flutter_easyloading
flutter_easyloading copied to clipboard
Add backbutton interceptor support.
following plugin backbuttonintercept could be integrated wherein a disable back button flag could be added to disable the android back button when the loader is showing.
Thanks for taking the time to open an issue. I will have a look and answer as soon as possible.
A simple way to get around this issue is to create a wrapper class around EasyLoader and implement the BackButtonInterceptor plugin inside it like so :
import 'package:back_button_interceptor/back_button_interceptor.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
class Loader {
static void show({String? status}) {
// Intercept the back button
BackButtonInterceptor.add(interceptor);
// Show the loader
EasyLoading.show(
status: status
);
}
static void dismiss() {
// Dismiss the loader
EasyLoading.dismiss();
// Dismiss the back button interceptor
BackButtonInterceptor.remove(interceptor);
}
// Back button interceptor function
static bool interceptor(bool stopEvent, RouteInfo info) {
// Do whatever you want when intercepting the back button
return true;
}
}
Then you can call the loader anywhere in your code like so :
// ...
import 'package:your_app/wrapper/path/loader.dart';
// ...
Loader.show(
status: 'The loader status message'
);
// Do some stuff while the loader is displayed
Loader.dismiss();
// ...
I'm not sure it's the best way to do it, but it should cover simple use cases.