Line data Source code
1 : part of flutter_data; 2 : 3 : typedef FutureFn<R> = FutureOr<R> Function(); 4 : 5 : class DataHelpers { 6 3 : static final uuid = Uuid(); 7 : 8 1 : static String getType<T>([String? type]) { 9 1 : if (T == dynamic && type == null) { 10 0 : throw UnsupportedError('Please supply a type'); 11 : } 12 1 : type ??= T.toString(); 13 1 : type = type.decapitalize(); 14 1 : return type.pluralize(); 15 : } 16 : 17 1 : static String generateKey<T>([String? type]) { 18 1 : type = getType<T>(type); 19 4 : return StringUtils.typify(type, uuid.v1().substring(0, 8)); 20 : } 21 : } 22 : 23 : class OfflineException extends DataException { 24 2 : OfflineException({required Object error}) : super(error); 25 1 : @override 26 : String toString() { 27 2 : return 'OfflineException: $error'; 28 : } 29 : } 30 : 31 : abstract class _Lifecycle { 32 : @protected 33 : @visibleForTesting 34 : bool get isInitialized; 35 : 36 : void dispose(); 37 : } 38 : 39 : typedef Watcher = W Function<W>(ProviderListenable<W> provider); 40 : 41 : typedef OneProvider<T extends DataModel<T>> 42 : = AutoDisposeStateNotifierProvider<DataStateNotifier<T?>, DataState<T?>> 43 : Function( 44 : dynamic id, { 45 : bool? remote, 46 : Map<String, dynamic>? params, 47 : Map<String, String>? headers, 48 : AlsoWatch<T>? alsoWatch, 49 : }); 50 : 51 : typedef AllProvider<T extends DataModel<T>> = AutoDisposeStateNotifierProvider< 52 : DataStateNotifier<List<T>>, DataState<List<T>>> 53 : Function({ 54 : bool? remote, 55 : Map<String, dynamic>? params, 56 : Map<String, String>? headers, 57 : bool? syncLocal, 58 : });