v4.0.1screen_loader
Easy to use mixin ScreenLoader, which will handle the loading on the screen without using state or navigation stack. You can customise the loading as well.
50Likes 77230-day downloads150Pub points
AndroidiOSWebmacOSWindowsLinux
Easy to use mixin ScreenLoader, which will handle the loading on the screen. You can customize the loading as well, check below how it is done.
{"sdk":"flutter"}^3.0.4{"sdk":"flutter"}English project snapshot. Visit GitHub for the latest content.
stream_mixin, it shows and hides the loader without updating the state of the widget which increases the performanceScreenLoader mixin and wrap the widget with loadableWidgetScreenLoader mixinloadableWidgetperformFuture function to show loader while your future is being performedSimply overide loader() method
loader() {
// here any widget would do
return AlertDialog(
title: Text('Wait.. Loading data..'),
);
}
https://raw.githubusercontent.com/arnold-parge/screen_loader/master/example/local.gif
void main() {
configScreenLoader(
loader: AlertDialog(
title: Text('Gobal Loader..'),
),
bgBlur: 20.0,
);
runApp(MyApp());
}
https://raw.githubusercontent.com/arnold-parge/screen_loader/master/example/global.gif
configScreenLoader. Note: if you don't override local(), this loader will be usedScreenLoaderApp widget is removed. Now no need to wrap your App around any widget just to set the global configurations. Instead call configScreenLoader() before runApp()-void main() => runApp(MyApp());
+void main() {
+ configScreenLoader(
+ loader: AlertDialog(
+ title: Text('Gobal Loader..'),
+ ),
+ bgBlur: 20.0,
+ );
+ runApp(MyApp());
+}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return ScreenLoaderApp(
- app: MaterialApp(
- debugShowCheckedModeBanner: false,
- title: 'Screen Loader',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: Screen(),
- ),
- globalLoader: AlertDialog(
- title: Text('Gobal Loader..'),
+ return MaterialApp(
+ debugShowCheckedModeBanner: false,
+ title: 'Screen Loader',
+ theme: ThemeData(
+ primarySwatch: Colors.blue,
),
- globalLoadingBgBlur: 20.0,
+ home: Screen(),
);
}
}
build function with screen use the build function itself and wrap the widget you want to show loader on with the loadableWidget.
-class _ScreenState extends State<Screen> with ScreenLoader<Screen> {
+class _ScreenState extends State<Screen> with ScreenLoader {
@override
loader() {
return AlertDialog(
@@ -49,17 +51,19 @@ class _ScreenState extends State<Screen> with ScreenLoader<Screen> {
}
@override
- Widget screen(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text('ScreenLoader Example'),
- ),
- body: _buildBody(),
- floatingActionButton: FloatingActionButton(
- onPressed: () async {
- await this.performFuture(NetworkService.getData);
- },
- child: Icon(Icons.refresh),
+ Widget build(BuildContext context) {
+ return loadableWidget(
+ child: Scaffold(
+ appBar: AppBar(
+ title: Text('ScreenLoader Example'),
+ ),
+ body: _buildBody(),
+ floatingActionButton: FloatingActionButton(
+ onPressed: () async {
+ await this.performFuture(NetworkService.getData);
+ },
+ child: Icon(Icons.refresh),
+ ),
),
);
}