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
67ea92cb
Unverified
Commit
67ea92cb
authored
Sep 30, 2019
by
Justin McCandless
Committed by
GitHub
Sep 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix exception when selecting in TextField (#41326)
parent
d122f099
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
6 deletions
+53
-6
text_selection.dart
packages/flutter/lib/src/cupertino/text_selection.dart
+3
-5
text_field_test.dart
packages/flutter/test/cupertino/text_field_test.dart
+49
-0
text_selection_test.dart
packages/flutter/test/cupertino/text_selection_test.dart
+1
-1
No files found.
packages/flutter/lib/src/cupertino/text_selection.dart
View file @
67ea92cb
...
...
@@ -164,15 +164,13 @@ class _ToolbarRenderBox extends RenderShiftedBox {
child
.
layout
(
heightConstraint
.
enforce
(
enforcedConstraint
),
parentUsesSize:
true
,);
final
_ToolbarParentData
childParentData
=
child
.
parentData
;
final
Offset
localTopCenter
=
globalToLocal
(
Offset
(
_arrowTipX
,
_barTopY
));
// The local x-coordinate of the center of the toolbar.
final
double
lowerBound
=
child
.
size
.
width
/
2
+
_kToolbarScreenPadding
;
final
double
upperBound
=
size
.
width
-
child
.
size
.
width
/
2
-
_kToolbarScreenPadding
;
final
double
adjustedCenterX
=
localTopCenter
.
dx
.
clamp
(
lowerBound
,
upperBound
);
final
double
adjustedCenterX
=
_arrowTipX
.
clamp
(
lowerBound
,
upperBound
);
childParentData
.
offset
=
Offset
(
adjustedCenterX
-
child
.
size
.
width
/
2
,
localTopCenter
.
dy
);
childParentData
.
arrowXOffsetFromCenter
=
localTopCenter
.
dx
-
adjustedCenterX
;
childParentData
.
offset
=
Offset
(
adjustedCenterX
-
child
.
size
.
width
/
2
,
_barTopY
);
childParentData
.
arrowXOffsetFromCenter
=
_arrowTipX
-
adjustedCenterX
;
}
// The path is described in the toolbar's coordinate system.
...
...
packages/flutter/test/cupertino/text_field_test.dart
View file @
67ea92cb
...
...
@@ -3276,6 +3276,55 @@ void main() {
tester
.
binding
.
window
.
physicalSizeTestValue
=
null
;
tester
.
binding
.
window
.
devicePixelRatioTestValue
=
null
;
});
// This is a regression test for
// https://github.com/flutter/flutter/issues/37046.
testWidgets
(
'No exceptions when showing selection menu inside of nested Navigators'
,
(
WidgetTester
tester
)
async
{
const
String
testValue
=
'123456'
;
final
TextEditingController
controller
=
TextEditingController
(
text:
testValue
,
);
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
CupertinoPageScaffold
(
child:
Center
(
child:
Column
(
children:
<
Widget
>[
Container
(
height:
100
,
color:
CupertinoColors
.
activeOrange
,
),
Expanded
(
child:
Navigator
(
onGenerateRoute:
(
_
)
=>
CupertinoPageRoute
<
void
>(
builder:
(
_
)
=>
Container
(
child:
CupertinoTextField
(
controller:
controller
,
),
)),
),
),
],
),
),
),
),
);
// No text selection toolbar.
expect
(
find
.
byType
(
CupertinoTextSelectionToolbar
),
findsNothing
);
// Double tap on the text in the input.
await
tester
.
pumpAndSettle
();
await
tester
.
tapAt
(
textOffsetToPosition
(
tester
,
testValue
.
length
~/
2
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
100
));
await
tester
.
tapAt
(
textOffsetToPosition
(
tester
,
testValue
.
length
~/
2
));
await
tester
.
pumpAndSettle
();
// Now the text selection toolbar is showing and there were no exceptions.
expect
(
find
.
byType
(
CupertinoTextSelectionToolbar
),
findsOneWidget
);
expect
(
tester
.
takeException
(),
null
);
});
});
group
(
'textAlignVertical position'
,
()
{
...
...
packages/flutter/test/cupertino/text_selection_test.dart
View file @
67ea92cb
...
...
@@ -3,8 +3,8 @@
// found in the LICENSE file.
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/widgets.dart'
;
void
main
(
)
{
group
(
'canSelectAll'
,
()
{
...
...
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