v4.0.1screen_loader
状態やナビゲーションスタックを使用せずに、画面の読み込みを処理する簡単なミックスイン ScreenLoader。ロードのカスタマイズも可能です。
50いいね 77230日間ダウンロード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),
+ ),
),
);
}