v4.0.1screen_loader
易於使用的 mixin ScreenLoader,可處理螢幕上的載入,而無需使用狀態或導航堆疊。您也可以自訂載入。
50喜歡 772近 30 天下載150Pub 分數
AndroidiOSWebmacOSWindowsLinux
易用的混合類型 ScreenLoader,可處理螢幕上的載入。您也可以自訂載入樣式,請參閱下方如何進行。
{"sdk":"flutter"}^3.0.4{"sdk":"flutter"}以下為英文專案原文快照,最新內容請造訪 GitHub。
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),
+ ),
),
);
}