@@ -6,23 +6,21 @@ import 'package:flutter/gestures.dart';
6
6
import 'package:flutter/material.dart' ;
7
7
import 'package:flutter/rendering.dart' ;
8
8
import 'package:flutter_test/flutter_test.dart' ;
9
- import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart' ;
10
9
11
10
void main () {
12
11
final TestWidgetsFlutterBinding binding = _GestureBindingSpy ();
13
12
14
- testWidgets ('attach and detach correctly handle gesture' ,
15
- // TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787
16
- experimentalLeakTesting: LeakTesting .settings.withIgnoredAll (),
17
- (_) async {
13
+ testWidgets ('attach and detach correctly handle gesture' , (_) async {
18
14
expect (WidgetsBinding .instance, binding);
19
15
final TextSelectionDelegate delegate = FakeEditableTextState ();
16
+ final ViewportOffset offset = ViewportOffset .zero ();
17
+ addTearDown (offset.dispose);
20
18
final RenderEditable editable = RenderEditable (
21
19
backgroundCursorColor: Colors .grey,
22
20
selectionColor: Colors .black,
23
21
textDirection: TextDirection .ltr,
24
22
cursorColor: Colors .red,
25
- offset: ViewportOffset . zero () ,
23
+ offset: offset ,
26
24
textSelectionDelegate: delegate,
27
25
text: const TextSpan (
28
26
text: 'test' ,
@@ -36,13 +34,17 @@ void main() {
36
34
affinity: TextAffinity .upstream,
37
35
),
38
36
);
37
+ addTearDown (editable.dispose);
39
38
editable.layout (BoxConstraints .loose (const Size (1000.0 , 1000.0 )));
40
39
41
- final PipelineOwner owner = PipelineOwner (onNeedVisualUpdate: () { });
42
- final _PointerRouterSpy spy = GestureBinding .instance.pointerRouter as _PointerRouterSpy ;
40
+ final PipelineOwner owner = PipelineOwner (onNeedVisualUpdate: () {});
41
+ addTearDown (owner.dispose);
42
+ final _PointerRouterSpy spy =
43
+ GestureBinding .instance.pointerRouter as _PointerRouterSpy ;
43
44
editable.attach (owner);
44
45
// This should register pointer into GestureBinding.instance.pointerRouter.
45
- editable.handleEvent (const PointerDownEvent (), BoxHitTestEntry (editable, const Offset (10 ,10 )));
46
+ editable.handleEvent (const PointerDownEvent (),
47
+ BoxHitTestEntry (editable, const Offset (10 , 10 )));
46
48
GestureBinding .instance.pointerRouter.route (const PointerDownEvent ());
47
49
expect (spy.routeCount, greaterThan (0 ));
48
50
editable.detach ();
@@ -57,7 +59,7 @@ class _GestureBindingSpy extends AutomatedTestWidgetsFlutterBinding {
57
59
PointerRouter get pointerRouter => _testPointerRouter;
58
60
}
59
61
60
- class FakeEditableTextState extends Fake implements TextSelectionDelegate { }
62
+ class FakeEditableTextState extends Fake implements TextSelectionDelegate {}
61
63
62
64
class _PointerRouterSpy extends PointerRouter {
63
65
int routeCount = 0 ;
0 commit comments