flutter_state_provider

Last updated:

0 purchases

flutter_state_provider Image
flutter_state_provider Images
Add to Cart

Description:

flutter state provider

state_provider #
Flutter package designed to simplify API request management by offering seamless handling of loading, success, and error states. Integrated with Provider, it efficiently manages and notifies the application of the various states during API requests, enhancing the development experience for Flutter developers.
How To Use StateProvider #
Import the following package in your dart file
import 'package:flutter_state_provider/flutter_state_provider.dart';
copied to clipboard
Usage with when #
state = StateProvider.loading();

state.when(
// When the state is loading
() => CircularProgressIndicator(),
(error) {
return ErrorWidget(error);
},
(success) {
return SuccessWidget(success);
},
),
copied to clipboard
Usage with switch #
state = StateProvider.loading();

switch (state) {
case LoadingState():
return CircularProgressIndicator();
case ErrorState():
return ErrorWidget(state.error);
case SuccessState():
return SuccessWidget(state.success);
}
``

// OR
return switch (state) {
LoadingState()=>
CircularProgressIndicator(),
ErrorState()=> ErrorWidget(state.error),
SuccessState()=> SuccessWidget(state.success),
};
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.