-
-
Notifications
You must be signed in to change notification settings - Fork 189
useExpansibleController #473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes introduce a new Changes
Sequence Diagram(s)sequenceDiagram
participant Widget as Widget
participant Hook as useExpansibleController
participant Controller as ExpansibleController
Widget->>Hook: call useExpansibleController()
Hook->>Controller: create ExpansibleController instance
Controller-->>Hook: return instance
Hook-->>Widget: return ExpansibleController
Widget->>Controller: interact (expand/collapse)
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
packages/flutter_hooks/lib/src/misc.dart (1)
20-20:⚠️ Potential issueFix inconsistent generic parameter naming in the Reducer typedef.
The
Reducertypedef still uses the old generic parameter names (StateandAction) while the rest of the file has been updated to useStateTandActionTfor consistency.Apply this diff to maintain consistency:
-typedef Reducer<State, Action> = State Function(State state, Action action); +typedef Reducer<StateT, ActionT> = StateT Function(StateT state, ActionT action);
🧹 Nitpick comments (1)
packages/flutter_hooks/test/use_animation_controller_test.dart (1)
34-34: Good practice using unawaited(), but consider consistency.Using
unawaited(controller.forward())is good practice to explicitly mark the future as intentionally unawaited. However, note that line 105 uses// ignore: unawaited_futuresfor the same purpose, creating inconsistency in the file.Consider standardizing the approach throughout the file:
- // ignore: unawaited_futures - controller.forward(); + unawaited(controller.forward());
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
README.md(1 hunks)packages/flutter_hooks/CHANGELOG.md(1 hunks)packages/flutter_hooks/lib/src/expansion_tile_controller.dart(1 hunks)packages/flutter_hooks/lib/src/hooks.dart(1 hunks)packages/flutter_hooks/lib/src/misc.dart(5 hunks)packages/flutter_hooks/pubspec.yaml(1 hunks)packages/flutter_hooks/test/use_animation_controller_test.dart(2 hunks)packages/flutter_hooks/test/use_expansible_controller_test.dart(3 hunks)packages/flutter_hooks/test/use_ticker_provider_test.dart(2 hunks)packages/flutter_hooks/test/use_transformation_controller_test.dart(1 hunks)
🔇 Additional comments (15)
packages/flutter_hooks/lib/src/hooks.dart (1)
9-10: Appropriate lint suppression for backward compatibility.The
// ignore: deprecated_member_usecomment correctly suppresses deprecation warnings forExpansionTileControllerwhile maintaining backward compatibility during the transition touseExpansibleController.packages/flutter_hooks/CHANGELOG.md (1)
1-4: Clear deprecation documentation.The changelog entry properly documents the deprecation of
useExpansionTileControllerin favor ofuseExpansibleController, providing clear guidance for users during the migration.packages/flutter_hooks/test/use_animation_controller_test.dart (1)
1-1: Import added for unawaited function.The
dart:asyncimport is correctly added to support theunawaited()function usage.packages/flutter_hooks/test/use_ticker_provider_test.dart (2)
1-1: LGTM: Import added for async handling improvement.The addition of
dart:asyncimport is necessary for using theunawaitedfunction on line 49.
46-49: Excellent improvement in async handling clarity.The reformatting with trailing commas improves readability, and wrapping
animationController.forward()withunawaited()makes the intent explicit that we don't want to await the animation completion. This prevents linter warnings and clearly communicates the asynchronous behavior.packages/flutter_hooks/test/use_expansible_controller_test.dart (3)
12-12: Correct update to use the new hook.Properly updated to use
useExpansibleController()instead of the deprecateduseExpansionTileController().
27-27: Debug string updated consistently.The debug property string correctly reflects the new hook name and controller type.
33-66: Comprehensive test updates for the new hook.All test references have been correctly updated from the deprecated
useExpansionTileControllerto the newuseExpansibleControllerhook. The test logic remains unchanged, ensuring behavioral consistency while adopting the new API.packages/flutter_hooks/test/use_transformation_controller_test.dart (1)
23-44: Good improvement in test robustness.Using
anyOf()to accept multiple diagnostic string formats makes the test more resilient to different Flutter versions or matrix formatting styles. This prevents test brittleness while maintaining verification of the core functionality.README.md (2)
358-358: Documentation properly updated for the new hook.The README correctly reflects the renaming from
useExpansionTileControllertouseExpansibleController, with updated link and description that accurately describes creating anExpansibleController.
361-361: Minor formatting improvement.The addition of bold formatting to
**CarouselController**improves consistency with other controller descriptions in the table.packages/flutter_hooks/lib/src/misc.dart (1)
4-98: LGTM! Generic parameter renaming is consistent and well-executed.The renaming from
State/ActiontoStateT/ActionTimproves clarity and follows common naming conventions for generic type parameters. The changes are consistently applied across theStoreinterface,useReducerfunction, and all internal hook classes.packages/flutter_hooks/lib/src/expansion_tile_controller.dart (3)
3-9: LGTM! Well-documented new hook function.The new
useExpansibleControllerfunction is properly implemented with appropriate documentation and follows the established patterns for controller hook functions.
15-18: LGTM! Proper deprecation handling.The deprecation is well-implemented:
- Clear deprecation annotation with migration guidance
- Proper delegation to the new implementation to avoid code duplication
- Maintains backward compatibility during the transition period
20-37: LGTM! Hook implementation properly updated.The hook classes have been correctly renamed and updated:
_ExpansibleControllerHookreplaces the old implementation- Controller type properly changed to
ExpansibleController- Debug label updated to reflect the new naming
- State management remains consistent with the established pattern
| environment: | ||
| sdk: ">=2.17.0 <3.0.0" | ||
| flutter: ">=3.21.0-13.0.pre.4" | ||
| flutter: ">=3.32.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify the Flutter SDK version requirement.
The update from ">=3.21.0-13.0.pre.4" to ">=3.32.0" represents a significant version jump. Please ensure that Flutter 3.32.0 is a valid, released version and that this requirement aligns with the package's actual dependencies.
🌐 Web query:
What is the latest stable version of Flutter as of June 2025?
💡 Result:
As of June 2025, the latest stable version of Flutter is 3.29.0, released on February 12, 2025. (groups.google.com) This release introduced several enhancements, including:
-
Rendering Engine Update: Flutter now runs Dart code on the platform's main thread for both Android and iOS, improving platform interop through direct synchronous calls. (codewithandrea.com)
-
Cupertino and Material Widgets Refinements: The update brought refinements to Cupertino and Material widgets, along with DevTools enhancements and Impeller engine optimizations. (codewithandrea.com)
-
Deprecation of Certain Packages: In an effort to focus on the core framework, the Flutter team announced the discontinuation of support for several official packages, effective April 30, 2025. (codewithandrea.com)
To upgrade to Flutter 3.29.0, you can run the following command in your terminal:
flutter upgradeFor a comprehensive list of changes and updates in this release, refer to the official Flutter release notes. (docs.flutter.dev)
Citations:
- 1: https://groups.google.com/g/flutter-announce/c/Ojcja3Dltt4?utm_source=openai
- 2: https://codewithandrea.com/newsletter/february-2025/?utm_source=openai
- 3: https://codewithandrea.com/newsletter/february-2025/?utm_source=openai
- 4: https://codewithandrea.com/newsletter/february-2025/?utm_source=openai
- 5: https://docs.flutter.dev/release/release-notes?utm_source=openai
Invalid Flutter SDK Version Constraint
The SDK constraint in packages/flutter_hooks/pubspec.yaml requires Flutter >=3.32.0, but Flutter 3.32.0 hasn’t been released. The latest stable version as of June 2025 is 3.29.0.
Please update the constraint accordingly:
- flutter: ">=3.32.0"
+ flutter: ">=3.29.0"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| flutter: ">=3.32.0" | |
| flutter: ">=3.29.0" |
🤖 Prompt for AI Agents
In packages/flutter_hooks/pubspec.yaml at line 10, the Flutter SDK version
constraint is set to ">=3.32.0", which is invalid because Flutter 3.32.0 has not
been released yet. Update the version constraint to ">=3.29.0" to reflect the
latest stable Flutter version as of June 2025.
Summary by CodeRabbit
New Features
Deprecation
Documentation
Tests
Chores