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

outdated

Deferred type for working with asynchronous data.

Deferred type for Dart #

Modeling asynchronous data made easy. Comes with a FutureBuilder2 widget for use in Flutter applications.

Examples #

final Deferred<String> idle = Deferred.idle();
final Deferred<String> inProgress = Deferred.inProgress();
final Deferred<String> success = Deferred.success('DATA!');
final Deferred<String> error = Deferred.error('ERROR!');

Flutter #

FutureBuilder2, an alternative "FutureBuilder" which is simpler to use than the bundled one provided by default in Flutter.

import "package:deferred_type/deferred_type.dart";

final futureBuilder = FutureBuilder2<String>(
  future: someFuture,
  builder: (context, state) => state.maybeWhen<Widget>(
    inProgress: () => const CircularProgressIndicator(),
    success: (data) => SomeWidget(data),
    error: (error, _stacktrace) => SomeErrorWidget(error),
    // handle fallback cases, must be provided 
    // if all states are not handled.
    orElse: () => const FallbackWidget(),
  );
);

Possible to-do #

  • Write some tests.
  • Version with fpdart integration.
  • Come up with a better name for the FutureBuilder.

Other resources #

1
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Deferred type for working with asynchronous data.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on deferred_type