flutter_async_widgets 1.0.0 copy "flutter_async_widgets: ^1.0.0" to clipboard
flutter_async_widgets: ^1.0.0 copied to clipboard

Flutter async convenience widgets

flutter_async_widgets #

style: lint pub package

Convenience widgets for working with asynchronicity

AsyncBuilder #

Simple example with a single Future

class ExampleWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AsyncBuilder.single<String>(
      Future.delayed(const Duration(seconds: 3), () => 'String from the future'),
      onData: (context, data) => Center(child: Text(data)),
    );
  }
}

Complex example with three Futures. The widget will show the loading state until all three Futures complete.

class ExampleWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AsyncBuilder.combine3<String, int, double>(
      Future.delayed(const Duration(seconds: 1), () => 'String from the future'),
      Future.delayed(const Duration(seconds: 6), () => 42),
      Future.delayed(const Duration(seconds: 3), () => 1337.0),
      onData: (context, a, b, c) => Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Text(a),
          Text(b.toString()),
          Text(c.toString()),
        ],
      ),
    );
  }
}
4
likes
150
points
58
downloads

Publisher

verified publisherdevnico.me

Weekly Downloads

Flutter async convenience widgets

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, riverpod

More

Packages that depend on flutter_async_widgets