Skip to content

Commit

Permalink
Fix depreciation
Browse files Browse the repository at this point in the history
  • Loading branch information
rrousselGit committed Apr 8, 2024
1 parent e4c5360 commit d6146c1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/todos/lib/main.dart
Expand Up @@ -157,7 +157,7 @@ class Toolbar extends HookConsumerWidget {
style: ButtonStyle(
visualDensity: VisualDensity.compact,
foregroundColor:
MaterialStateProperty.all(textColorFor(TodoListFilter.all)),
WidgetStateProperty.all(textColorFor(TodoListFilter.all)),
),
child: const Text('All'),
),
Expand All @@ -170,7 +170,7 @@ class Toolbar extends HookConsumerWidget {
TodoListFilter.active,
style: ButtonStyle(
visualDensity: VisualDensity.compact,
foregroundColor: MaterialStateProperty.all(
foregroundColor: WidgetStateProperty.all(
textColorFor(TodoListFilter.active),
),
),
Expand All @@ -185,7 +185,7 @@ class Toolbar extends HookConsumerWidget {
TodoListFilter.completed,
style: ButtonStyle(
visualDensity: VisualDensity.compact,
foregroundColor: MaterialStateProperty.all(
foregroundColor: WidgetStateProperty.all(
textColorFor(TodoListFilter.completed),
),
),
Expand Down
10 changes: 10 additions & 0 deletions packages/riverpod/lib/src/framework/scheduler.dart
Expand Up @@ -54,8 +54,14 @@ class ProviderScheduler {
final _stateToRefresh = <ProviderElementBase>[];

Completer<void>? _pendingTaskCompleter;

/// A future that completes when the next task is done.
Future<void>? get pendingFuture => _pendingTaskCompleter?.future;

/// Schedules a provider to be refreshed.
///
/// The refresh will happen at the end of the next event-loop,
/// and only if the provider is active.
void scheduleProviderRefresh(ProviderElementBase element) {
_stateToRefresh.add(element);

Expand Down Expand Up @@ -95,6 +101,9 @@ class ProviderScheduler {
}
}

/// Schedules a provider to be disposed.
///
/// The provider will be disposed at the end of the next event-loop,
void scheduleProviderDispose(
AutoDisposeProviderElementMixin<Object?> element,
) {
Expand Down Expand Up @@ -129,6 +138,7 @@ class ProviderScheduler {
}
}

/// Disposes the scheduler.
void dispose() {
_disposed = true;
_pendingTaskCompleter?.complete();
Expand Down
Expand Up @@ -47,7 +47,7 @@ class _ExampleState extends ConsumerState<Example> {
ElevatedButton(
style: ButtonStyle(
// If there is an error, we show the button in red
backgroundColor: MaterialStateProperty.all(
backgroundColor: WidgetStateProperty.all(
isErrored ? Colors.red : null,
),
),
Expand Down
Expand Up @@ -41,7 +41,7 @@ class Example extends HookConsumerWidget {
ElevatedButton(
style: ButtonStyle(
// If there is an error, we show the button in red
backgroundColor: MaterialStateProperty.all(
backgroundColor: WidgetStateProperty.all(
isErrored ? Colors.red : null,
),
),
Expand Down

0 comments on commit d6146c1

Please sign in to comment.