Skip to content

Commit

Permalink
Fix deprecated WidgetsBinding.window warning
Browse files Browse the repository at this point in the history
  • Loading branch information
rrousselGit committed Jul 10, 2023
1 parent 81c7833 commit e33410c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/flutter_hooks/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Added `useSearchController` (thanks to @snapsl)
- Keys on `useCallback` are now optional, to match `useMemoized` (thanks to @jezsung)
- Update `usePlatformBrightness` to stop relying on deprecated code

## 0.18.6

Expand Down
4 changes: 2 additions & 2 deletions packages/flutter_hooks/lib/src/platform_brightness.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class _PlatformBrightnessState
@override
void initHook() {
super.initHook();
_brightness = WidgetsBinding.instance.window.platformBrightness;
_brightness = WidgetsBinding.instance.platformDispatcher.platformBrightness;
WidgetsBinding.instance.addObserver(this);
}

Expand All @@ -59,7 +59,7 @@ class _PlatformBrightnessState
void didChangePlatformBrightness() {
super.didChangePlatformBrightness();
final _previous = _brightness;
_brightness = WidgetsBinding.instance.window.platformBrightness;
_brightness = WidgetsBinding.instance.platformDispatcher.platformBrightness;
hook.onBrightnessChange?.call(_previous, _brightness);

if (hook.rebuildOnChange) {
Expand Down

0 comments on commit e33410c

Please sign in to comment.