resource_future

Last updated:

0 purchases

resource_future Image
resource_future Images
Add to Cart

Description:

resource future

Offers a ResourceFutureBuilder that handles a Future<Resource> and handles the result by calling
the passed methods for onSuccess, onLoading and onError depending on the state.

Usage #
Use a ResourceFutureBuilder like this:
import 'package:flutter/material.dart';
import 'package:resource_future/resource_future.dart';
import 'package:resource_result/resource_result.dart';

final Future<Resource<int>> getSomeIntFuture = Future.value(Success(3));
// or final Future<Resource<int>> getSomeIntFuture = Future.value(Failure(Error("I failed"));

final myIntResourceFutureBuilder = ResourceFutureBuilder(
future: getSomeIntFuture,
success: (context, myInt) => Text("My int loaded successfully: $myInt"),
loadingIndicator: (context) => const CircularProgressIndicator(),
/* optional handleError: defaults to red Text with error message */
handleError: (context, error) =>
Text("Failed to get my int :(. ${error.message}"),
);
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.