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

Commit 4fec227

Browse files
[battery] Migrate battery to null safety (#3380)
1 parent 782a7a9 commit 4fec227

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

packages/battery/battery/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.0-nullsafety
2+
3+
* Migrate to null safety.
4+
15
## 1.0.11
26

37
* Update the example app: remove the deprecated `RaisedButton` and `FlatButton` widgets.

packages/battery/battery/example/lib/main.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class MyApp extends StatelessWidget {
2727
}
2828

2929
class MyHomePage extends StatefulWidget {
30-
MyHomePage({Key key, this.title}) : super(key: key);
30+
MyHomePage({Key? key, required this.title}) : super(key: key);
3131

3232
final String title;
3333

@@ -36,10 +36,10 @@ class MyHomePage extends StatefulWidget {
3636
}
3737

3838
class _MyHomePageState extends State<MyHomePage> {
39-
Battery _battery = Battery();
39+
final Battery _battery = Battery();
4040

41-
BatteryState _batteryState;
42-
StreamSubscription<BatteryState> _batteryStateSubscription;
41+
BatteryState? _batteryState;
42+
late StreamSubscription<BatteryState> _batteryStateSubscription;
4343

4444
@override
4545
void initState() {

packages/battery/battery/example/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ dev_dependencies:
1212
sdk: flutter
1313
integration_test:
1414
path: ../../../integration_test
15-
pedantic: ^1.8.0
15+
pedantic: ^1.10.0-nullsafety
1616

1717
flutter:
1818
uses-material-design: true
1919

2020
environment:
21-
sdk: ">=2.1.0 <3.0.0"
21+
sdk: ">=2.12.0-0 <3.0.0"
2222
flutter: ">=1.12.13+hotfix.5 <2.0.0"

packages/battery/battery/integration_test/battery_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// @dart = 2.9
6+
57
import 'package:flutter_test/flutter_test.dart';
68
import 'package:battery/battery.dart';
79
import 'package:integration_test/integration_test.dart';

packages/battery/battery/pubspec.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: battery
22
description: Flutter plugin for accessing information about the battery state
33
(full, charging, discharging) on Android and iOS.
44
homepage: https://github.com/flutter/plugins/tree/master/packages/battery/battery
5-
version: 1.0.11
5+
version: 2.0.0-nullsafety
66

77
flutter:
88
plugin:
@@ -16,20 +16,18 @@ flutter:
1616
dependencies:
1717
flutter:
1818
sdk: flutter
19-
meta: ^1.0.5
20-
battery_platform_interface: ^1.0.0
19+
meta: ^1.3.0-nullsafety
20+
battery_platform_interface: ^2.0.0-nullsafety
2121

2222
dev_dependencies:
23-
async: ^2.0.8
24-
test: ^1.3.0
25-
mockito: ^4.1.1
23+
mockito: ^5.0.0-nullsafety.0
2624
flutter_test:
2725
sdk: flutter
28-
plugin_platform_interface: ^1.0.0
26+
plugin_platform_interface: ^1.1.0-nullsafety
2927
integration_test:
3028
path: ../../integration_test
31-
pedantic: ^1.8.0
29+
pedantic: ^1.10.0-nullsafety
3230

3331
environment:
34-
sdk: ">=2.1.0 <3.0.0"
32+
sdk: ">=2.12.0-0 <3.0.0"
3533
flutter: ">=1.12.13+hotfix.5"

packages/battery/battery/test/battery_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
import 'dart:async';
66

77
import 'package:battery_platform_interface/battery_platform_interface.dart';
8+
import 'package:flutter_test/flutter_test.dart';
89
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
9-
import 'package:test/test.dart';
1010
import 'package:battery/battery.dart';
1111
import 'package:mockito/mockito.dart';
1212

1313
void main() {
1414
group('battery', () {
15-
Battery battery;
15+
late Battery battery;
1616
MockBatteryPlatform fakePlatform;
1717
setUp(() async {
1818
fakePlatform = MockBatteryPlatform();

0 commit comments

Comments
 (0)