fluttertoast: I’m using the ^8.2.4 package. I wrapped it with BatteryLevelCubit in my MaterialApp.router widget. In it I check the battery status every minute.
What I want is to be able to show this toast message no matter what screen the user is on. But I have no idea where the flutter icon comes from and why the changes I want are not happening.
What I tried:
void showLowBatteryAlert({required int batteryLevel}) {
if (!isShowLowBatteryAlert) {
if (batteryLevel == batteryLevel) {
emit(LowBatteryLevelState(batteryLevel));
}
}
}
class LowBatteryLevelState extends BatteryLevelState {
LowBatteryLevelState(this.batteryLevel) {
Fluttertoast.showToast(
msg: 'Low Battery Level: $batteryLevel',
backgroundColor: Colors.red,
fontSize: 16.sp,
textColor: Colors.white,
gravity: ToastGravity.TOP,
);
}
final int batteryLevel;
}
2
Answers
Thank you: https://stackoverflow.com/users/14071053/aks
The answer:
From the Android 12 release, the view of the Toast message has been redesigned to include two lines of text and display the app icon next to the text. If you don't want to show that icon you can try to create custom toast. You can see the custom toast creation process on
Feel free to reply if the code is not working
Here is the Modified code: