flutter easyloading
a clean and lightweight loading widget for flutter app, easy to use without context.
installing
add this to your package’s pubspec.yaml
file:
dependencies:
flutter_easyloading: ^1.0.1
import
import 'package:flutter_easyloading/flutter_easyloading.dart';
how to use
first, warp your app widget with fluttereasyloading
:
class myapp extends statelesswidget {
@override
widget build(buildcontext context) {
/// child should be [materialapp] or [cupertinoapp].
/// make sure that loading can be displayed in front of all other widgets
return fluttereasyloading(
child: materialapp(
title: 'flutter easyloading',
theme: themedata(
primaryswatch: colors.blue,
),
home: myhomepage(title: 'flutter easyloading'),
),
);
}
}
then, enjoy yourself:
easyloading.show(status: 'loading...');
easyloading.showsuccess('great success!');
easyloading.showerror('failed with error');
easyloading.showinfo('useful information.');
easyloading.dismiss();
custom
/// loading style, default [easyloadingstyle.dark].
easyloadingstyle loadingstyle;
/// loading indicator type, default [easyloadingindicatortype.fadingcircle].
easyloadingindicatortype indicatortype;
/// loading mask type, default [easyloadingmasktype.none].
easyloadingmasktype masktype;
/// textalign of status, default [textalign.center].
textalign textalign;
/// content padding of loading.
edgeinsets contentpadding;
/// padding of [status].
edgeinsets textpadding;
/// size of indicator, default 40.0.
double indicatorsize;
/// radius of loading, default 5.0.
double radius;
/// fontsize of loading, default 15.0.
double fontsize;
/// display duration of [showsuccess] [showerror] [showinfo], default 2000ms.
duration displayduration;
/// color of loading status, only used for [easyloadingstyle.custom].
color textcolor;
/// color of loading indicator, only used for [easyloadingstyle.custom].
color indicatorcolor;
/// background color of loading, only used for [easyloadingstyle.custom].
color backgroundcolor;
/// mask color of loading, only used for [easyloadingmasktype.custom].
color maskcolor;
/// should allow user interactions while loading is displayed.
bool userinteractions;
/// success widget of loading
widget successwidget;
/// error widget of loading
widget errorwidget;
/// info widget of loading
widget infowidget;
because easyloading
is a singleton, so you can custom loading style any where like this:
easyloading.instance
..displayduration = const duration(milliseconds: 2000)
..indicatortype = easyloadingindicatortype.fadingcircle
..loadingstyle = easyloadingstyle.dark
..indicatorsize = 45.0
..radius = 10.0
..backgroundcolor = colors.green
..indicatorcolor = colors.yellow
..textcolor = colors.yellow
..maskcolor = colors.blue.withopacity(0.5)
..userinteractions = true;
more indicatortype can see in flutter_spinkit showcase
todo
- [ ] add progress indicator
- [ ] add custom animation
Comments are closed.