potatoes library

Classes

ApiService
ApiService is the main class to use to make API calls. This use an instance of Dio (possibly created using DioClient) and has several methods to automatize data extraction
CubitErrorState
A cubit state representing an error. CubitErrorState can track the originating error as well the stack trace. Each time a new CubitErrorState is created, it is streamed into CubitErrorState.stream so that you could implement a global error tracker/logger.
CubitInformationState
A cubit state representing a timely information, for example the confirmation of the execution of a process
CubitLoadingState
A cubit state representing a loading state. Cubit is fetching data and so is not in a ready state
CubitManager<C extends Cubit, T, I>
A CubitManager is a factory for a single Cubit type. It handles the lifecycle of the cubits of a specific type by assigning id to each instance. This is handy when you want to ensure that only one cubit of each id is used across your app. A classic use case could be managing posts cubits inside and app, with posts objects that can be edited as the app runs. CubitManager will ensure that only one cubit is associated to a specific post (given a unique post ID). While using CubitManager, you may not want the cubits to be automatically closed by widgets such as BlocProvider. Be sure to always use BlocProvider.value instead of the default constructor, as the latest internally handle the created cubit lifecycle. CubitManager needs three generic types in order to be instanced:
CubitSuccessState
A Cubit state representing a lasting success/idle state. Extend this class and add all the relevant attributes you need to be in a success state
DioClient
This class's only purpose is to instantiate new Dio objects
InitialValueCubit<T>
A Cubit to wrap a single type with an initial value. Use reset to revert the cubit to its initial value
Links is a multi-purpose class made to handle HTTP links with your app. Its used by DioClient to setup new instances
ObjectCubit<O, S>
An ObjectCubit is an implementation of a Cubit designed to handle the lifecycle of a single object. This is specifically effective to track business objects as you might want to update them while still tracking the same Cubit. ObjectCubit ensures that you can get the last version registered version of the tracked object at anytime, regardless of the current cubit state. ObjectCubit uses two generic types:
Phoenix
A simple widget to rebuild the whole app tree from a BuildContext. Wrap your main widget (typically "MyApp") with this and simply call Phoenix.rebirth(context) to rebuild the whole app.
PreferencesService
PreferencesService is an adapter of the regular SharedPreferences providing more organization to the preferences management and preventing misuses
ValueCubit<T>
A Cubit to wrap a single type

Mixins

CompletableMixin<T extends StatefulWidget>
CompletableMixin is an extension allowing you to seamlessly add a whole screen loader on your page. Assign a value to loadingDialogCompleter to display your loader, then call waitForDialog in order to dismiss it.

Functions

showLoadingBarrier({required BuildContext context, String? text}) Completer<BuildContext>
A simple loader that can be used in conjunction with CompletableMixin. Displays a simple AlertDialog that covers the whole screen until dismissed. User cannot dismiss it from screen touch or back press.
showSimpleLoadingBarrier({required BuildContext context}) Completer<BuildContext>
A simple loader that can be used in conjunction with CompletableMixin. Displays a translucent barrier that covers the whole screen until dismissed. User cannot dismiss it from screen touch or back press.

Exceptions / Errors

ApiError
This is a generic class to handle and display errors across your app. APIError helps you track errors coming from API call and display an error message accordingly. It also maintain the original Exception as well as the stack trace