Preserve Flutter mirror-os codebase
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mirror_core/mirror_core.dart';
|
||||
|
||||
final programsApiProvider = Provider<ProgramsApiClient>((ref) {
|
||||
return ProgramsApiClient(baseUrl: 'http://192.168.86.172:8091');
|
||||
});
|
||||
|
||||
final programsProvider =
|
||||
AsyncNotifierProvider<ProgramsNotifier, List<Program>>(ProgramsNotifier.new);
|
||||
|
||||
class ProgramsNotifier extends AsyncNotifier<List<Program>> {
|
||||
@override
|
||||
Future<List<Program>> build() async {
|
||||
final client = ref.read(programsApiProvider);
|
||||
return client.fetchPrograms();
|
||||
}
|
||||
|
||||
Future<void> refresh() async {
|
||||
state = const AsyncValue.loading();
|
||||
state = await AsyncValue.guard(() async {
|
||||
final client = ref.read(programsApiProvider);
|
||||
return client.fetchPrograms();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user