-
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15fdb4f
commit 2199900
Showing
13 changed files
with
78 additions
and
114 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
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
44 changes: 0 additions & 44 deletions
44
packages/flutter_hooks/lib/src/material_states_controller.dart
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
packages/flutter_hooks/lib/src/widget_states_controller.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
part of 'hooks.dart'; | ||
|
||
/// Creates a [WidgetStatesController] that will be disposed automatically. | ||
/// | ||
/// See also: | ||
/// - [WidgetStatesController] | ||
WidgetStatesController useWidgetStatesController({ | ||
Set<WidgetState>? values, | ||
List<Object?>? keys, | ||
}) { | ||
return use( | ||
_WidgetStatesControllerHook( | ||
values: values, | ||
keys: keys, | ||
), | ||
); | ||
} | ||
|
||
class _WidgetStatesControllerHook extends Hook<WidgetStatesController> { | ||
const _WidgetStatesControllerHook({ | ||
required this.values, | ||
super.keys, | ||
}); | ||
|
||
final Set<WidgetState>? values; | ||
|
||
@override | ||
HookState<WidgetStatesController, Hook<WidgetStatesController>> | ||
createState() => _WidgetStateControllerHookState(); | ||
} | ||
|
||
class _WidgetStateControllerHookState | ||
extends HookState<WidgetStatesController, _WidgetStatesControllerHook> { | ||
late final controller = WidgetStatesController(hook.values); | ||
|
||
@override | ||
WidgetStatesController build(BuildContext context) => controller; | ||
|
||
@override | ||
void dispose() => controller.dispose(); | ||
|
||
@override | ||
String get debugLabel => 'useWidgetStatesController'; | ||
} |
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
Oops, something went wrong.