|
2 | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | 3 | // found in the LICENSE file. |
4 | 4 |
|
5 | | -// @dart = 2.8 |
6 | | - |
7 | 5 | import 'package:flutter/foundation.dart'; |
8 | 6 | import 'package:flutter/material.dart'; |
9 | 7 | import 'package:flutter/rendering.dart'; |
@@ -408,7 +406,7 @@ void main() { |
408 | 406 | test('ignore key event from web platform', () async { |
409 | 407 | final TextSelectionDelegate delegate = FakeEditableTextState(); |
410 | 408 | final ViewportOffset viewportOffset = ViewportOffset.zero(); |
411 | | - TextSelection currentSelection; |
| 409 | + late TextSelection currentSelection; |
412 | 410 | final RenderEditable editable = RenderEditable( |
413 | 411 | backgroundCursorColor: Colors.grey, |
414 | 412 | selectionColor: Colors.black, |
@@ -460,7 +458,7 @@ void main() { |
460 | 458 | test('selects correct place with offsets', () { |
461 | 459 | final TextSelectionDelegate delegate = FakeEditableTextState(); |
462 | 460 | final ViewportOffset viewportOffset = ViewportOffset.zero(); |
463 | | - TextSelection currentSelection; |
| 461 | + late TextSelection currentSelection; |
464 | 462 | final RenderEditable editable = RenderEditable( |
465 | 463 | backgroundCursorColor: Colors.grey, |
466 | 464 | selectionColor: Colors.black, |
@@ -545,7 +543,7 @@ void main() { |
545 | 543 | test('selects correct place when offsets are flipped', () { |
546 | 544 | final TextSelectionDelegate delegate = FakeEditableTextState(); |
547 | 545 | final ViewportOffset viewportOffset = ViewportOffset.zero(); |
548 | | - TextSelection currentSelection; |
| 546 | + late TextSelection currentSelection; |
549 | 547 | final RenderEditable editable = RenderEditable( |
550 | 548 | backgroundCursorColor: Colors.grey, |
551 | 549 | selectionColor: Colors.black, |
@@ -578,7 +576,7 @@ void main() { |
578 | 576 |
|
579 | 577 | test('selection does not flicker as user is dragging', () { |
580 | 578 | int selectionChangedCount = 0; |
581 | | - TextSelection updatedSelection; |
| 579 | + TextSelection? updatedSelection; |
582 | 580 | final TextSelectionDelegate delegate = FakeEditableTextState(); |
583 | 581 | const TextSpan text = TextSpan( |
584 | 582 | text: 'abc def ghi', |
@@ -630,8 +628,8 @@ void main() { |
630 | 628 | editable2.selectPositionAt(from: const Offset(30, 2), to: const Offset(48, 2), cause: SelectionChangedCause.drag); |
631 | 629 | pumpFrame(); |
632 | 630 |
|
633 | | - expect(updatedSelection.baseOffset, 3); |
634 | | - expect(updatedSelection.extentOffset, 5); |
| 631 | + expect(updatedSelection!.baseOffset, 3); |
| 632 | + expect(updatedSelection!.extentOffset, 5); |
635 | 633 | expect(selectionChangedCount, 1); |
636 | 634 | }, skip: isBrowser); // https://github.com/flutter/flutter/issues/61028 |
637 | 635 |
|
@@ -742,7 +740,7 @@ void main() { |
742 | 740 | test('arrow keys and delete handle simple text correctly', () async { |
743 | 741 | final TextSelectionDelegate delegate = FakeEditableTextState(); |
744 | 742 | final ViewportOffset viewportOffset = ViewportOffset.zero(); |
745 | | - TextSelection currentSelection; |
| 743 | + late TextSelection currentSelection; |
746 | 744 | final RenderEditable editable = RenderEditable( |
747 | 745 | backgroundCursorColor: Colors.grey, |
748 | 746 | selectionColor: Colors.black, |
@@ -791,7 +789,7 @@ void main() { |
791 | 789 | test('arrow keys and delete handle surrogate pairs correctly', () async { |
792 | 790 | final TextSelectionDelegate delegate = FakeEditableTextState(); |
793 | 791 | final ViewportOffset viewportOffset = ViewportOffset.zero(); |
794 | | - TextSelection currentSelection; |
| 792 | + late TextSelection currentSelection; |
795 | 793 | final RenderEditable editable = RenderEditable( |
796 | 794 | backgroundCursorColor: Colors.grey, |
797 | 795 | selectionColor: Colors.black, |
@@ -841,7 +839,7 @@ void main() { |
841 | 839 | test('arrow keys and delete handle grapheme clusters correctly', () async { |
842 | 840 | final TextSelectionDelegate delegate = FakeEditableTextState(); |
843 | 841 | final ViewportOffset viewportOffset = ViewportOffset.zero(); |
844 | | - TextSelection currentSelection; |
| 842 | + late TextSelection currentSelection; |
845 | 843 | final RenderEditable editable = RenderEditable( |
846 | 844 | backgroundCursorColor: Colors.grey, |
847 | 845 | selectionColor: Colors.black, |
@@ -891,7 +889,7 @@ void main() { |
891 | 889 | test('arrow keys and delete handle surrogate pairs correctly', () async { |
892 | 890 | final TextSelectionDelegate delegate = FakeEditableTextState(); |
893 | 891 | final ViewportOffset viewportOffset = ViewportOffset.zero(); |
894 | | - TextSelection currentSelection; |
| 892 | + late TextSelection currentSelection; |
895 | 893 | final RenderEditable editable = RenderEditable( |
896 | 894 | backgroundCursorColor: Colors.grey, |
897 | 895 | selectionColor: Colors.black, |
@@ -1048,11 +1046,11 @@ void main() { |
1048 | 1046 | // Give it a width that forces the editable to wrap. |
1049 | 1047 | editable.layout(const BoxConstraints.tightFor(width: 200)); |
1050 | 1048 |
|
1051 | | - final Rect composingRect = editable.getRectForComposingRange(const TextRange(start: 0, end: 20 + 2)); |
| 1049 | + final Rect composingRect = editable.getRectForComposingRange(const TextRange(start: 0, end: 20 + 2))!; |
1052 | 1050 |
|
1053 | 1051 | // Since the range covers an entire line, the Rect should also be almost |
1054 | 1052 | // as wide as the entire paragraph (give or take 1 character). |
1055 | | - expect(composingRect?.width, greaterThan(200 - 10)); |
| 1053 | + expect(composingRect.width, greaterThan(200 - 10)); |
1056 | 1054 | }, skip: isBrowser); // https://github.com/flutter/flutter/issues/66089 |
1057 | 1055 | }); |
1058 | 1056 |
|
|
0 commit comments