flutter_async 0.6.1 copy "flutter_async: ^0.6.1" to clipboard
flutter_async: ^0.6.1 copied to clipboard

Handle async tasks with ease through automatic loading, error handling, and native widget integration.

example/lib/main.dart

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

void main() => runApp(const MaterialApp(home: Scaffold(body: MyWidget())));

class MyWidget extends StatelessWidget {
  const MyWidget({super.key});

  @override
  Widget build(BuildContext context) {

    return AsyncBuilder<int>.function(
      future: () => Future.delayed(const Duration(seconds: 3), () => 5),
      builder: (context, data) {
        return Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            AsyncElevatedButton(
              key: const Key('first'),
              config: const AsyncButtonConfig(keepHeight: true
                  // loadingBuilder: (_) => const Text('Loading...'),
                  ),
              onPressed: () async {
                await Future.delayed(const Duration(seconds: 2));
                throw 'error';
              },
              child: const Text('data'),
            ),
            AsyncElevatedButton(
              config: AsyncButtonConfig(
                loadingBuilder: (_) => const Text('Loading...'),
              ),
              onPressed: () {
                AsyncBuilder.of(context).reload();
              },
              child: const Text('data'),
            ),
          ],
        );
      },
    );
  }
}
3
likes
0
pub points
66%
popularity

Publisher

verified publisherbranvier.com

Handle async tasks with ease through automatic loading, error handling, and native widget integration.

Homepage

License

unknown (license)

Dependencies

animated_value, async_notifier, flutter

More

Packages that depend on flutter_async