flutter_loader 0.2.6 icon indicating copy to clipboard operation
flutter_loader: ^0.2.6 copied to clipboard

A Flutter package for simplifying resource loading with customizable UI

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_loader/flutter_loader.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: LoaderDemo(),
    );
  }
}

class LoaderDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter Loader Demo'),
      ),
      body: DefaultLoaderBuilder(
        themeData: DefaultLoaderThemeData(
          errorMessageResolver: (error) =>
              'Custom errorMessageResolver: $error',
        ),
        loader: () => Future.delayed(
          Duration(seconds: 3),
          () => 'Hello World',
        ),
        loadedBuilder: (context) {
          final controller = LoaderController.of(context)!;
          return Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text('${controller.data}'),
                SizedBox(height: 10),
                ElevatedButton(
                  onPressed: () => controller.load(
                    () => Future.delayed(
                        Duration(seconds: 3), () => Future.error('Oops')),
                  ),
                  child: Text('Error'),
                ),
                ElevatedButton(
                  onPressed: () => controller.load(),
                  child: Text('Success'),
                ),
              ],
            ),
          );
        },
      ),
    );
  }
}
5
likes
140
pub points
47%
popularity

Publisher

verified publisher iconhieurocker.com

A Flutter package for simplifying resource loading with customizable UI

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_loader