Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
9d688313
Unverified
Commit
9d688313
authored
Apr 18, 2023
by
Justin McCandless
Committed by
GitHub
Apr 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused context parameter (#124254)
Tidying up the spell check API.
parent
39becb77
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
6 deletions
+88
-6
spell_check_suggestions_toolbar.dart
...er/lib/src/cupertino/spell_check_suggestions_toolbar.dart
+3
-3
text_field.dart
packages/flutter/lib/src/cupertino/text_field.dart
+1
-1
spell_check_suggestions_toolbar.dart
...ter/lib/src/material/spell_check_suggestions_toolbar.dart
+0
-1
text_field.dart
packages/flutter/lib/src/material/text_field.dart
+1
-1
spell_check_suggestions_toolbar_test.dart
.../test/cupertino/spell_check_suggestions_toolbar_test.dart
+57
-0
spell_check_suggestions_toolbar_test.dart
...r/test/material/spell_check_suggestions_toolbar_test.dart
+26
-0
No files found.
packages/flutter/lib/src/cupertino/spell_check_suggestions_toolbar.dart
View file @
9d688313
...
...
@@ -45,7 +45,6 @@ class CupertinoSpellCheckSuggestionsToolbar extends StatelessWidget {
/// Builds the button items for the toolbar based on the available
/// spell check suggestions.
static
List
<
ContextMenuButtonItem
>?
buildButtonItems
(
BuildContext
context
,
EditableTextState
editableTextState
,
)
{
// Determine if composing region is misspelled.
...
...
@@ -58,8 +57,9 @@ class CupertinoSpellCheckSuggestionsToolbar extends StatelessWidget {
return
null
;
}
if
(
spanAtCursorIndex
.
suggestions
.
isEmpty
)
{
assert
(
debugCheckHasCupertinoLocalizations
(
context
));
final
CupertinoLocalizations
localizations
=
CupertinoLocalizations
.
of
(
context
);
assert
(
debugCheckHasCupertinoLocalizations
(
editableTextState
.
context
));
final
CupertinoLocalizations
localizations
=
CupertinoLocalizations
.
of
(
editableTextState
.
context
);
return
<
ContextMenuButtonItem
>[
ContextMenuButtonItem
(
onPressed:
()
{},
...
...
packages/flutter/lib/src/cupertino/text_field.dart
View file @
9d688313
...
...
@@ -802,7 +802,7 @@ class CupertinoTextField extends StatefulWidget {
EditableTextState
editableTextState
,
)
{
final
List
<
ContextMenuButtonItem
>?
buttonItems
=
CupertinoSpellCheckSuggestionsToolbar
.
buildButtonItems
(
context
,
editableTextState
);
CupertinoSpellCheckSuggestionsToolbar
.
buildButtonItems
(
editableTextState
);
if
(
buttonItems
==
null
||
buttonItems
.
isEmpty
){
return
const
SizedBox
.
shrink
();
...
...
packages/flutter/lib/src/material/spell_check_suggestions_toolbar.dart
View file @
9d688313
...
...
@@ -62,7 +62,6 @@ class SpellCheckSuggestionsToolbar extends StatelessWidget {
/// Builds the button items for the toolbar based on the available
/// spell check suggestions.
static
List
<
ContextMenuButtonItem
>?
buildButtonItems
(
BuildContext
context
,
EditableTextState
editableTextState
,
)
{
// Determine if composing region is misspelled.
...
...
packages/flutter/lib/src/material/text_field.dart
View file @
9d688313
...
...
@@ -816,7 +816,7 @@ class TextField extends StatefulWidget {
final
Offset
anchor
=
SpellCheckSuggestionsToolbar
.
getToolbarAnchor
(
editableTextState
.
contextMenuAnchors
);
final
List
<
ContextMenuButtonItem
>?
buttonItems
=
SpellCheckSuggestionsToolbar
.
buildButtonItems
(
context
,
editableTextState
);
SpellCheckSuggestionsToolbar
.
buildButtonItems
(
editableTextState
);
if
(
buttonItems
==
null
){
return
const
SizedBox
.
shrink
();
...
...
packages/flutter/test/cupertino/spell_check_suggestions_toolbar_test.dart
0 → 100644
View file @
9d688313
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
TestWidgetsFlutterBinding
.
ensureInitialized
();
testWidgets
(
'buildButtonItems builds a "No Replacements Found" button when no suggestions'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
_FakeEditableText
(),
),
);
final
_FakeEditableTextState
editableTextState
=
tester
.
state
(
find
.
byType
(
_FakeEditableText
));
final
List
<
ContextMenuButtonItem
>?
buttonItems
=
CupertinoSpellCheckSuggestionsToolbar
.
buildButtonItems
(
editableTextState
);
expect
(
buttonItems
,
isNotNull
);
expect
(
buttonItems
!.
length
,
1
);
expect
(
buttonItems
.
first
.
label
,
'No Replacements Found'
);
});
}
class
_FakeEditableText
extends
EditableText
{
_FakeEditableText
()
:
super
(
controller:
TextEditingController
(),
focusNode:
FocusNode
(),
backgroundCursorColor:
CupertinoColors
.
white
,
cursorColor:
CupertinoColors
.
white
,
style:
const
TextStyle
(),
);
@override
_FakeEditableTextState
createState
()
=>
_FakeEditableTextState
();
}
class
_FakeEditableTextState
extends
EditableTextState
{
@override
TextEditingValue
get
currentTextEditingValue
=>
TextEditingValue
.
empty
;
@override
SuggestionSpan
?
findSuggestionSpanAtCursorIndex
(
int
cursorIndex
)
{
return
const
SuggestionSpan
(
TextRange
(
start:
0
,
end:
0
,
),
<
String
>[],
);
}
}
packages/flutter/test/material/spell_check_suggestions_toolbar_test.dart
View file @
9d688313
...
...
@@ -4,6 +4,7 @@
import
'package:flutter/cupertino.dart'
show
CupertinoTextSelectionToolbar
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
// Vertical position at which to anchor the toolbar for testing.
...
...
@@ -85,4 +86,29 @@ void main() {
final
double
toolbarY
=
tester
.
getTopLeft
(
findSpellCheckSuggestionsToolbar
()).
dy
;
expect
(
toolbarY
,
equals
(
expectedToolbarY
));
});
test
(
'buildButtonItems builds only a delete button when no suggestions'
,
()
{
final
_FakeEditableTextState
editableTextState
=
_FakeEditableTextState
();
final
List
<
ContextMenuButtonItem
>?
buttonItems
=
SpellCheckSuggestionsToolbar
.
buildButtonItems
(
editableTextState
);
expect
(
buttonItems
,
hasLength
(
1
));
expect
(
buttonItems
!.
first
.
type
,
ContextMenuButtonType
.
delete
);
});
}
class
_FakeEditableTextState
extends
EditableTextState
{
@override
TextEditingValue
get
currentTextEditingValue
=>
TextEditingValue
.
empty
;
@override
SuggestionSpan
?
findSuggestionSpanAtCursorIndex
(
int
cursorIndex
)
{
return
const
SuggestionSpan
(
TextRange
(
start:
0
,
end:
0
,
),
<
String
>[],
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment