flutter_loader 0.0.2 copy "flutter_loader: ^0.0.2" to clipboard
flutter_loader: ^0.0.2 copied to clipboard

outdated

Provides widget for implementing UI with multiple states, i.e init, loading, error, loaded.

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) {
          return Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text('${LoaderController.of(context).data}'),
                SizedBox(height: 10),
                RaisedButton(
                  onPressed: () => LoaderController.of(context).load(
                    () => Future.delayed(
                        Duration(seconds: 3), () => Future.error('Oops')),
                  ),
                  child: Text('Error'),
                ),
                RaisedButton(
                  onPressed: () => LoaderController.of(context).load(),
                  child: Text('Success'),
                ),
              ],
            ),
          );
        },
      ),
    );
  }
}
6
likes
0
pub points
47%
popularity

Publisher

verified publisherhieurocker.com

Provides widget for implementing UI with multiple states, i.e init, loading, error, loaded.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_loader