sparkrook

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

sparkrook

SparkRook #

About #
A flutter widget to replace all your API call logic. Want to call an API on the go? Just embed this widget in your project.
Installing #

To use this package in your Flutter project add this to your pubspec.yaml
dependencies:
sparkrook: ^1.0.2
copied to clipboard
Usage #
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SparkRookWidget<List<Comment>, Comment>(
url: Services.commentsAPI,
method: HttpMethod.GET,
parser: Comment.fromJson,
builder: (context, state) {
return state.maybeWhen(
() => Container(),
loading: () => const Center(
child: CircularProgressIndicator(),
),
dataReceived: (data) {
return ListView.builder(
itemCount: data?.length ?? 0,
itemBuilder: (_, i) {
return SizedBox(
height: 40,
child: Card(
child: Column(
children: [
Text(data?[i].name ?? ""),
],
),
),
);
},
);
},
errorReceived: (error) {
return Center(
child: Text(
error.message,
),
);
},
orElse: () => Container(),
);
},
),
),
);
}
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.