Skip to content

Commit 6254f10

Browse files
committed
Edit example code by using BuildContext synchronously
Edit pubspec.yaml description
1 parent ac4cf0f commit 6254f10

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.0.2
2+
3+
- Edit pubspec.yaml description
4+
- Edit `example/lib/main.dart` by using BuildContext synchronously
5+
16
## 0.0.1
27

38
Initial release including the following features:

example/lib/main.dart

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore_for_file: use_build_context_synchronously
2-
31
import 'dart:io';
42

53
import 'package:flutter/material.dart';
@@ -36,21 +34,16 @@ class _MyAppState extends State<MyApp> {
3634
String dropdownValue = Platform.isIOS ? iconsIOS.first : iconsAndroid.first;
3735
final _flutterIconDynamicPlugin = FlutterIconDynamic();
3836

39-
@override
40-
void initState() {
41-
super.initState();
42-
}
43-
4437
Future<void> changeIcon(String icon, BuildContext context) async {
4538
try {
4639
final value = await _flutterIconDynamicPlugin.setIcon(icon, androidIcons: iconsAndroid);
47-
if (value) {
48-
showSnackBar(context, 'Icon changed to $icon');
49-
} else {
50-
showSnackBar(context, 'Failed to change icon to $icon');
40+
if (context.mounted) {
41+
showSnackBar(context, value ? 'Icon changed to $icon' : 'Failed to change icon to $icon');
5142
}
5243
} catch (e) {
53-
showSnackBar(context, 'Failed to change icon to $icon: $e');
44+
if (context.mounted) {
45+
showSnackBar(context, 'Failed to change icon to $icon: $e');
46+
}
5447
}
5548
}
5649

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_icon_dynamic
2-
description: "Change your mobile app icon dynamically"
3-
version: 0.0.1
2+
description: "Change your Android and iOS app icon dynamically without any hassle!"
3+
version: 0.0.2
44
homepage: https://github.com/sncf-connect-tech/flutter_icon_dynamic
55

66
environment:

0 commit comments

Comments
 (0)