From 6270e1e2b17ad0a747e5118d39d49e6c4ac61926 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Tue, 20 Aug 2024 17:32:28 +0900 Subject: [PATCH] [battery_plus] Fix analyze issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve following issues: info • example/lib/main.dart:78:23 • Don't use 'BuildContext's across async gaps. Try rewriting the code to not use the 'BuildContext', or guard the use with a 'mounted' check. • use_build_context_synchronously info • example/lib/main.dart:102:23 • Don't use 'BuildContext's across async gaps. Try rewriting the code to not use the 'BuildContext', or guard the use with a 'mounted' check. • use_build_context_synchronously --- packages/battery_plus/CHANGELOG.md | 1 + packages/battery_plus/example/lib/main.dart | 2 ++ 2 files changed, 3 insertions(+) diff --git a/packages/battery_plus/CHANGELOG.md b/packages/battery_plus/CHANGELOG.md index feac0ae74..8193fb7bb 100644 --- a/packages/battery_plus/CHANGELOG.md +++ b/packages/battery_plus/CHANGELOG.md @@ -1,6 +1,7 @@ ## NEXT * Update minimum Flutter and Dart version to 3.13 and 3.1. +* Fix analyze issue. ## 1.1.2 diff --git a/packages/battery_plus/example/lib/main.dart b/packages/battery_plus/example/lib/main.dart index 6aa8088a3..733f22835 100644 --- a/packages/battery_plus/example/lib/main.dart +++ b/packages/battery_plus/example/lib/main.dart @@ -74,6 +74,7 @@ class _MyHomePageState extends State { onPressed: () { _battery.batteryLevel.then( (batteryLevel) { + if (!context.mounted) return; showDialog( context: context, builder: (_) => AlertDialog( @@ -98,6 +99,7 @@ class _MyHomePageState extends State { onPressed: () { _battery.isInBatterySaveMode.then( (isInPowerSaveMode) { + if (!context.mounted) return; showDialog( context: context, builder: (_) => AlertDialog(