Allow all providers to be scoped (#542)

This commit is contained in:
Remi Rousselet
2021-06-27 14:40:35 +02:00
committed by GitHub
parent 7864d7884f
commit 6ce875ae62
67 changed files with 1647 additions and 780 deletions

View File

@ -278,7 +278,9 @@ abstract class TagTheme with _$TagTheme {
}) = _TagTheme;
}
final tagThemeProvider = ScopedProvider<TagTheme>(null);
final tagThemeProvider = Provider<TagTheme>((ref) {
throw UnimplementedError();
});
class Tag extends HookConsumerWidget {
const Tag({

View File

@ -103,7 +103,9 @@ abstract class QuestionTheme with _$QuestionTheme {
}) = _QuestionTheme;
}
final questionThemeProvider = ScopedProvider<QuestionTheme>(null);
final questionThemeProvider = Provider<QuestionTheme>((ref) {
throw UnimplementedError();
});
class MyHomePage extends HookConsumerWidget {
const MyHomePage({Key? key}) : super(key: key);
@ -140,10 +142,11 @@ class MyHomePage extends HookConsumerWidget {
itemBuilder: (context, index) {
return ProviderScope(
overrides: [
currentQuestion.overrideAs((watch) {
return watch(paginatedQuestionsProvider(index ~/ 50))
.whenData((page) => page.items[index % 50]);
}),
currentQuestion.overrideWithValue(
ref
.watch(paginatedQuestionsProvider(index ~/ 50))
.whenData((page) => page.items[index % 50]),
),
],
child: const QuestionItem(),
);
@ -163,7 +166,9 @@ class MyHomePage extends HookConsumerWidget {
}
}
final currentQuestion = ScopedProvider<AsyncValue<Question>>(null);
final currentQuestion = Provider<AsyncValue<Question>>((ref) {
throw UnimplementedError();
});
class QuestionItem extends HookConsumerWidget {
const QuestionItem({Key? key}) : super(key: key);