Skip to content
This repository was 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 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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.10

* Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276))
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
2 changes: 1 addition & 1 deletion packages/battery/battery/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ 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: 9 additions & 7 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.10
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,13 +16,15 @@ flutter:
dependencies:
flutter:
sdk: flutter
meta: ^1.0.5
battery_platform_interface: ^1.0.0
meta: ^1.3.0-nullsafety.6
battery_platform_interface:
git:
url: https://github.com/bparrishMines/plugins.git
ref: batter_interface_nnbd
path: packages/battery/battery_platform_interface

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
Expand All @@ -31,5 +33,5 @@ dev_dependencies:
pedantic: ^1.8.0

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