better_future 2.0.0 copy "better_future: ^2.0.0" to clipboard
better_future: ^2.0.0 copied to clipboard

Advanced asynchronous orchestration with named results, and automatic dependency management and cleanup.

example/main.dart

import 'package:better_future/better_future.dart';

void main() async {
  print('--- Basic BetterFuture Example ---');

  final locale = 'fr';

  final results = await BetterFuture.wait({
    // A simple independent computation
    'greeting': () => switch (locale) {
      'fr' => 'Bonjour',
      _ => 'Hello',
    },

    // A computation depending on another result
    'message': ($) async {
      final greeting = await $.greeting<String>();
      return '$greeting BetterFuture!';
    },

    // A task running in parallel
    'timestamp': ($) => DateTime.now(),
  });

  print('Greeting: ${results['greeting']}');
  print('Full Message: ${results['message']}');
  print('Computed at: ${results['timestamp']}');
}
0
likes
160
points
147
downloads

Publisher

verified publisherd-markey.ovh

Weekly Downloads

Advanced asynchronous orchestration with named results, and automatic dependency management and cleanup.

Repository (GitHub)
View/report issues

Documentation

API reference

Funding

Consider supporting this project:

github.com

License

Apache-2.0 (license)

More

Packages that depend on better_future