Skip to content

Commit fd1fd91

Browse files
committed
Various lints
1 parent 2dbd2d5 commit fd1fd91

File tree

3 files changed

+31
-24
lines changed

3 files changed

+31
-24
lines changed

packages/flutter_hooks/lib/src/misc.dart

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
part of 'hooks.dart';
22

33
/// A store of mutable state that allows mutations by dispatching actions.
4-
abstract class Store<State, Action> {
4+
abstract class Store<StateT, ActionT> {
55
/// The current state.
66
///
77
/// This value may change after a call to [dispatch].
8-
State get state;
8+
StateT get state;
99

1010
/// Dispatches an action.
1111
///
1212
/// Actions are dispatched synchronously.
1313
/// It is impossible to try to dispatch actions during `build`.
14-
void dispatch(Action action);
14+
void dispatch(ActionT action);
1515
}
1616

1717
/// Composes an [Action] and a [State] to create a new [State].
@@ -33,10 +33,10 @@ typedef Reducer<State, Action> = State Function(State state, Action action);
3333
/// See also:
3434
/// * [Reducer]
3535
/// * [Store]
36-
Store<State, Action> useReducer<State, Action>(
37-
Reducer<State, Action> reducer, {
38-
required State initialState,
39-
required Action initialAction,
36+
Store<StateT, ActionT> useReducer<StateT, ActionT>(
37+
Reducer<StateT, ActionT> reducer, {
38+
required StateT initialState,
39+
required ActionT initialAction,
4040
}) {
4141
return use(
4242
_ReducerHook(
@@ -47,27 +47,27 @@ Store<State, Action> useReducer<State, Action>(
4747
);
4848
}
4949

50-
class _ReducerHook<State, Action> extends Hook<Store<State, Action>> {
50+
class _ReducerHook<StateT, ActionT> extends Hook<Store<StateT, ActionT>> {
5151
const _ReducerHook(
5252
this.reducer, {
5353
required this.initialState,
5454
required this.initialAction,
5555
});
5656

57-
final Reducer<State, Action> reducer;
58-
final State initialState;
59-
final Action initialAction;
57+
final Reducer<StateT, ActionT> reducer;
58+
final StateT initialState;
59+
final ActionT initialAction;
6060

6161
@override
62-
_ReducerHookState<State, Action> createState() =>
63-
_ReducerHookState<State, Action>();
62+
_ReducerHookState<StateT, ActionT> createState() =>
63+
_ReducerHookState<StateT, ActionT>();
6464
}
6565

66-
class _ReducerHookState<State, Action>
67-
extends HookState<Store<State, Action>, _ReducerHook<State, Action>>
68-
implements Store<State, Action> {
66+
class _ReducerHookState<StateT, ActionT>
67+
extends HookState<Store<StateT, ActionT>, _ReducerHook<StateT, ActionT>>
68+
implements Store<StateT, ActionT> {
6969
@override
70-
late State state = hook.reducer(hook.initialState, hook.initialAction);
70+
late StateT state = hook.reducer(hook.initialState, hook.initialAction);
7171

7272
@override
7373
void initHook() {
@@ -77,7 +77,7 @@ class _ReducerHookState<State, Action>
7777
}
7878

7979
@override
80-
void dispatch(Action action) {
80+
void dispatch(ActionT action) {
8181
final newState = hook.reducer(state, action);
8282

8383
if (state != newState) {
@@ -86,7 +86,7 @@ class _ReducerHookState<State, Action>
8686
}
8787

8888
@override
89-
Store<State, Action> build(BuildContext context) {
89+
Store<StateT, ActionT> build(BuildContext context) {
9090
return this;
9191
}
9292

packages/flutter_hooks/test/use_animation_controller_test.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:async';
2+
13
import 'package:flutter/foundation.dart';
24
import 'package:flutter/scheduler.dart';
35
import 'package:flutter/widgets.dart';
@@ -26,9 +28,10 @@ void main() {
2628

2729
controller
2830
..duration = const Duration(seconds: 1)
29-
..reverseDuration = const Duration(seconds: 1)
30-
// check has a ticker
31-
..forward();
31+
..reverseDuration = const Duration(seconds: 1);
32+
33+
// check has a ticker
34+
unawaited(controller.forward());
3235

3336
// dispose
3437
await tester.pumpWidget(const SizedBox());

packages/flutter_hooks/test/use_ticker_provider_test.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:async';
2+
13
import 'package:flutter/foundation.dart';
24
import 'package:flutter/widgets.dart';
35
import 'package:flutter_hooks/flutter_hooks.dart';
@@ -41,8 +43,10 @@ void main() {
4143
));
4244

4345
final animationController = AnimationController(
44-
vsync: provider, duration: const Duration(seconds: 1))
45-
..forward();
46+
vsync: provider,
47+
duration: const Duration(seconds: 1),
48+
);
49+
unawaited(animationController.forward());
4650

4751
expect(() => AnimationController(vsync: provider), throwsFlutterError);
4852

0 commit comments

Comments
 (0)