flutter_state_provider 0.0.1 copy "flutter_state_provider: ^0.0.1" to clipboard
flutter_state_provider: ^0.0.1 copied to clipboard

package designed to simplify API request management by offering seamless handling of loading, success, and error states. Integrated with 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';

Usage with when #

state = StateProvider.loading();

state.when(
    // When the state is loading
    () => CircularProgressIndicator(),
    (error) {
     return ErrorWidget(error);
    },
     (success) {
        return SuccessWidget(success);
    },
  ),

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),
  };
3
likes
160
points
59
downloads

Publisher

unverified uploader

Weekly Downloads

package designed to simplify API request management by offering seamless handling of loading, success, and error states. Integrated with Provider.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on flutter_state_provider