Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[battery] Migrate battery to null safety #3380

Merged
merged 6 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/battery/battery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.0-nullsafety

* Migrate to null safety.

## 1.0.11

* Update the example app: remove the deprecated `RaisedButton` and `FlatButton` widgets.
Expand Down
8 changes: 4 additions & 4 deletions packages/battery/battery/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MyApp extends StatelessWidget {
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
MyHomePage({Key? key, required this.title}) : super(key: key);

final String title;

Expand All @@ -36,10 +36,10 @@ class MyHomePage extends StatefulWidget {
}

class _MyHomePageState extends State<MyHomePage> {
Battery _battery = Battery();
final Battery _battery = Battery();

BatteryState _batteryState;
StreamSubscription<BatteryState> _batteryStateSubscription;
BatteryState? _batteryState;
late StreamSubscription<BatteryState> _batteryStateSubscription;

@override
void initState() {
Expand Down
4 changes: 2 additions & 2 deletions packages/battery/battery/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ dev_dependencies:
sdk: flutter
integration_test:
path: ../../../integration_test
pedantic: ^1.8.0
pedantic: ^1.10.0-nullsafety

flutter:
uses-material-design: true

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: ">=2.12.0-0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
2 changes: 2 additions & 0 deletions packages/battery/battery/integration_test/battery_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart = 2.9

import 'package:flutter_test/flutter_test.dart';
import 'package:battery/battery.dart';
import 'package:integration_test/integration_test.dart';
Expand Down
16 changes: 7 additions & 9 deletions packages/battery/battery/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: battery
description: Flutter plugin for accessing information about the battery state
(full, charging, discharging) on Android and iOS.
homepage: https://github.com/flutter/plugins/tree/master/packages/battery/battery
version: 1.0.11
version: 2.0.0-nullsafety
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.0.0-nullsafety.0 maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the standard for this repo is to not add the .0 at the end:

https://github.com/flutter/plugins/blob/master/packages/webview_flutter/CHANGELOG.md#200-nullsafety
https://github.com/flutter/plugins/blob/master/packages/plugin_platform_interface/CHANGELOG.md#110-nullsafety

It would probably be best to follow the same pattern unless @amirh or @cyanglaz suggest something different.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the adopted style then ok.

However, it is a common mistake to interchange between suffix and suffix.0 while the former intended to read any version with the suffix and the later this is version 0 for this suffix. Omitting suffix in the version effectively creates an implicit suffix.0 version and looks ambiguous.


flutter:
plugin:
Expand All @@ -16,20 +16,18 @@ flutter:
dependencies:
flutter:
sdk: flutter
meta: ^1.0.5
battery_platform_interface: ^1.0.0
meta: ^1.3.0-nullsafety
battery_platform_interface: ^2.0.0-nullsafety

dev_dependencies:
async: ^2.0.8
test: ^1.3.0
mockito: ^4.1.1
mockito: ^5.0.0-nullsafety.0
bparrishMines marked this conversation as resolved.
Show resolved Hide resolved
flutter_test:
sdk: flutter
plugin_platform_interface: ^1.0.0
plugin_platform_interface: ^1.1.0-nullsafety
integration_test:
path: ../../integration_test
pedantic: ^1.8.0
pedantic: ^1.10.0-nullsafety

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: ">=2.12.0-0 <3.0.0"
flutter: ">=1.12.13+hotfix.5"
4 changes: 2 additions & 2 deletions packages/battery/battery/test/battery_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import 'dart:async';

import 'package:battery_platform_interface/battery_platform_interface.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'package:test/test.dart';
import 'package:battery/battery.dart';
import 'package:mockito/mockito.dart';

void main() {
group('battery', () {
Battery battery;
late Battery battery;
MockBatteryPlatform fakePlatform;
setUp(() async {
fakePlatform = MockBatteryPlatform();
Expand Down