Skip to content

Commit

Permalink
feat: add a parameter "wrapper" to allow adding providers to hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Biao Biao1 Cheng committed Jun 17, 2024
1 parent ea28800 commit 21b30d5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/flutter_hooks_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
Future<_HookTestingAction<T, P>> buildHook<T, P>(
T Function(P? props) hook, {
P? initialProps,
Widget Function(Widget child)? wrapper,
}) async {
late T result;

Expand All @@ -17,10 +18,12 @@ Future<_HookTestingAction<T, P>> buildHook<T, P>(
return Container();
});
}
Widget warpedBuilder([P? props]) =>
wrapper == null ? builder(props) : wrapper(builder(props));

await _build(builder(initialProps));
await _build(warpedBuilder(initialProps));

Future<void> rebuild([P? props]) => _build(builder(props));
Future<void> rebuild([P? props]) => _build(warpedBuilder(props));

Future<void> unmount() => _build(Container());

Expand Down

0 comments on commit 21b30d5

Please sign in to comment.