-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor loading providers to a widget
- Loading branch information
Showing
8 changed files
with
129 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:yaru/yaru.dart'; | ||
|
||
class BlockingProviderPreloader<T> extends ConsumerWidget { | ||
const BlockingProviderPreloader({ | ||
super.key, | ||
required this.provider, | ||
required this.builder, | ||
}); | ||
|
||
final ProviderListenable<AsyncValue<T>> provider; | ||
final Widget Function(BuildContext context, T value) builder; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final value = ref.watch(provider); | ||
|
||
return value.when( | ||
data: (value) => builder(context, value), | ||
error: (e, stack) => | ||
Center(child: Text('Error:\n$e\nStackTrace:\n$stack')), | ||
loading: () => const Center(child: YaruCircularProgressIndicator()), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 6 additions & 9 deletions
15
frontend/lib/ui/dashboard/dashboard_body/dashboard_body.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.