Last updated:
0 purchases
flutter async widgets
flutter_async_widgets #
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)),
);
}
}
copied to clipboard
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()),
],
),
);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.