Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rrousselGit/flutter_hooks
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: flutter_hooks-v0.20.5
Choose a base ref
...
head repository: rrousselGit/flutter_hooks
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: flutter_hooks-v0.21.2
Choose a head ref

Commits on Mar 22, 2024

  1. Fix depreciation (#423)

    rrousselGit authored Mar 22, 2024
    Copy the full SHA
    acb911f View commit details
  2. Copy the full SHA
    8e4e8d2 View commit details

Commits on Mar 25, 2024

  1. 0.21.1-pre.0

    rrousselGit committed Mar 25, 2024
    Copy the full SHA
    d53783b View commit details

Commits on May 30, 2024

  1. Copy the full SHA
    2c7a59e View commit details

Commits on Jul 8, 2024

  1. Copy the full SHA
    3cadf75 View commit details
  2. Update useSingleTickerProvider based on SingleTickerProviderStateMixin (

    #432)
    
    Co-authored-by: Remi Rousselet <darky12s@gmail.com>
    dev-tatsuya and rrousselGit authored Jul 8, 2024
    Copy the full SHA
    b4ed644 View commit details
  3. Format

    rrousselGit committed Jul 8, 2024
    Copy the full SHA
    c9d71f9 View commit details
  4. Copy the full SHA
    cd67c96 View commit details

Commits on Jul 22, 2024

  1. Copy the full SHA
    c5c7dbc View commit details
  2. Copy the full SHA
    bdce4d2 View commit details

Commits on Jul 30, 2024

  1. Copy the full SHA
    2a8325b View commit details
  2. Copy the full SHA
    a10ec1e View commit details

Commits on Aug 1, 2024

  1. Copy the full SHA
    835aea0 View commit details
  2. Copy the full SHA
    319679b View commit details

Commits on Sep 26, 2024

  1. Copy the full SHA
    83f146a View commit details

Commits on Oct 2, 2024

  1. Copy the full SHA
    ffc0d2a View commit details
  2. Copy the full SHA
    34a47fd View commit details
  3. Copy the full SHA
    85156a5 View commit details
  4. Copy the full SHA
    cbd4e66 View commit details
  5. dart format and update import in hooks.dart

    Dalis committed Oct 2, 2024
    Copy the full SHA
    a92e2fe View commit details

Commits on Dec 10, 2024

  1. Copy the full SHA
    5fe2a1a View commit details
  2. Copy the full SHA
    9682007 View commit details
  3. test: fix texts

    offich committed Dec 10, 2024
    Copy the full SHA
    51e3c56 View commit details
  4. test: improve test

    offich committed Dec 10, 2024
    Copy the full SHA
    db9a63f View commit details

Commits on Dec 15, 2024

  1. Update README.md

    offich authored Dec 15, 2024
    Copy the full SHA
    f0faeff View commit details

Commits on Jan 13, 2025

  1. Update README.md

    rrousselGit authored Jan 13, 2025
    Copy the full SHA
    d5f024b View commit details

Commits on Feb 19, 2025

  1. Copy the full SHA
    e20f2e0 View commit details

Commits on Feb 23, 2025

  1. Discord links

    rrousselGit committed Feb 23, 2025
    Copy the full SHA
    19e4167 View commit details
  2. Copy the full SHA
    a63df87 View commit details
  3. Copy the full SHA
    49c314f View commit details
  4. Changelog

    rrousselGit committed Feb 23, 2025
    Copy the full SHA
    c096dd3 View commit details
  5. Copy the full SHA
    8f968cc View commit details
  6. Copy the full SHA
    4102c32 View commit details
  7. Merge pull request #460 from benthillerkus:use-tree-sliver-controller

    Implement useTreeSliverController
    rrousselGit authored Feb 23, 2025
    Copy the full SHA
    bad25f3 View commit details
  8. Readme

    rrousselGit committed Feb 23, 2025
    Copy the full SHA
    53f4296 View commit details
  9. Copy the full SHA
    b12f7dc View commit details
  10. Changelog

    rrousselGit committed Feb 23, 2025
    Copy the full SHA
    c3c3d24 View commit details
  11. Fuse files

    rrousselGit committed Feb 23, 2025
    Copy the full SHA
    5e73bac View commit details
  12. Copy the full SHA
    16a0b79 View commit details
  13. Merge pull request #450 from offich:feat/use-overlay-portal-controller

    Add useOverlayPortalController
    rrousselGit authored Feb 23, 2025
    Copy the full SHA
    a203adf View commit details
  14. Merge branch 'master' of https://github.com/rrousselGit/flutter_hooks

    …into pr/d-polikhranidi/446
    rrousselGit committed Feb 23, 2025
    Copy the full SHA
    b283a05 View commit details
  15. Fix

    rrousselGit committed Feb 23, 2025
    Copy the full SHA
    82c543c View commit details
  16. Format

    rrousselGit committed Feb 23, 2025
    Copy the full SHA
    2dd4eba View commit details
  17. Merge pull request #446 from d-polikhranidi/patch-1

    Add animationDuration property to useTabController hook
    rrousselGit authored Feb 23, 2025
    Copy the full SHA
    239c387 View commit details
  18. Changelog

    rrousselGit committed Feb 23, 2025
    Copy the full SHA
    6a6daf2 View commit details
  19. Copy the full SHA
    2dbd2d5 View commit details
Showing with 1,203 additions and 178 deletions.
  1. +38 −34 README.md
  2. +33 −1 packages/flutter_hooks/CHANGELOG.md
  3. +1 −1 packages/flutter_hooks/example/lib/star_wars/planet_screen.dart
  4. +25 −3 packages/flutter_hooks/lib/src/animation.dart
  5. +46 −0 packages/flutter_hooks/lib/src/carousel_controller.dart
  6. +34 −0 packages/flutter_hooks/lib/src/draggable_scrollable_controller.dart
  7. +57 −0 packages/flutter_hooks/lib/src/fixed_extent_scroll_controller.dart
  8. +0 −6 packages/flutter_hooks/lib/src/focus_node.dart
  9. +0 −6 packages/flutter_hooks/lib/src/focus_scope_node.dart
  10. +12 −5 packages/flutter_hooks/lib/src/hooks.dart
  11. +68 −0 packages/flutter_hooks/lib/src/listenable.dart
  12. +0 −44 packages/flutter_hooks/lib/src/material_states_controller.dart
  13. +29 −0 packages/flutter_hooks/lib/src/misc.dart
  14. +10 −0 packages/flutter_hooks/lib/src/page_controller.dart
  15. +10 −0 packages/flutter_hooks/lib/src/scroll_controller.dart
  16. +7 −2 packages/flutter_hooks/lib/src/tab_controller.dart
  17. +28 −0 packages/flutter_hooks/lib/src/tree_sliver_controller.dart
  18. +44 −0 packages/flutter_hooks/lib/src/widget_states_controller.dart
  19. +2 −2 packages/flutter_hooks/pubspec.yaml
  20. +7 −9 packages/flutter_hooks/resources/translations/ko_kr/README.md
  21. +4 −8 packages/flutter_hooks/resources/translations/pt_br/README.md
  22. +7 −8 packages/flutter_hooks/resources/translations/zh_cn/README.md
  23. +117 −0 packages/flutter_hooks/test/carousel_controller_test.dart
  24. +140 −0 packages/flutter_hooks/test/use_draggable_scrollable_controller_test.dart
  25. +102 −0 packages/flutter_hooks/test/use_fixed_extent_scroll_controller_test.dart
  26. +0 −14 packages/flutter_hooks/test/use_focus_node_test.dart
  27. +0 −14 packages/flutter_hooks/test/use_focus_scope_node_test.dart
  28. +21 −21 packages/flutter_hooks/test/use_material_states_controller_test.dart
  29. +165 −0 packages/flutter_hooks/test/use_on_listenable_change_test.dart
  30. +91 −0 packages/flutter_hooks/test/use_overlay_portal_controller_test.dart
  31. +9 −0 packages/flutter_hooks/test/use_page_controller_test.dart
  32. +9 −0 packages/flutter_hooks/test/use_scroll_controller_test.dart
  33. +19 −0 packages/flutter_hooks/test/use_tab_controller_test.dart
  34. +68 −0 packages/flutter_hooks/test/use_tree_sliver_controller_test.dart
72 changes: 38 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[English](https://github.com/rrousselGit/flutter_hooks/blob/master/README.md) | [Português](https://github.com/rrousselGit/flutter_hooks/blob/master/packages/flutter_hooks/resources/translations/pt_br/README.md) | [한국어](https://github.com/rrousselGit/flutter_hooks/blob/master/packages/flutter_hooks/resources/translations/ko_kr/README.md) | [简体中文](https://github.com/rrousselGit/flutter_hooks/blob/master/packages/flutter_hooks/resources/translations/zh_cn/README.md)

[![Build](https://github.com/rrousselGit/flutter_hooks/workflows/Build/badge.svg)](https://github.com/rrousselGit/flutter_hooks/actions?query=workflow%3ABuild) [![codecov](https://codecov.io/gh/rrousselGit/flutter_hooks/branch/master/graph/badge.svg)](https://codecov.io/gh/rrousselGit/flutter_hooks) [![pub package](https://img.shields.io/pub/v/flutter_hooks.svg)](https://pub.dev/packages/flutter_hooks) [![pub package](https://img.shields.io/badge/Awesome-Flutter-blue.svg?longCache=true&style=flat-square)](https://github.com/Solido/awesome-flutter)
<a href="https://discord.gg/Bbumvej"><img src="https://img.shields.io/discord/765557403865186374.svg?logo=discord&color=blue" alt="Discord"></a>
<a href="https://discord.gg/6G6ZWkk3fQ"><img src="https://img.shields.io/discord/765557403865186374.svg?logo=discord&color=blue" alt="Discord"></a>

<img src="https://raw.githubusercontent.com/rrousselGit/flutter_hooks/master/packages/flutter_hooks/flutter-hook.svg?sanitize=true" width="200">

@@ -19,17 +19,16 @@ logic of say `initState` or `dispose`. An obvious example is `AnimationControlle

```dart
class Example extends StatefulWidget {
final Duration duration;
const Example({super.key, required this.duration});
const Example({Key? key, required this.duration})
: super(key: key);
final Duration duration;
@override
_ExampleState createState() => _ExampleState();
}
class _ExampleState extends State<Example> with SingleTickerProviderStateMixin {
AnimationController? _controller;
late final AnimationController _controller;
@override
void initState() {
@@ -41,13 +40,13 @@ class _ExampleState extends State<Example> with SingleTickerProviderStateMixin {
void didUpdateWidget(Example oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.duration != oldWidget.duration) {
_controller!.duration = widget.duration;
_controller.duration = widget.duration;
}
}
@override
void dispose() {
_controller!.dispose();
_controller.dispose();
super.dispose();
}
@@ -74,8 +73,7 @@ This library proposes a third solution:

```dart
class Example extends HookWidget {
const Example({Key? key, required this.duration})
: super(key: key);
const Example({super.key, required this.duration});
final Duration duration;
@@ -310,12 +308,12 @@ They will take care of creating/updating/disposing an object.

#### dart:async related hooks:

| Name | Description |
| ---------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| [useStream](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useStream.html) | Subscribes to a `Stream` and returns its current state as an `AsyncSnapshot`. |
| [useStreamController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useStreamController.html) | Creates a `StreamController` which will automatically be disposed. |
| [useOnStreamChange](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useOnStreamChange.html) | Subscribes to a `Stream`, registers handlers, and returns the `StreamSubscription`.
| [useFuture](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useFuture.html) | Subscribes to a `Future` and returns its current state as an `AsyncSnapshot`. |
| Name | Description |
| ---------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| [useStream](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useStream.html) | Subscribes to a `Stream` and returns its current state as an `AsyncSnapshot`. |
| [useStreamController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useStreamController.html) | Creates a `StreamController` which will automatically be disposed. |
| [useOnStreamChange](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useOnStreamChange.html) | Subscribes to a `Stream`, registers handlers, and returns the `StreamSubscription`. |
| [useFuture](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useFuture.html) | Subscribes to a `Future` and returns its current state as an `AsyncSnapshot`. |

#### Animation related hooks:

@@ -333,30 +331,36 @@ They will take care of creating/updating/disposing an object.
| [useListenableSelector](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useListenableSelector.html) | Similar to `useListenable`, but allows filtering UI rebuilds |
| [useValueNotifier](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useValueNotifier.html) | Creates a `ValueNotifier` which will be automatically disposed. |
| [useValueListenable](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useValueListenable.html) | Subscribes to a `ValueListenable` and return its value. |
| [useOnListenableChange](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useOnListenableChange.html) | Adds a given listener callback to a `Listenable` which will be automatically removed. |

#### Misc hooks:

A series of hooks with no particular theme.

| Name | Description |
| ------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
| [useReducer](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useReducer.html) | An alternative to `useState` for more complex states. |
| [usePrevious](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/usePrevious.html) | Returns the previous argument called to [usePrevious]. |
| [useTextEditingController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useTextEditingController-constant.html) | Creates a `TextEditingController`. |
| [useFocusNode](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useFocusNode.html) | Creates a `FocusNode`. |
| [useTabController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useTabController.html) | Creates and disposes a `TabController`. |
| [useScrollController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useScrollController.html) | Creates and disposes a `ScrollController`. |
| [usePageController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/usePageController.html) | Creates and disposes a `PageController`. |
| [useAppLifecycleState](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useAppLifecycleState.html) | Returns the current `AppLifecycleState` and rebuilds the widget on change. |
| [useOnAppLifecycleStateChange](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useOnAppLifecycleStateChange.html) | Listens to `AppLifecycleState` changes and triggers a callback on change. |
| [useTransformationController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useTransformationController.html) | Creates and disposes a `TransformationController`. |
| [useIsMounted](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useIsMounted.html) | An equivalent to `State.mounted` for hooks. |
| [useAutomaticKeepAlive](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useAutomaticKeepAlive.html) | An equivalent to the `AutomaticKeepAlive` widget for hooks. |
| [useOnPlatformBrightnessChange](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useOnPlatformBrightnessChange.html) | Listens to platform `Brightness` changes and triggers a callback on change.|
| [useSearchController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useSearchController.html) | Creates and disposes a `SearchController`. |
| [useMaterialStatesController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useMaterialStatesController.html) | Creates and disposes a `MaterialStatesController`. |
| [useExpansionTileController](https://api.flutter.dev/flutter/material/ExpansionTileController-class.html) | Creates a `ExpansionTileController`. |
| [useDebounced](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useDebounced.html) | Returns a debounced version of the provided value, triggering widget updates accordingly after a specified timeout duration |
| Name | Description |
| -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [useReducer](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useReducer.html) | An alternative to `useState` for more complex states. |
| [usePrevious](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/usePrevious.html) | Returns the previous argument called to [usePrevious]. |
| [useTextEditingController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useTextEditingController-constant.html) | Creates a `TextEditingController`. |
| [useFocusNode](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useFocusNode.html) | Creates a `FocusNode`. |
| [useTabController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useTabController.html) | Creates and disposes a `TabController`. |
| [useScrollController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useScrollController.html) | Creates and disposes a `ScrollController`. |
| [usePageController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/usePageController.html) | Creates and disposes a `PageController`. |
| [useFixedExtentScrollController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useFixedExtentScrollController.html) | Creates and disposes a `FixedExtentScrollController`. |
| [useAppLifecycleState](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useAppLifecycleState.html) | Returns the current `AppLifecycleState` and rebuilds the widget on change. |
| [useOnAppLifecycleStateChange](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useOnAppLifecycleStateChange.html) | Listens to `AppLifecycleState` changes and triggers a callback on change. |
| [useTransformationController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useTransformationController.html) | Creates and disposes a `TransformationController`. |
| [useIsMounted](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useIsMounted.html) | An equivalent to `State.mounted` for hooks. |
| [useAutomaticKeepAlive](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useAutomaticKeepAlive.html) | An equivalent to the `AutomaticKeepAlive` widget for hooks. |
| [useOnPlatformBrightnessChange](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useOnPlatformBrightnessChange.html) | Listens to platform `Brightness` changes and triggers a callback on change. |
| [useSearchController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useSearchController.html) | Creates and disposes a `SearchController`. |
| [useWidgetStatesController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useWidgetStatesController.html) | Creates and disposes a `WidgetStatesController`. |
| [useExpansionTileController](https://api.flutter.dev/flutter/material/ExpansionTileController-class.html) | Creates a `ExpansionTileController`. |
| [useDebounced](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useDebounced.html) | Returns a debounced version of the provided value, triggering widget updates accordingly after a specified timeout duration |
| [useDraggableScrollableController](https://api.flutter.dev/flutter/widgets/DraggableScrollableController-class.html) | Creates a `DraggableScrollableController`. |
| [useCarouselController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useCarouselController.html) | Creates and disposes a **`CarouselController`**. |
| [useTreeSliverController](https://pub.dev/documentation/flutter_hooks/latest/flutter_hooks/useTreeSliverController.html) | Creates a `TreeSliverController`. |
| [useOverlayPortalController](https://api.flutter.dev/flutter/widgets/OverlayPortalController-class.html) | Creates and manages an `OverlayPortalController` for controlling the visibility of overlay content. The controller will be automatically disposed when no longer needed. |

## Contributions

34 changes: 33 additions & 1 deletion packages/flutter_hooks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
## 0.21.2 - 2025-02-23

- Add `useCarouselController` (thanks to @riscait)
- Add `useTreeSliverController` (thanks to @benthillerkus)
- Added `useOverlayPortalController` (thanks to @offich)
- Add animationDuration property to useTabController hook (thanks to @d-polikhranidi)

## 0.21.1-pre.4 - 2024-08-01

- Added `useFixedExtentScrollController` (thanks to @whynotmake-it)

## 0.21.1-pre.3 - 2024-07-30

- Added `useOnListenableChange` (thanks to @whynotmake-it)

## 0.21.1-pre.2 - 2024-07-22

- Added `onAttach` and `onDetach` to `useScrollController` and `usePageController` (thanks to @whynotmake-it)

## 0.21.1-pre.1 - 2024-07-08

- Added `useDraggableScrollableController` (thanks to @dickermoshe)
- Fix TickerMode not getting muted by hooks (thanks to @dev-tatsuya)

## 0.21.1-pre.0

- Bump minimum Flutter SDK to 3.21.0-13.0.pre.4

## 0.21.0 - 2024-03-22 (retracted)

- Renamed `useMaterialStatesController` to `useWidgetStatesController` to follow the rename in Flutter.

## 0.20.5 - 2024-02-05

- Deprecate the `useIsMounted` hook as you should use `BuildContext.mounted` instead if you're on Flutter 3.7.0 or greater
@@ -10,7 +42,7 @@
## 0.20.3 - 2023-10-10

- Added `useExpansionTileController` (thanks to @droidbg)
- Added `useMaterialStateController` (thanks to @AdamHavlicek)
- Added `useMaterialStatesController` (thanks to @AdamHavlicek)

## 0.20.2 - 2023-10-02

Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ class _Error extends StatelessWidget {
if (errorMsg != null) Text(errorMsg!),
ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.redAccent),
backgroundColor: WidgetStateProperty.all(Colors.redAccent),
),
onPressed: () async {
await Provider.of<_PlanetHandler>(
Loading