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
6feedcc6
Unverified
Commit
6feedcc6
authored
May 30, 2019
by
Jonah Williams
Committed by
GitHub
May 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use toFixedAsString and DoubleProperty in diagnosticProperties (#33488)
parent
0df3ec6b
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
74 additions
and
31 deletions
+74
-31
debug.dart
packages/flutter/lib/src/foundation/debug.dart
+20
-1
diagnostics.dart
packages/flutter/lib/src/foundation/diagnostics.dart
+2
-1
bottom_sheet_theme.dart
packages/flutter/lib/src/material/bottom_sheet_theme.dart
+1
-1
dialog_theme.dart
packages/flutter/lib/src/material/dialog_theme.dart
+1
-1
floating_action_button_theme.dart
...lutter/lib/src/material/floating_action_button_theme.dart
+5
-5
snack_bar_theme.dart
packages/flutter/lib/src/material/snack_bar_theme.dart
+1
-1
flutter_logo.dart
packages/flutter/lib/src/painting/flutter_logo.dart
+1
-1
image_stream.dart
packages/flutter/lib/src/painting/image_stream.dart
+1
-1
matrix_utils.dart
packages/flutter/lib/src/painting/matrix_utils.dart
+12
-9
stack.dart
packages/flutter/lib/src/rendering/stack.dart
+6
-6
table.dart
packages/flutter/lib/src/rendering/table.dart
+4
-4
double_precision_test.dart
packages/flutter/test/foundation/double_precision_test.dart
+20
-0
No files found.
packages/flutter/lib/src/foundation/debug.dart
View file @
6feedcc6
...
...
@@ -24,7 +24,8 @@ import 'print.dart';
bool
debugAssertAllFoundationVarsUnset
(
String
reason
,
{
DebugPrintCallback
debugPrintOverride
=
debugPrintThrottled
})
{
assert
(()
{
if
(
debugPrint
!=
debugPrintOverride
||
debugDefaultTargetPlatformOverride
!=
null
)
debugDefaultTargetPlatformOverride
!=
null
||
debugDoublePrecision
!=
null
)
throw
FlutterError
(
reason
);
return
true
;
}());
...
...
@@ -73,3 +74,21 @@ Future<T> debugInstrumentAction<T>(String description, Future<T> action()) {
const
Map
<
String
,
String
>
timelineWhitelistArguments
=
<
String
,
String
>{
'mode'
:
'basic'
,
};
/// Configure [debugFormatDouble] using [num.toStringAsPrecision].
///
/// Defaults to null, which uses the default logic of [debugFormatDouble].
int
debugDoublePrecision
;
/// Formats a double to have standard formatting.
///
/// This behavior can be overriden by [debugDoublePrecision].
String
debugFormatDouble
(
double
value
)
{
if
(
value
==
null
)
{
return
'null'
;
}
if
(
debugDoublePrecision
!=
null
)
{
return
value
.
toStringAsPrecision
(
debugDoublePrecision
);
}
return
value
.
toStringAsFixed
(
1
);
}
packages/flutter/lib/src/foundation/diagnostics.dart
View file @
6feedcc6
...
...
@@ -7,6 +7,7 @@ import 'dart:math' as math;
import
'package:meta/meta.dart'
;
import
'assertions.dart'
;
import
'debug.dart'
;
// Examples can assume:
// int rows, columns;
...
...
@@ -1911,7 +1912,7 @@ class DoubleProperty extends _NumProperty<double> {
);
@override
String
numberToString
()
=>
value
?.
toStringAsFixed
(
1
);
String
numberToString
()
=>
debugFormatDouble
(
value
);
}
/// An int valued property with an optional unit the value is measured in.
...
...
packages/flutter/lib/src/material/bottom_sheet_theme.dart
View file @
6feedcc6
...
...
@@ -105,7 +105,7 @@ class BottomSheetThemeData extends Diagnosticable {
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
super
.
debugFillProperties
(
properties
);
properties
.
add
(
DiagnosticsProperty
<
Color
>(
'backgroundColor'
,
backgroundColor
,
defaultValue:
null
));
properties
.
add
(
D
iagnosticsProperty
<
double
>
(
'elevation'
,
elevation
,
defaultValue:
null
));
properties
.
add
(
D
oubleProperty
(
'elevation'
,
elevation
,
defaultValue:
null
));
properties
.
add
(
DiagnosticsProperty
<
ShapeBorder
>(
'shape'
,
shape
,
defaultValue:
null
));
}
}
packages/flutter/lib/src/material/dialog_theme.dart
View file @
6feedcc6
...
...
@@ -122,7 +122,7 @@ class DialogTheme extends Diagnosticable {
super
.
debugFillProperties
(
properties
);
properties
.
add
(
DiagnosticsProperty
<
Color
>(
'backgroundColor'
,
backgroundColor
));
properties
.
add
(
DiagnosticsProperty
<
ShapeBorder
>(
'shape'
,
shape
,
defaultValue:
null
));
properties
.
add
(
D
iagnosticsProperty
<
double
>
(
'elevation'
,
elevation
));
properties
.
add
(
D
oubleProperty
(
'elevation'
,
elevation
));
properties
.
add
(
DiagnosticsProperty
<
TextStyle
>(
'titleTextStyle'
,
titleTextStyle
,
defaultValue:
null
));
properties
.
add
(
DiagnosticsProperty
<
TextStyle
>(
'contentTextStyle'
,
contentTextStyle
,
defaultValue:
null
));
}
...
...
packages/flutter/lib/src/material/floating_action_button_theme.dart
View file @
6feedcc6
...
...
@@ -179,11 +179,11 @@ class FloatingActionButtonThemeData extends Diagnosticable {
properties
.
add
(
DiagnosticsProperty
<
Color
>(
'backgroundColor'
,
backgroundColor
,
defaultValue:
defaultData
.
backgroundColor
));
properties
.
add
(
DiagnosticsProperty
<
Color
>(
'focusColor'
,
focusColor
,
defaultValue:
defaultData
.
focusColor
));
properties
.
add
(
DiagnosticsProperty
<
Color
>(
'hoverColor'
,
hoverColor
,
defaultValue:
defaultData
.
hoverColor
));
properties
.
add
(
D
iagnosticsProperty
<
double
>
(
'elevation'
,
elevation
,
defaultValue:
defaultData
.
elevation
));
properties
.
add
(
D
iagnosticsProperty
<
double
>
(
'focusElevation'
,
focusElevation
,
defaultValue:
defaultData
.
focusElevation
));
properties
.
add
(
D
iagnosticsProperty
<
double
>
(
'hoverElevation'
,
hoverElevation
,
defaultValue:
defaultData
.
hoverElevation
));
properties
.
add
(
D
iagnosticsProperty
<
double
>
(
'disabledElevation'
,
disabledElevation
,
defaultValue:
defaultData
.
disabledElevation
));
properties
.
add
(
D
iagnosticsProperty
<
double
>
(
'highlightElevation'
,
highlightElevation
,
defaultValue:
defaultData
.
highlightElevation
));
properties
.
add
(
D
oubleProperty
(
'elevation'
,
elevation
,
defaultValue:
defaultData
.
elevation
));
properties
.
add
(
D
oubleProperty
(
'focusElevation'
,
focusElevation
,
defaultValue:
defaultData
.
focusElevation
));
properties
.
add
(
D
oubleProperty
(
'hoverElevation'
,
hoverElevation
,
defaultValue:
defaultData
.
hoverElevation
));
properties
.
add
(
D
oubleProperty
(
'disabledElevation'
,
disabledElevation
,
defaultValue:
defaultData
.
disabledElevation
));
properties
.
add
(
D
oubleProperty
(
'highlightElevation'
,
highlightElevation
,
defaultValue:
defaultData
.
highlightElevation
));
properties
.
add
(
DiagnosticsProperty
<
ShapeBorder
>(
'shape'
,
shape
,
defaultValue:
defaultData
.
shape
));
}
}
packages/flutter/lib/src/material/snack_bar_theme.dart
View file @
6feedcc6
...
...
@@ -166,7 +166,7 @@ class SnackBarThemeData extends Diagnosticable {
properties
.
add
(
DiagnosticsProperty
<
Color
>(
'backgroundColor'
,
backgroundColor
,
defaultValue:
null
));
properties
.
add
(
DiagnosticsProperty
<
Color
>(
'actionTextColor'
,
actionTextColor
,
defaultValue:
null
));
properties
.
add
(
DiagnosticsProperty
<
Color
>(
'disabledActionTextColor'
,
disabledActionTextColor
,
defaultValue:
null
));
properties
.
add
(
D
iagnosticsProperty
<
double
>
(
'elevation'
,
elevation
,
defaultValue:
null
));
properties
.
add
(
D
oubleProperty
(
'elevation'
,
elevation
,
defaultValue:
null
));
properties
.
add
(
DiagnosticsProperty
<
ShapeBorder
>(
'shape'
,
shape
,
defaultValue:
null
));
properties
.
add
(
DiagnosticsProperty
<
SnackBarBehavior
>(
'behavior'
,
behavior
,
defaultValue:
null
));
}
...
...
packages/flutter/lib/src/painting/flutter_logo.dart
View file @
6feedcc6
...
...
@@ -238,7 +238,7 @@ class FlutterLogoDecoration extends Decoration {
properties
.
add
(
DiagnosticsNode
.
message
(
'
$lightColor
/
$darkColor
on
$textColor
'
));
properties
.
add
(
EnumProperty
<
FlutterLogoStyle
>(
'style'
,
style
));
if
(
_inTransition
)
properties
.
add
(
DiagnosticsNode
.
message
(
'transition
$
_position
:
$_opacity
'
));
properties
.
add
(
DiagnosticsNode
.
message
(
'transition
$
{debugFormatDouble(_position)}
:
${debugFormatDouble(_opacity)}
'
));
}
}
...
...
packages/flutter/lib/src/painting/image_stream.dart
View file @
6feedcc6
...
...
@@ -41,7 +41,7 @@ class ImageInfo {
final
double
scale
;
@override
String
toString
()
=>
'
$image
@
${
scale
}
x'
;
String
toString
()
=>
'
$image
@
${
debugFormatDouble(scale)
}
x'
;
@override
int
get
hashCode
=>
hashValues
(
image
,
scale
);
...
...
packages/flutter/lib/src/painting/matrix_utils.dart
View file @
6feedcc6
...
...
@@ -265,9 +265,12 @@ class MatrixUtils {
List
<
String
>
debugDescribeTransform
(
Matrix4
transform
)
{
if
(
transform
==
null
)
return
const
<
String
>[
'null'
];
final
List
<
String
>
matrix
=
transform
.
toString
().
split
(
'
\n
'
).
toList
();
matrix
.
removeLast
();
return
matrix
;
return
<
String
>[
'[0]
${debugFormatDouble(transform.entry(0, 0))}
,
${debugFormatDouble(transform.entry(0, 1))}
,
${debugFormatDouble(transform.entry(0, 2))}
,
${debugFormatDouble(transform.entry(0, 3))}
'
,
'[1]
${debugFormatDouble(transform.entry(1, 0))}
,
${debugFormatDouble(transform.entry(1, 1))}
,
${debugFormatDouble(transform.entry(1, 2))}
,
${debugFormatDouble(transform.entry(1, 3))}
'
,
'[2]
${debugFormatDouble(transform.entry(2, 0))}
,
${debugFormatDouble(transform.entry(2, 1))}
,
${debugFormatDouble(transform.entry(2, 2))}
,
${debugFormatDouble(transform.entry(2, 3))}
'
,
'[3]
${debugFormatDouble(transform.entry(3, 0))}
,
${debugFormatDouble(transform.entry(3, 1))}
,
${debugFormatDouble(transform.entry(3, 2))}
,
${debugFormatDouble(transform.entry(3, 3))}
'
,
];
}
/// Property which handles [Matrix4] that represent transforms.
...
...
@@ -296,13 +299,13 @@ class TransformProperty extends DiagnosticsProperty<Matrix4> {
if
(
parentConfiguration
!=
null
&&
!
parentConfiguration
.
lineBreakProperties
)
{
// Format the value on a single line to be compatible with the parent's
// style.
final
List
<
Vector4
>
rows
=
<
Vector4
>[
value
.
getRow
(
0
)
,
value
.
getRow
(
1
)
,
value
.
getRow
(
2
)
,
value
.
getRow
(
3
)
,
final
List
<
String
>
values
=
<
String
>[
'
${debugFormatDouble(value.entry(0, 0))}
,
${debugFormatDouble(value.entry(0, 1))}
,
${debugFormatDouble(value.entry(0, 2))}
,
${debugFormatDouble(value.entry(0, 3))}
'
,
'
${debugFormatDouble(value.entry(1, 0))}
,
${debugFormatDouble(value.entry(1, 1))}
,
${debugFormatDouble(value.entry(1, 2))}
,
${debugFormatDouble(value.entry(1, 3))}
'
,
'
${debugFormatDouble(value.entry(2, 0))}
,
${debugFormatDouble(value.entry(2, 1))}
,
${debugFormatDouble(value.entry(2, 2))}
,
${debugFormatDouble(value.entry(2, 3))}
'
,
'
${debugFormatDouble(value.entry(3, 0))}
,
${debugFormatDouble(value.entry(3, 1))}
,
${debugFormatDouble(value.entry(3, 2))}
,
${debugFormatDouble(value.entry(3, 3))}
'
,
];
return
'[
${
rows.join("; "
)}
]'
;
return
'[
${
values.join('; '
)}
]'
;
}
return
debugDescribeTransform
(
value
).
join
(
'
\n
'
);
}
...
...
packages/flutter/lib/src/rendering/stack.dart
View file @
6feedcc6
...
...
@@ -215,17 +215,17 @@ class StackParentData extends ContainerBoxParentData<RenderBox> {
String
toString
()
{
final
List
<
String
>
values
=
<
String
>[];
if
(
top
!=
null
)
values
.
add
(
'top=
$
top
'
);
values
.
add
(
'top=
$
{debugFormatDouble(top)}
'
);
if
(
right
!=
null
)
values
.
add
(
'right=
$
right
'
);
values
.
add
(
'right=
$
{debugFormatDouble(right)}
'
);
if
(
bottom
!=
null
)
values
.
add
(
'bottom=
$
bottom
'
);
values
.
add
(
'bottom=
$
{debugFormatDouble(bottom)}
'
);
if
(
left
!=
null
)
values
.
add
(
'left=
$
left
'
);
values
.
add
(
'left=
$
{debugFormatDouble(left)}
'
);
if
(
width
!=
null
)
values
.
add
(
'width=
$
width
'
);
values
.
add
(
'width=
$
{debugFormatDouble(width)}
'
);
if
(
height
!=
null
)
values
.
add
(
'height=
$
height
'
);
values
.
add
(
'height=
$
{debugFormatDouble(height)}
'
);
if
(
values
.
isEmpty
)
values
.
add
(
'not positioned'
);
values
.
add
(
super
.
toString
());
...
...
packages/flutter/lib/src/rendering/table.dart
View file @
6feedcc6
...
...
@@ -141,7 +141,7 @@ class FixedColumnWidth extends TableColumnWidth {
}
@override
String
toString
()
=>
'
$runtimeType
(
$
value
)'
;
String
toString
()
=>
'
$runtimeType
(
$
{debugFormatDouble(value)}
)'
;
}
/// Sizes the column to a fraction of the table's constraints' maxWidth.
...
...
@@ -210,7 +210,7 @@ class FlexColumnWidth extends TableColumnWidth {
}
@override
String
toString
()
=>
'
$runtimeType
(
$
value
)'
;
String
toString
()
=>
'
$runtimeType
(
$
{debugFormatDouble(value)}
)'
;
}
/// Sizes the column such that it is the size that is the maximum of
...
...
@@ -1178,8 +1178,8 @@ class RenderTable extends RenderBox {
properties
.
add
(
DiagnosticsProperty
<
Map
<
int
,
TableColumnWidth
>>(
'specified column widths'
,
_columnWidths
,
level:
_columnWidths
.
isEmpty
?
DiagnosticLevel
.
hidden
:
DiagnosticLevel
.
info
));
properties
.
add
(
DiagnosticsProperty
<
TableColumnWidth
>(
'default column width'
,
defaultColumnWidth
));
properties
.
add
(
MessageProperty
(
'table size'
,
'
$columns
\
u00D7
$rows
'
));
properties
.
add
(
IterableProperty
<
double
>(
'column offsets'
,
_columnLefts
,
ifNull:
'unknown'
));
properties
.
add
(
IterableProperty
<
double
>(
'row offsets'
,
_rowTops
,
ifNull:
'unknown'
));
properties
.
add
(
IterableProperty
<
String
>(
'column offsets'
,
_columnLefts
?.
map
(
debugFormatDouble
)
,
ifNull:
'unknown'
));
properties
.
add
(
IterableProperty
<
String
>(
'row offsets'
,
_rowTops
?.
map
(
debugFormatDouble
)
,
ifNull:
'unknown'
));
}
@override
...
...
packages/flutter/test/foundation/double_precision_test.dart
0 → 100644
View file @
6feedcc6
// Copyright 2019 The Chromium 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/foundation.dart'
;
import
'../flutter_test_alternative.dart'
;
void
main
(
)
{
test
(
'debugFormatDouble formats doubles'
,
()
{
expect
(
debugFormatDouble
(
1
),
'1.0'
);
expect
(
debugFormatDouble
(
1.1
),
'1.1'
);
expect
(
debugFormatDouble
(
null
),
'null'
);
});
test
(
'debugDoublePrecision can control double precision'
,
()
{
debugDoublePrecision
=
3
;
expect
(
debugFormatDouble
(
1
),
'1.00'
);
debugDoublePrecision
=
null
;
});
}
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