Skip to content

Commit

Permalink
[battery] Migrate battery to null safety (#3380)
Browse files Browse the repository at this point in the history
  • Loading branch information
bparrishMines committed Jan 13, 2021
1 parent 782a7a9 commit 4fec227
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
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

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
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

0 comments on commit 4fec227

Please sign in to comment.