Future<AndroidBatteryInfo?>' can't be assigned to the parameter type 'Future<AndroidBatteryInfo>?'
lvlasuod opened this issue · 2 comments
Hi
I installed the package and created an example same as the package, I got this error.
Running Gradle task 'assembleDebug'...
lib/main.dart:26:47: Error: The argument type 'Future<AndroidBatteryInfo?>' can't be assigned to the parameter type 'Future?' because 'AndroidBatteryInfo?' is nullable and 'AndroidBatteryInfo' isn't.
- 'Future' is from 'dart:async'.
pubsec.yaml
name: battery_health
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
battery_info:
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
flutter:
uses-material-design: true
Hi,
The example is out of date. The package has recently moved to null-safety.
You should be able to fix the issue by changing FutureBuilder to FutureBuilder<AndroidBatteryInfo?> here:
https://github.com/igrik12/battery_info/blob/master/example/lib/main.dart#L22
The same should work for StreamBuilder.
I will update the example project to reflect the null-safety changes