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
fb9ff62c
Unverified
Commit
fb9ff62c
authored
Jan 29, 2021
by
LongCatIsLooong
Committed by
GitHub
Jan 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InputDecorator negative baseline error message (#74837)
parent
52e90f55
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
4 deletions
+56
-4
input_decorator.dart
packages/flutter/lib/src/material/input_decorator.dart
+17
-4
input_decorator_test.dart
packages/flutter/test/material/input_decorator_test.dart
+39
-0
No files found.
packages/flutter/lib/src/material/input_decorator.dart
View file @
fb9ff62c
...
...
@@ -935,9 +935,20 @@ class _RenderDecoration extends RenderBox {
// baseline from the alphabetic baseline. The ideographic baseline is for
// use post-layout and is derived from the alphabetic baseline combined with
// the font metrics.
final
double
?
baseline
=
box
.
getDistanceToBaseline
(
TextBaseline
.
alphabetic
);
assert
(
baseline
!=
null
&&
baseline
>=
0.0
);
return
baseline
!;
final
double
baseline
=
box
.
getDistanceToBaseline
(
TextBaseline
.
alphabetic
)!;
assert
(()
{
if
(
baseline
>=
0
)
return
true
;
throw
FlutterError
.
fromParts
(<
DiagnosticsNode
>[
ErrorSummary
(
"One of InputDecorator's children reported a negative baseline offset."
),
ErrorDescription
(
'
${box.runtimeType}
, of size
${box.size}
, reported a negative '
'alphabetic baseline of
$baseline
.'
,
),
]);
}());
return
baseline
;
}
// Returns a value used by performLayout to position all of the renderers.
...
...
@@ -1767,7 +1778,9 @@ class _AffixText extends StatelessWidget {
/// [InputDecorator] can be used to create widgets that look and behave like a
/// [TextField] but support other kinds of input.
///
/// Requires one of its ancestors to be a [Material] widget.
/// Requires one of its ancestors to be a [Material] widget. The [child] widget,
/// as well as the decorative widgets specified in [decoration], must have
/// non-negative baselines.
///
/// See also:
///
...
...
packages/flutter/test/material/input_decorator_test.dart
View file @
fb9ff62c
...
...
@@ -4,6 +4,7 @@
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -4420,4 +4421,42 @@ void main() {
final
double
intrinsicHeight
=
tester
.
getSize
(
find
.
byKey
(
intrinsicHeightKey
)).
height
;
expect
(
intrinsicHeight
,
equals
(
height
));
});
testWidgets
(
'error message for negative baseline'
,
(
WidgetTester
tester
)
async
{
FlutterErrorDetails
?
errorDetails
;
final
FlutterExceptionHandler
?
oldHandler
=
FlutterError
.
onError
;
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
errorDetails
??=
details
;
};
try
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Center
(
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
InputDecorator
(
decoration:
const
InputDecoration
(),
child:
Stack
(
children:
const
<
Widget
>[
SizedBox
(
height:
0
),
Positioned
(
bottom:
5
,
child:
Text
(
'ok'
),
),
],
),
),
),
),
),
null
,
EnginePhase
.
layout
,
);
}
finally
{
FlutterError
.
onError
=
oldHandler
;
}
expect
(
errorDetails
?.
toString
(),
contains
(
"InputDecorator's children reported a negative baseline"
));
expect
(
errorDetails
?.
toString
(),
contains
(
'RenderStack'
));
});
}
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