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
6536f650
Unverified
Commit
6536f650
authored
Aug 25, 2020
by
LongCatIsLooong
Committed by
GitHub
Aug 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Warns when single line text fields overflow (#63639)" (#64573)
This reverts commit
0ab5ecc8
.
parent
47596c62
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
137 additions
and
529 deletions
+137
-529
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+1
-0
shifted_box.dart
packages/flutter/lib/src/rendering/shifted_box.dart
+44
-110
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+17
-143
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+67
-76
box_test.dart
packages/flutter/test/rendering/box_test.dart
+0
-68
debug_overflow_indicator_test.dart
...flutter/test/rendering/debug_overflow_indicator_test.dart
+1
-1
basic_test.dart
packages/flutter/test/widgets/basic_test.dart
+1
-1
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+0
-124
text_golden_test.dart
packages/flutter/test/widgets/text_golden_test.dart
+3
-3
extension_test.dart
...es/flutter_driver/test/src/real_tests/extension_test.dart
+3
-3
No files found.
packages/flutter/lib/src/rendering/editable.dart
View file @
6536f650
...
@@ -1569,6 +1569,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
...
@@ -1569,6 +1569,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
final
Offset
paintOffset
=
_paintOffset
;
final
Offset
paintOffset
=
_paintOffset
;
final
List
<
ui
.
TextBox
>
boxes
=
selection
.
isCollapsed
?
final
List
<
ui
.
TextBox
>
boxes
=
selection
.
isCollapsed
?
<
ui
.
TextBox
>[]
:
_textPainter
.
getBoxesForSelection
(
selection
);
<
ui
.
TextBox
>[]
:
_textPainter
.
getBoxesForSelection
(
selection
);
if
(
boxes
.
isEmpty
)
{
if
(
boxes
.
isEmpty
)
{
...
...
packages/flutter/lib/src/rendering/shifted_box.dart
View file @
6536f650
...
@@ -14,8 +14,6 @@ import 'debug_overflow_indicator.dart';
...
@@ -14,8 +14,6 @@ import 'debug_overflow_indicator.dart';
import
'object.dart'
;
import
'object.dart'
;
import
'stack.dart'
show
RelativeRect
;
import
'stack.dart'
show
RelativeRect
;
typedef
BoxConstraintsTransform
=
BoxConstraints
Function
(
BoxConstraints
);
/// Abstract class for one-child-layout render boxes that provide control over
/// Abstract class for one-child-layout render boxes that provide control over
/// the child's position.
/// the child's position.
abstract
class
RenderShiftedBox
extends
RenderBox
with
RenderObjectWithChildMixin
<
RenderBox
>
{
abstract
class
RenderShiftedBox
extends
RenderBox
with
RenderObjectWithChildMixin
<
RenderBox
>
{
...
@@ -596,62 +594,59 @@ class RenderConstrainedOverflowBox extends RenderAligningShiftedBox {
...
@@ -596,62 +594,59 @@ class RenderConstrainedOverflowBox extends RenderAligningShiftedBox {
}
}
}
}
/// A [RenderBox] that applies an arbitary transform to its [constraints], and
/// Renders a box, imposing no constraints on its child, allowing the child to
/// sizes its child using the normalized output [BoxConstraints], treating any
/// render at its "natural" size.
/// overflow as error.
///
///
/// This [RenderBox] sizes its child using a normalized [BoxConstraints] created
/// This allows a child to render at the size it would render if it were alone
/// by applying [constraintsTransform] to this [RenderBox]'s own [constraints].
/// on an infinite canvas with no constraints. This box will then attempt to
/// This box will then attempt to adopt the same size, within the limits of its
/// adopt the same size, within the limits of its own constraints. If it ends
/// own constraints. If it ends up with a different size, it will align the
/// up with a different size, it will align the child based on [alignment].
/// child based on [alignment]. If the box cannot expand enough to accommodate
/// If the box cannot expand enough to accommodate the entire child, the
/// the entire child, the child will be clipped if [clipBehavior] is not
/// child will be clipped.
/// [Clip.none].
///
///
/// In debug mode, if the child overflows the box, a warning will be printed on
/// In debug mode, if the child overflows the box, a warning will be printed on
/// the console, and black and yellow striped areas will appear where the
/// the console, and black and yellow striped areas will appear where the
/// overflow occurs.
/// overflow occurs.
///
///
/// This [RenderBox] can be used to allow the child to enforce some of its
/// intrinsic sizing rules, partially disregard the constraints set by its
/// parent render object, and display a warning in debug mode if the parent
/// render object fails to provide enough space.
///
/// See also:
/// See also:
///
///
/// * [ConstraintsTransformBox], the widget that makes use of this
/// [RenderObject] and exposes the same functionality.
/// * [RenderConstrainedBox], which renders a box which imposes constraints
/// * [RenderConstrainedBox], which renders a box which imposes constraints
/// on its child.
/// on its child.
/// * [RenderConstrainedOverflowBox], which renders a box that imposes different
/// * [RenderConstrainedOverflowBox], which renders a box that imposes different
/// constraints on its child than it gets from its parent, possibly allowing
/// constraints on its child than it gets from its parent, possibly allowing
/// the child to overflow the parent.
/// the child to overflow the parent.
/// * [RenderUnconstrainedBox] which allows its children to render themselves
/// * [RenderSizedOverflowBox], a render object that is a specific size but
/// unconstrained, expands to fit them, and considers overflow to be an error.
/// passes its original constraints through to its child, which it allows to
class
RenderConstraintsTransformBox
extends
RenderAligningShiftedBox
with
DebugOverflowIndicatorMixin
{
/// overflow.
/// Create a render object that sizes itself to the child and modifies the
class
RenderUnconstrainedBox
extends
RenderAligningShiftedBox
with
DebugOverflowIndicatorMixin
{
/// [constraints] before passing it down to that child.
/// Create a render object that sizes itself to the child but does not
/// pass the [constraints] down to that child.
///
///
/// The [alignment]
and [clipBehavior]
must not be null.
/// The [alignment] must not be null.
Render
ConstraintsTransform
Box
({
Render
Unconstrained
Box
({
@required
AlignmentGeometry
alignment
,
@required
AlignmentGeometry
alignment
,
@required
TextDirection
textDirection
,
@required
TextDirection
textDirection
,
@required
BoxConstraintsTransform
constraintsTransform
,
Axis
constrainedAxis
,
RenderBox
child
,
RenderBox
child
,
Clip
clipBehavior
=
Clip
.
none
,
Clip
clipBehavior
=
Clip
.
none
,
})
:
assert
(
alignment
!=
null
),
})
:
assert
(
alignment
!=
null
),
assert
(
clipBehavior
!=
null
),
assert
(
clipBehavior
!=
null
),
_constrain
tsTransform
=
constraintsTransform
,
_constrain
edAxis
=
constrainedAxis
,
_clipBehavior
=
clipBehavior
,
_clipBehavior
=
clipBehavior
,
super
.
mixin
(
alignment
,
textDirection
,
child
);
super
.
mixin
(
alignment
,
textDirection
,
child
);
/// @{macro flutter.widgets.constraintsTransform}
/// The axis to retain constraints on, if any.
BoxConstraintsTransform
get
constraintsTransform
=>
_constraintsTransform
;
///
BoxConstraintsTransform
_constraintsTransform
;
/// If not set, or set to null (the default), neither axis will retain its
set
constraintsTransform
(
BoxConstraintsTransform
value
)
{
/// constraints. If set to [Axis.vertical], then vertical constraints will
if
(
_constraintsTransform
==
value
)
/// be retained, and if set to [Axis.horizontal], then horizontal constraints
/// will be retained.
Axis
get
constrainedAxis
=>
_constrainedAxis
;
Axis
_constrainedAxis
;
set
constrainedAxis
(
Axis
value
)
{
if
(
_constrainedAxis
==
value
)
return
;
return
;
_constrain
tsTransform
=
value
;
_constrain
edAxis
=
value
;
markNeedsLayout
();
markNeedsLayout
();
}
}
...
@@ -677,10 +672,21 @@ class RenderConstraintsTransformBox extends RenderAligningShiftedBox with DebugO
...
@@ -677,10 +672,21 @@ class RenderConstraintsTransformBox extends RenderAligningShiftedBox with DebugO
void
performLayout
()
{
void
performLayout
()
{
final
BoxConstraints
constraints
=
this
.
constraints
;
final
BoxConstraints
constraints
=
this
.
constraints
;
if
(
child
!=
null
)
{
if
(
child
!=
null
)
{
assert
(
constraintsTransform
!=
null
);
// Let the child lay itself out at it's "natural" size, but if
final
BoxConstraints
childConstraints
=
constraintsTransform
(
constraints
);
// constrainedAxis is non-null, keep any constraints on that axis.
assert
(
childConstraints
!=
null
);
BoxConstraints
childConstraints
;
assert
(
childConstraints
.
isNormalized
,
'
$childConstraints
is not normalized'
);
if
(
constrainedAxis
!=
null
)
{
switch
(
constrainedAxis
)
{
case
Axis
.
horizontal
:
childConstraints
=
BoxConstraints
(
maxWidth:
constraints
.
maxWidth
,
minWidth:
constraints
.
minWidth
);
break
;
case
Axis
.
vertical
:
childConstraints
=
BoxConstraints
(
maxHeight:
constraints
.
maxHeight
,
minHeight:
constraints
.
minHeight
);
break
;
}
}
else
{
childConstraints
=
const
BoxConstraints
();
}
child
.
layout
(
childConstraints
,
parentUsesSize:
true
);
child
.
layout
(
childConstraints
,
parentUsesSize:
true
);
size
=
constraints
.
constrain
(
child
.
size
);
size
=
constraints
.
constrain
(
child
.
size
);
alignChild
();
alignChild
();
...
@@ -735,78 +741,6 @@ class RenderConstraintsTransformBox extends RenderAligningShiftedBox with DebugO
...
@@ -735,78 +741,6 @@ class RenderConstraintsTransformBox extends RenderAligningShiftedBox with DebugO
}
}
}
}
/// Renders a box, imposing no constraints on its child, allowing the child to
/// render at its "natural" size.
///
/// This allows a child to render at the size it would render if it were alone
/// on an infinite canvas with no constraints. This box will then attempt to
/// adopt the same size, within the limits of its own constraints. If it ends
/// up with a different size, it will align the child based on [alignment].
/// If the box cannot expand enough to accommodate the entire child, the
/// child will be clipped.
///
/// In debug mode, if the child overflows the box, a warning will be printed on
/// the console, and black and yellow striped areas will appear where the
/// overflow occurs.
///
/// See also:
///
/// * [RenderConstrainedBox], which renders a box which imposes constraints
/// on its child.
/// * [RenderConstrainedOverflowBox], which renders a box that imposes different
/// constraints on its child than it gets from its parent, possibly allowing
/// the child to overflow the parent.
/// * [RenderSizedOverflowBox], a render object that is a specific size but
/// passes its original constraints through to its child, which it allows to
/// overflow.
class
RenderUnconstrainedBox
extends
RenderConstraintsTransformBox
{
/// Create a render object that sizes itself to the child but does not
/// pass the [constraints] down to that child.
///
/// The [alignment] and [clipBehavior] must not be null.
RenderUnconstrainedBox
({
@required
AlignmentGeometry
alignment
,
@required
TextDirection
textDirection
,
Axis
constrainedAxis
,
RenderBox
child
,
Clip
clipBehavior
=
Clip
.
none
,
})
:
assert
(
alignment
!=
null
),
assert
(
clipBehavior
!=
null
),
_constrainedAxis
=
constrainedAxis
,
super
(
alignment:
alignment
,
textDirection:
textDirection
,
child:
child
,
clipBehavior:
clipBehavior
,
constraintsTransform:
null
)
{
_constraintsTransform
=
_convertAxis
;
}
/// The axis to retain constraints on, if any.
///
/// If not set, or set to null (the default), neither axis will retain its
/// constraints. If set to [Axis.vertical], then vertical constraints will
/// be retained, and if set to [Axis.horizontal], then horizontal constraints
/// will be retained.
Axis
get
constrainedAxis
=>
_constrainedAxis
;
Axis
_constrainedAxis
;
set
constrainedAxis
(
Axis
value
)
{
if
(
_constrainedAxis
==
value
)
return
;
_constrainedAxis
=
value
;
markNeedsLayout
();
}
BoxConstraints
_convertAxis
(
BoxConstraints
constriants
)
{
if
(
constrainedAxis
==
null
)
{
return
const
BoxConstraints
();
}
switch
(
constrainedAxis
)
{
case
Axis
.
horizontal
:
return
constraints
.
copyWith
(
maxHeight:
double
.
infinity
,
minHeight:
0
);
case
Axis
.
vertical
:
return
constraints
.
copyWith
(
maxWidth:
double
.
infinity
,
minWidth:
0
);
}
assert
(
false
);
return
null
;
}
}
/// A render object that is a specific size but passes its original constraints
/// A render object that is a specific size but passes its original constraints
/// through to its child, which it allows to overflow.
/// through to its child, which it allows to overflow.
///
///
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
6536f650
...
@@ -30,7 +30,6 @@ export 'package:flutter/rendering.dart' show
...
@@ -30,7 +30,6 @@ export 'package:flutter/rendering.dart' show
AlignmentGeometryTween
,
AlignmentGeometryTween
,
Axis
,
Axis
,
BoxConstraints
,
BoxConstraints
,
BoxConstraintsTransform
,
CrossAxisAlignment
,
CrossAxisAlignment
,
CustomClipper
,
CustomClipper
,
CustomPainter
,
CustomPainter
,
...
@@ -2219,114 +2218,6 @@ class ConstrainedBox extends SingleChildRenderObjectWidget {
...
@@ -2219,114 +2218,6 @@ class ConstrainedBox extends SingleChildRenderObjectWidget {
}
}
}
}
/// A widget that applies an arbitary transform to its constraints, and sizes
/// its child using the resulting [BoxConstraints], treating any overflow
/// as error.
///
/// This container sizes its child using a [BoxConstraints] created by applying
/// [constraintsTransform] to its own constraints. This container will then
/// attempt to adopt the same size, within the limits of its own constraints. If
/// it ends up with a different size, it will align the child based on
/// [alignment]. If the container cannot expand enough to accommodate the entire
/// child, the child will be clipped if [clipBehavior] is not [Clip.none].
///
/// In debug mode, if the child overflows the container, a warning will be
/// printed on the console, and black and yellow striped areas will appear where
/// the overflow occurs.
///
/// {@tool snippet}
/// This snippet guarantees the child [Card] will be at least as tall as its
/// intrinsic height. Unlike [UnconstrainedBox], the child can be taller if the
/// the parent's minHeight is constrained. If parent container's maxHeight is
/// less than [Card]'s intrinsic height, in debug mode a warning will be given.
///
/// ```dart
/// ConstraintsTransformBox(
/// constraintsTransform: (BoxConstraints constraints) => constraints.copyWith(maxHeight: double.infinity),
/// child: const Card(child: Text('Hello World!')),
/// )
/// ```
/// {@end-tool}
///
/// See also:
///
/// * [ConstrainedBox], which renders a box which imposes constraints
/// on its child.
/// * [OverflowBox], a widget that imposes additional constraints on its child,
/// and allows the child to overflow itself.
/// * [UnconstrainedBox] which allows its children to render themselves
/// unconstrained, expands to fit them, and considers overflow to be an error.
class
ConstraintsTransformBox
extends
SingleChildRenderObjectWidget
{
/// Creates a widget that uses a function to transform the constraints it
/// passes to its child. If the child overflows the parent's constraints, a
/// warning will be given in debug mode.
///
/// The `alignment`, `clipBehavior` and `constraintsTransform` arguments must
/// not be null.
const
ConstraintsTransformBox
({
Key
key
,
Widget
child
,
this
.
textDirection
,
this
.
alignment
=
Alignment
.
center
,
this
.
constraintsTransform
,
this
.
clipBehavior
=
Clip
.
hardEdge
,
})
:
assert
(
alignment
!=
null
),
assert
(
clipBehavior
!=
null
),
assert
(
constraintsTransform
!=
null
),
super
(
key:
key
,
child:
child
);
/// The text direction to use when interpreting the [alignment] if it is an
/// [AlignmentDirectional].
///
/// Defaults to null, in which case [Directionality.of] is used to determine
/// the text direction.
final
TextDirection
textDirection
;
/// The alignment to use when laying out the child, if it has a different size
/// than this widget.
///
/// If this is an [AlignmentDirectional], then [textDirection] must not be
/// null.
///
/// See also:
///
/// * [Alignment] for non-[Directionality]-aware alignments.
/// * [AlignmentDirectional] for [Directionality]-aware alignments.
final
AlignmentGeometry
alignment
;
/// @{template flutter.widgets.constraintsTransform}
/// The function used to transform the incoming [BoxConstraints], to impose on
/// [child].
///
/// Must not be null. The function must return a non-null and normalized
/// [BoxConstraints].
/// @{endtemplate}
final
BoxConstraintsTransform
constraintsTransform
;
// TODO(liyuqian): defaults to [Clip.none] once Google references are updated.
/// {@macro flutter.widgets.Clip}
///
/// Defaults to [Clip.hardEdge].
final
Clip
clipBehavior
;
@override
void
updateRenderObject
(
BuildContext
context
,
covariant
RenderConstraintsTransformBox
renderObject
)
{
renderObject
..
textDirection
=
textDirection
??
Directionality
.
of
(
context
)
..
constraintsTransform
=
constraintsTransform
..
alignment
=
alignment
..
clipBehavior
=
clipBehavior
;
}
@override
RenderConstraintsTransformBox
createRenderObject
(
BuildContext
context
)
=>
RenderConstraintsTransformBox
(
textDirection:
textDirection
??
Directionality
.
of
(
context
),
alignment:
alignment
,
constraintsTransform:
constraintsTransform
,
clipBehavior:
clipBehavior
,
);
}
/// A widget that imposes no constraints on its child, allowing it to render
/// A widget that imposes no constraints on its child, allowing it to render
/// at its "natural" size.
/// at its "natural" size.
///
///
...
@@ -2351,20 +2242,20 @@ class ConstraintsTransformBox extends SingleChildRenderObjectWidget {
...
@@ -2351,20 +2242,20 @@ class ConstraintsTransformBox extends SingleChildRenderObjectWidget {
/// * [OverflowBox], a widget that imposes different constraints on its child
/// * [OverflowBox], a widget that imposes different constraints on its child
/// than it gets from its parent, possibly allowing the child to overflow
/// than it gets from its parent, possibly allowing the child to overflow
/// the parent.
/// the parent.
class
UnconstrainedBox
extends
S
tateless
Widget
{
class
UnconstrainedBox
extends
S
ingleChildRenderObject
Widget
{
/// Creates a widget that imposes no constraints on its child, allowing it to
/// Creates a widget that imposes no constraints on its child, allowing it to
/// render at its "natural" size. If the child overflows the parents
/// render at its "natural" size. If the child overflows the parents
/// constraints, a warning will be given in debug mode.
/// constraints, a warning will be given in debug mode.
const
UnconstrainedBox
({
const
UnconstrainedBox
({
Key
key
,
Key
key
,
this
.
child
,
Widget
child
,
this
.
textDirection
,
this
.
textDirection
,
this
.
alignment
=
Alignment
.
center
,
this
.
alignment
=
Alignment
.
center
,
this
.
constrainedAxis
,
this
.
constrainedAxis
,
this
.
clipBehavior
=
Clip
.
hardEdge
,
this
.
clipBehavior
=
Clip
.
hardEdge
,
})
:
assert
(
alignment
!=
null
),
})
:
assert
(
alignment
!=
null
),
assert
(
clipBehavior
!=
null
),
assert
(
clipBehavior
!=
null
),
super
(
key:
key
);
super
(
key:
key
,
child:
child
);
/// The text direction to use when interpreting the [alignment] if it is an
/// The text direction to use when interpreting the [alignment] if it is an
/// [AlignmentDirectional].
/// [AlignmentDirectional].
...
@@ -2395,39 +2286,22 @@ class UnconstrainedBox extends StatelessWidget {
...
@@ -2395,39 +2286,22 @@ class UnconstrainedBox extends StatelessWidget {
/// Defaults to [Clip.hardEdge].
/// Defaults to [Clip.hardEdge].
final
Clip
clipBehavior
;
final
Clip
clipBehavior
;
/// The widget below this widget in the tree.
///
/// {@macro flutter.widgets.child}
final
Widget
child
;
static
BoxConstraints
_unconstrained
(
BoxConstraints
constraints
)
=>
const
BoxConstraints
();
static
BoxConstraints
_widthConstrained
(
BoxConstraints
constraints
)
=>
constraints
.
widthConstraints
();
static
BoxConstraints
_heightConstrained
(
BoxConstraints
constraints
)
=>
constraints
.
heightConstraints
();
@override
@override
Widget
build
(
BuildContext
context
)
{
void
updateRenderObject
(
BuildContext
context
,
covariant
RenderUnconstrainedBox
renderObject
)
{
BoxConstraintsTransform
constraintsTransform
;
renderObject
..
textDirection
=
textDirection
??
Directionality
.
of
(
context
)
if
(
constrainedAxis
!=
null
)
{
..
alignment
=
alignment
switch
(
constrainedAxis
)
{
..
constrainedAxis
=
constrainedAxis
case
Axis
.
horizontal
:
..
clipBehavior
=
clipBehavior
;
constraintsTransform
=
_widthConstrained
;
break
;
case
Axis
.
vertical
:
constraintsTransform
=
_heightConstrained
;
break
;
}
}
}
constraintsTransform
??=
_unconstrained
;
return
ConstraintsTransformBox
(
@override
child:
child
,
RenderUnconstrainedBox
createRenderObject
(
BuildContext
context
)
=>
RenderUnconstrainedBox
(
textDirection:
textDirection
??
Directionality
.
of
(
context
),
textDirection:
textDirection
??
Directionality
.
of
(
context
),
alignment:
alignment
,
alignment:
alignment
,
constrainedAxis:
constrainedAxis
,
clipBehavior:
clipBehavior
,
clipBehavior:
clipBehavior
,
constraintsTransform:
constraintsTransform
,
);
);
}
@override
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
...
...
packages/flutter/lib/src/widgets/editable_text.dart
View file @
6536f650
...
@@ -2397,9 +2397,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
...
@@ -2397,9 +2397,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
:
null
;
:
null
;
}
}
static
BoxConstraints
_unmodified
(
BoxConstraints
constraints
)
=>
constraints
;
static
BoxConstraints
_removeMaxHeightConstraint
(
BoxConstraints
constraints
)
=>
constraints
.
copyWith
(
maxHeight:
double
.
infinity
);
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMediaQuery
(
context
));
assert
(
debugCheckHasMediaQuery
(
context
));
...
@@ -2407,12 +2404,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
...
@@ -2407,12 +2404,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
super
.
build
(
context
);
// See AutomaticKeepAliveClientMixin.
super
.
build
(
context
);
// See AutomaticKeepAliveClientMixin.
final
TextSelectionControls
controls
=
widget
.
selectionControls
;
final
TextSelectionControls
controls
=
widget
.
selectionControls
;
final
bool
ignoreOverflow
=
_isMultiline
||
widget
.
clipBehavior
==
Clip
.
none
;
return
MouseRegion
(
return
ConstraintsTransformBox
(
constraintsTransform:
ignoreOverflow
?
_unmodified
:
_removeMaxHeightConstraint
,
clipBehavior:
widget
.
clipBehavior
,
child:
MouseRegion
(
cursor:
widget
.
mouseCursor
??
SystemMouseCursors
.
text
,
cursor:
widget
.
mouseCursor
??
SystemMouseCursors
.
text
,
child:
Scrollable
(
child:
Scrollable
(
excludeFromSemantics:
true
,
excludeFromSemantics:
true
,
...
@@ -2481,7 +2473,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
...
@@ -2481,7 +2473,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
);
);
},
},
),
),
),
);
);
}
}
...
...
packages/flutter/test/rendering/box_test.dart
View file @
6536f650
...
@@ -380,74 +380,6 @@ void main() {
...
@@ -380,74 +380,6 @@ void main() {
expect
(
unconstrained
.
getMaxIntrinsicWidth
(
100.0
),
equals
(
200.0
));
expect
(
unconstrained
.
getMaxIntrinsicWidth
(
100.0
),
equals
(
200.0
));
});
});
group
(
'ConstraintsTransfromBox'
,
()
{
FlutterErrorDetails
firstErrorDetails
;
void
exhaustErrors
()
{
FlutterErrorDetails
next
;
do
{
next
=
renderer
.
takeFlutterErrorDetails
();
firstErrorDetails
??=
next
;
}
while
(
next
!=
null
);
}
tearDown
(()
{
firstErrorDetails
=
null
;
});
test
(
'throws if the resulting constraints are not normalized'
,
()
{
final
RenderConstrainedBox
child
=
RenderConstrainedBox
(
additionalConstraints:
const
BoxConstraints
.
tightFor
(
height:
0
));
final
RenderConstraintsTransformBox
box
=
RenderConstraintsTransformBox
(
alignment:
Alignment
.
center
,
textDirection:
TextDirection
.
ltr
,
constraintsTransform:
(
BoxConstraints
constraints
)
=>
const
BoxConstraints
(
maxHeight:
-
1
,
minHeight:
200
),
child:
child
,
);
layout
(
box
,
constraints:
const
BoxConstraints
(),
onErrors:
exhaustErrors
);
expect
(
firstErrorDetails
?.
toString
(),
contains
(
'is not normalized'
));
});
test
(
'overflow is reported when insufficient size is given'
,
()
{
final
RenderConstrainedBox
child
=
RenderConstrainedBox
(
additionalConstraints:
const
BoxConstraints
.
tightFor
(
width:
double
.
maxFinite
));
final
RenderConstraintsTransformBox
box
=
RenderConstraintsTransformBox
(
alignment:
Alignment
.
center
,
textDirection:
TextDirection
.
ltr
,
constraintsTransform:
(
BoxConstraints
constraints
)
=>
constraints
.
copyWith
(
maxWidth:
double
.
infinity
),
child:
child
,
);
// No error reported.
layout
(
box
,
constraints:
const
BoxConstraints
(),
phase:
EnginePhase
.
composite
,
onErrors:
expectOverflowedErrors
);
});
test
(
'throws when null is returned by the transform function'
,
()
{
final
RenderConstrainedBox
child
=
RenderConstrainedBox
(
additionalConstraints:
const
BoxConstraints
.
tightFor
(
width:
200
));
final
RenderConstraintsTransformBox
box
=
RenderConstraintsTransformBox
(
alignment:
Alignment
.
center
,
textDirection:
TextDirection
.
ltr
,
constraintsTransform:
(
BoxConstraints
constraints
)
=>
null
,
child:
child
,
);
layout
(
box
,
constraints:
const
BoxConstraints
(),
onErrors:
exhaustErrors
);
expect
(
firstErrorDetails
.
toString
(),
contains
(
'!= null'
));
});
test
(
"the transform function can't be set to null"
,
()
{
final
RenderConstrainedBox
child
=
RenderConstrainedBox
(
additionalConstraints:
const
BoxConstraints
.
tightFor
(
width:
200
));
final
RenderConstraintsTransformBox
box
=
RenderConstraintsTransformBox
(
alignment:
Alignment
.
center
,
textDirection:
TextDirection
.
ltr
,
constraintsTransform:
null
,
child:
child
,
);
layout
(
box
,
constraints:
const
BoxConstraints
(),
onErrors:
exhaustErrors
);
expect
(
firstErrorDetails
.
toString
(),
contains
(
'!= null'
));
});
});
test
(
'getMinIntrinsicWidth error handling'
,
()
{
test
(
'getMinIntrinsicWidth error handling'
,
()
{
final
RenderUnconstrainedBox
unconstrained
=
RenderUnconstrainedBox
(
final
RenderUnconstrainedBox
unconstrained
=
RenderUnconstrainedBox
(
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
...
...
packages/flutter/test/rendering/debug_overflow_indicator_test.dart
View file @
6536f650
...
@@ -38,7 +38,7 @@ void main() {
...
@@ -38,7 +38,7 @@ void main() {
final
dynamic
exception
=
tester
.
takeException
();
final
dynamic
exception
=
tester
.
takeException
();
expect
(
exception
,
isFlutterError
);
expect
(
exception
,
isFlutterError
);
expect
(
exception
.
diagnostics
.
first
.
level
,
DiagnosticLevel
.
summary
);
expect
(
exception
.
diagnostics
.
first
.
level
,
DiagnosticLevel
.
summary
);
expect
(
exception
.
diagnostics
.
first
.
toString
(),
startsWith
(
'A Render
ConstraintsTransform
Box overflowed by '
));
expect
(
exception
.
diagnostics
.
first
.
toString
(),
startsWith
(
'A Render
Unconstrained
Box overflowed by '
));
expect
(
find
.
byType
(
UnconstrainedBox
),
paints
..
rect
());
expect
(
find
.
byType
(
UnconstrainedBox
),
paints
..
rect
());
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
...
packages/flutter/test/widgets/basic_test.dart
View file @
6536f650
...
@@ -339,7 +339,7 @@ void main() {
...
@@ -339,7 +339,7 @@ void main() {
testWidgets
(
'UnconstrainedBox can set and update clipBehavior'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'UnconstrainedBox can set and update clipBehavior'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
UnconstrainedBox
());
await
tester
.
pumpWidget
(
const
UnconstrainedBox
());
final
Render
ConstraintsTransformBox
renderObject
=
tester
.
allRenderObjects
.
whereType
<
RenderConstraintsTransform
Box
>().
first
;
final
Render
UnconstrainedBox
renderObject
=
tester
.
allRenderObjects
.
whereType
<
RenderUnconstrained
Box
>().
first
;
expect
(
renderObject
.
clipBehavior
,
equals
(
Clip
.
hardEdge
));
expect
(
renderObject
.
clipBehavior
,
equals
(
Clip
.
hardEdge
));
await
tester
.
pumpWidget
(
const
UnconstrainedBox
(
clipBehavior:
Clip
.
antiAlias
));
await
tester
.
pumpWidget
(
const
UnconstrainedBox
(
clipBehavior:
Clip
.
antiAlias
));
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
6536f650
...
@@ -5385,130 +5385,6 @@ void main() {
...
@@ -5385,130 +5385,6 @@ void main() {
expectToAssert
(
const
TextEditingValue
(
text:
'test'
,
composing:
TextRange
(
start:
-
1
,
end:
9
)),
false
);
expectToAssert
(
const
TextEditingValue
(
text:
'test'
,
composing:
TextRange
(
start:
-
1
,
end:
9
)),
false
);
});
});
testWidgets
(
'shows overflow indicator for single line text with insufficient height'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MediaQuery
(
data:
const
MediaQueryData
(
devicePixelRatio:
1.0
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SizedBox
(
height:
10
,
child:
EditableText
(
maxLines:
1
,
backgroundCursorColor:
Colors
.
grey
,
controller:
controller
,
focusNode:
focusNode
,
style:
textStyle
,
cursorColor:
cursorColor
,
),
),
),
),
));
final
dynamic
exception
=
tester
.
takeException
();
expect
(
exception
,
isFlutterError
);
expect
(
exception
.
diagnostics
.
first
.
level
,
DiagnosticLevel
.
summary
);
expect
(
exception
.
diagnostics
.
first
.
toString
(),
startsWith
(
'A RenderConstraintsTransformBox overflowed by '
));
// Can be fixed by given enough height;
await
tester
.
pumpWidget
(
MediaQuery
(
data:
const
MediaQueryData
(
devicePixelRatio:
1.0
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SizedBox
(
height:
10
,
child:
EditableText
(
maxLines:
1
,
backgroundCursorColor:
Colors
.
grey
,
controller:
controller
,
focusNode:
focusNode
,
style:
textStyle
,
cursorColor:
cursorColor
,
),
),
),
),
));
expect
(
tester
.
takeException
(),
isNull
);
});
testWidgets
(
'No overflow indicator for multiline line text or no clipping'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MediaQuery
(
data:
const
MediaQueryData
(
devicePixelRatio:
1.0
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SizedBox
(
height:
10
,
child:
EditableText
(
maxLines:
1
,
backgroundCursorColor:
Colors
.
grey
,
controller:
controller
,
focusNode:
focusNode
,
style:
textStyle
,
cursorColor:
cursorColor
,
clipBehavior:
Clip
.
none
,
),
),
),
),
));
expect
(
tester
.
takeException
(),
isNull
);
await
tester
.
pumpWidget
(
MediaQuery
(
data:
const
MediaQueryData
(
devicePixelRatio:
1.0
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SizedBox
(
height:
50
,
child:
EditableText
(
backgroundCursorColor:
Colors
.
grey
,
controller:
controller
,
focusNode:
focusNode
,
style:
textStyle
,
cursorColor:
cursorColor
,
),
),
),
),
));
expect
(
tester
.
takeException
(),
isNull
);
});
testWidgets
(
'RenderEditable can stretch vertically'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MediaQuery
(
data:
const
MediaQueryData
(
devicePixelRatio:
1.0
),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SizedBox
(
height:
400
,
child:
EditableText
(
maxLines:
1
,
backgroundCursorColor:
Colors
.
grey
,
controller:
controller
,
focusNode:
focusNode
,
style:
textStyle
,
cursorColor:
cursorColor
,
),
),
),
),
));
final
dynamic
exception
=
tester
.
takeException
();
expect
(
exception
,
isNull
);
final
EditableTextState
state
=
tester
.
state
(
find
.
byType
(
EditableText
));
expect
(
state
.
renderEditable
.
size
.
height
,
400
);
});
// Regression test for https://github.com/flutter/flutter/issues/65374.
// Regression test for https://github.com/flutter/flutter/issues/65374.
testWidgets
(
'Length formatter will not cause crash while the TextEditingValue is composing'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Length formatter will not cause crash while the TextEditingValue is composing'
,
(
WidgetTester
tester
)
async
{
final
TextInputFormatter
formatter
=
LengthLimitingTextInputFormatter
(
5
);
final
TextInputFormatter
formatter
=
LengthLimitingTextInputFormatter
(
5
);
...
...
packages/flutter/test/widgets/text_golden_test.dart
View file @
6536f650
...
@@ -632,11 +632,11 @@ void main() {
...
@@ -632,11 +632,11 @@ void main() {
),
),
children:
<
InlineSpan
>[
children:
<
InlineSpan
>[
WidgetSpan
(
WidgetSpan
(
child:
SizedBox
(
width:
70
,
height:
5
5
,
child:
TextField
()),
child:
SizedBox
(
width:
70
,
height:
2
5
,
child:
TextField
()),
),
),
TextSpan
(
text:
', and my favorite city is: '
,
style:
TextStyle
(
fontSize:
20
)),
TextSpan
(
text:
', and my favorite city is: '
,
style:
TextStyle
(
fontSize:
20
)),
WidgetSpan
(
WidgetSpan
(
child:
SizedBox
(
width:
70
,
height:
5
5
,
child:
TextField
()),
child:
SizedBox
(
width:
70
,
height:
2
5
,
child:
TextField
()),
),
),
],
],
),
),
...
@@ -743,7 +743,7 @@ void main() {
...
@@ -743,7 +743,7 @@ void main() {
),
),
TextSpan
(
text:
'outer'
,
style:
TextStyle
(
fontSize:
20
)),
TextSpan
(
text:
'outer'
,
style:
TextStyle
(
fontSize:
20
)),
WidgetSpan
(
WidgetSpan
(
child:
SizedBox
(
width:
70
,
height:
5
5
,
child:
TextField
()),
child:
SizedBox
(
width:
70
,
height:
2
5
,
child:
TextField
()),
),
),
WidgetSpan
(
WidgetSpan
(
child:
SizedBox
(
child:
SizedBox
(
...
...
packages/flutter_driver/test/src/real_tests/extension_test.dart
View file @
6536f650
...
@@ -570,7 +570,7 @@ void main() {
...
@@ -570,7 +570,7 @@ void main() {
),
),
),
),
Container
(
Container
(
height:
40
.0
,
height:
25
.0
,
child:
EditableText
(
child:
EditableText
(
key:
const
ValueKey
<
String
>(
'text3'
),
key:
const
ValueKey
<
String
>(
'text3'
),
controller:
TextEditingController
(
text:
'Hello3'
),
controller:
TextEditingController
(
text:
'Hello3'
),
...
@@ -581,14 +581,14 @@ void main() {
...
@@ -581,14 +581,14 @@ void main() {
),
),
),
),
Container
(
Container
(
height:
40
.0
,
height:
25
.0
,
child:
TextField
(
child:
TextField
(
key:
const
ValueKey
<
String
>(
'text4'
),
key:
const
ValueKey
<
String
>(
'text4'
),
controller:
TextEditingController
(
text:
'Hello4'
),
controller:
TextEditingController
(
text:
'Hello4'
),
),
),
),
),
Container
(
Container
(
height:
40
.0
,
height:
25
.0
,
child:
TextFormField
(
child:
TextFormField
(
key:
const
ValueKey
<
String
>(
'text5'
),
key:
const
ValueKey
<
String
>(
'text5'
),
controller:
TextEditingController
(
text:
'Hello5'
),
controller:
TextEditingController
(
text:
'Hello5'
),
...
...
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