Skip to content

Commit 052101c

Browse files
Issue 241: Dispose suggestions popup (akvelon#244)
* _suggestionsCloseNotifier * removed public notifier * Auto-format, update Flutter version in CI (akvelon#241) * Fix analyzer issues (akvelon#241) * Fix tests (akvelon#241) --------- Co-authored-by: Alexey Inkin <leha@inkin.ru>
1 parent b4e7714 commit 052101c

File tree

7 files changed

+16
-12
lines changed

7 files changed

+16
-12
lines changed

.github/workflows/dart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ '**' ]
88

99
env:
10-
flutter_version: 3.7.1
10+
flutter_version: 3.10.2
1111

1212
jobs:
1313
build:

lib/src/code_field/code_controller.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class CodeController extends TextEditingController {
144144
Set<String> readOnlySectionNames = const {},
145145
Set<String> visibleSectionNames = const {},
146146
@Deprecated('Use CodeTheme widget to provide theme to CodeField.')
147-
Map<String, TextStyle>? theme,
147+
Map<String, TextStyle>? theme,
148148
this.analysisResult = const AnalysisResult(issues: []),
149149
this.patternMap,
150150
this.readOnly = false,

lib/src/code_field/code_field.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class CodeField extends StatefulWidget {
186186
this.onChanged,
187187
@Deprecated('Use gutterStyle instead') this.lineNumbers,
188188
@Deprecated('Use gutterStyle instead')
189-
this.lineNumberStyle = const GutterStyle(),
189+
this.lineNumberStyle = const GutterStyle(),
190190
}) : assert(
191191
gutterStyle == null || lineNumbers == null,
192192
'Can not provide gutterStyle and lineNumbers at the same time. '
@@ -264,6 +264,7 @@ class _CodeFieldState extends State<CodeField> {
264264
widget.controller.removeListener(_onTextChanged);
265265
widget.controller.removeListener(_updatePopupOffset);
266266
widget.controller.popupController.removeListener(_onPopupStateChanged);
267+
_suggestionsPopup?.remove();
267268
widget.controller.searchController.removeListener(
268269
_onSearchControllerChange,
269270
);

lib/src/gutter/gutter.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// TODO(alexeyinkin): Remove when dropping support for Flutter < 3.10, https://github.com/akvelon/flutter-code-editor/issues/245
2+
// ignore_for_file: unnecessary_non_null_assertion
3+
14
import 'package:flutter/material.dart';
25

36
import '../code_field/code_controller.dart';

test/src/code_field/code_controller_readonly_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ void main() {
121121
// cursor /
122122
selection: TextSelection.collapsed(
123123
offset: 14,
124-
affinity: TextAffinity.upstream,
125124
),
126125
),
127126
reason: 'Delete - no effect',
@@ -460,7 +459,6 @@ void main() {
460459
// cursor /
461460
selection: TextSelection.collapsed(
462461
offset: 10,
463-
affinity: TextAffinity.upstream,
464462
),
465463
),
466464
reason: 'Backspace Delete Type at last empty line - No effect',

test/src/code_field/code_controller_shortcut_test.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ class MyClass {
1818
void main() {
1919
final calls = <MethodCall>[];
2020

21-
void mockClipboardHandler() {
21+
void mockClipboardHandler(WidgetTester wt) {
2222
calls.clear();
2323

24-
SystemChannels.platform.setMockMethodCallHandler((MethodCall call) async {
25-
calls.add(call);
26-
});
24+
wt.binding.defaultBinaryMessenger.setMockMethodCallHandler(
25+
SystemChannels.platform,
26+
(MethodCall call) async {
27+
calls.add(call);
28+
return null;
29+
},
30+
);
2731
}
2832

2933
group('CodeController. Shortcuts.', () {
@@ -97,7 +101,7 @@ void main() {
97101
controller.value = const TextEditingValue(text: MethodSnippet.full);
98102
controller.foldAt(1);
99103
await wt.selectFromHome(18, offset: 16);
100-
mockClipboardHandler();
104+
mockClipboardHandler(wt);
101105

102106
await example.act();
103107

test/src/history/code_history_controller_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ void main() {
258258
controller.selection,
259259
const TextSelection.collapsed(
260260
offset: MethodSnippet.visible.length,
261-
affinity: TextAffinity.upstream,
262261
),
263262
);
264263

@@ -269,7 +268,6 @@ void main() {
269268
controller.selection,
270269
const TextSelection.collapsed(
271270
offset: MethodSnippet.visible.length,
272-
affinity: TextAffinity.upstream,
273271
),
274272
);
275273
});

0 commit comments

Comments
 (0)