FLUTTER ECOSYSTEM

arnold-parge/screen_loader

화면의 로딩을 처리하는 사용하기 쉬운 믹스인 ScreenLoader입니다. 로딩을 맞춤 설정할 수도 있으며, 아래에서 그 방법을 확인하세요.

screen_loader 프로젝트 이미지
Stars
9
Forks
5
최근 푸시(UTC)
2025. 2. 25.
프로젝트 상태
활성
arnold-parge GitHub avatar
GITHUB User

arnold-parge ↗

언어Dart

기술 주제

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 3 개
  • flutter{"sdk":"flutter"}
  • stream_mixin^3.0.4
  • flutter_test개발 의존성{"sdk":"flutter"}

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

screen_loader

Why ScreenLoader?

  1. With the help of stream_mixin, it shows and hides the loader without updating the state of the widget which increases the performance
  2. It does not push any sort of widget to navigation stack, this helps in not messing up the navigation stack and context
  3. Easy to use, just use your screen with ScreenLoader mixin and wrap the widget with loadableWidget
  4. The loader is customizable. You can use any widget as a loader
  5. You can configure same loader for all the screens at once
  6. You can also configure different loader for different screens

Basic usage

  1. Use your screen with the ScreenLoader mixin
  2. Wrap the widget with loadableWidget
  3. Use performFuture function to show loader while your future is being performed
https://raw.githubusercontent.com/arnold-parge/screen_loader/master/example/basic.gif

Configure different loader for individual screen

Simply 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

Configure the loader for all screens at once

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

Priority of loaders (highest first)

  • Local loader: the one you override in your widget
  • Global loader: the one you specify in configScreenLoader. Note: if you don't override local(), this loader will be used
  • Default loader: if you don't specify global loader or override local loader, this loader will be used

Migration guide to 4.0.0

  1. ScreenLoaderApp 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(),
     );
   }
 }
  1. Instead of replacing the 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),
+        ),
       ),
     );
   }

PS
  • PRs are welcome
  • Please raise issues on https://github.com/arnold-parge/screen_loader.
  • Open for suggestions ❤️