Search packages, repositories and app categories

screen_loader cover
Package detailsv4.0.1

screen_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.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
1.5K
Likes
50
Pub points
150

Install package

flutter pub add screen_loader

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

ScreenLoader is a Flutter/Dart package that provides a simple mixin to manage on-screen loading states without requiring explicit state management or navigation stack manipulation. It enables developers to display and control loading indicators across screens with minimal boilerplate. The package supports customization of the loading UI, making it adaptable to various design needs. Ideal for apps needing consistent, reusable loading experiences across multiple widgets.

Use cases

  • Displaying loading overlays during async operations
  • Simplifying loading state management in forms
  • Adding loading indicators to API calls
  • Creating reusable loading components
  • Enhancing UX with smooth loading transitions
  • Reducing boilerplate in screen-level loading logic

Key features

  • Mixin-based loading implementation
  • Customizable loading UI
  • No need for state management
  • Works across all platforms
  • Minimal setup required
  • Supports asynchronous operation handling

Suitable for

  • Developers seeking lightweight loading solutions
  • Teams using minimal state management
  • Apps with frequent async data fetching
  • UI-heavy applications needing consistent loaders
  • Flutter beginners exploring loading patterns
  • Cross-platform apps targeting multiple devices

Considerations

  • Limited to basic loading functionality
  • Requires manual integration with async workflows
  • Not suitable for complex loading states
  • May need additional styling for custom designs
  • Depends on proper widget tree structure
  • Does not handle error states by default

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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

Configure different loader for individual screen

Simply overide loader() method

loader() {
    // here any widget would do
    return AlertDialog(
        title: Text('Wait.. Loading data..'),
    );
}

Configure the loader for all screens at once

void main() {
  configScreenLoader(
    loader: AlertDialog(
      title: Text('Gobal Loader..'),
    ),
    bgBlur: 20.0,
  );
  runApp(MyApp());
}

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 ❤️

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package

No data available yet.