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
0ebcfe10
Unverified
Commit
0ebcfe10
authored
Sep 03, 2019
by
rami-a
Committed by
GitHub
Sep 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent exception when creating a Divider borderSide (#39572)
parent
16fcb83f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
7 deletions
+31
-7
divider.dart
packages/flutter/lib/src/material/divider.dart
+24
-7
divider_test.dart
packages/flutter/test/material/divider_test.dart
+7
-0
No files found.
packages/flutter/lib/src/material/divider.dart
View file @
0ebcfe10
...
...
@@ -91,12 +91,16 @@ class Divider extends StatelessWidget {
/// {@end-tool}
final
Color
color
;
/// Computes the [BorderSide] that represents a divider of the specified
/// color, or, if there is no specified color, of the default
/// [ThemeData.dividerColor] specified in the ambient [Theme].
/// Computes the [BorderSide] that represents a divider..
///
/// The `width` argument can be used to override the default width of the
/// divider border, which defaults to 0.0 (a hairline border).
/// If [color] is null, then [DividerThemeData.color] is used. If that is also
/// null, then [ThemeData.dividerColor] is used.
///
/// If [width] is null, then [DividerThemeData.thickness] is used. If that is
/// also null, then this defaults to 0.0 (a hairline border).
///
/// If [context] is null, the default color of [BorderSide] is used and the
/// default width of 0.0 is used.
///
/// {@tool sample}
///
...
...
@@ -117,9 +121,22 @@ class Divider extends StatelessWidget {
/// ```
/// {@end-tool}
static
BorderSide
createBorderSide
(
BuildContext
context
,
{
Color
color
,
double
width
})
{
final
Color
effectiveColor
=
color
??
(
context
!=
null
?
(
DividerTheme
.
of
(
context
).
color
??
Theme
.
of
(
context
).
dividerColor
)
:
null
);
final
double
effectiveWidth
=
width
??
(
context
!=
null
?
DividerTheme
.
of
(
context
).
thickness
:
null
)
??
0.0
;
// Prevent assertion since it is possible that context is null and no color
// is specified.
if
(
effectiveColor
==
null
)
{
return
BorderSide
(
width:
effectiveWidth
,
);
}
return
BorderSide
(
color:
color
??
DividerTheme
.
of
(
context
).
color
??
Theme
.
of
(
context
).
divider
Color
,
width:
width
??
DividerTheme
.
of
(
context
).
thickness
??
0.0
,
color:
effective
Color
,
width:
effectiveWidth
,
);
}
...
...
packages/flutter/test/material/divider_test.dart
View file @
0ebcfe10
...
...
@@ -203,4 +203,11 @@ void main() {
expect
(
lineRect
.
top
,
dividerRect
.
top
+
customIndent
);
expect
(
lineRect
.
bottom
,
dividerRect
.
bottom
-
customIndent
);
});
// Regression test for https://github.com/flutter/flutter/issues/39533
testWidgets
(
'createBorderSide does not throw exception with null context'
,
(
WidgetTester
tester
)
async
{
// Passing a null context used to throw an exception but no longer does.
expect
(()
=>
Divider
.
createBorderSide
(
null
),
isNot
(
throwsAssertionError
));
expect
(()
=>
Divider
.
createBorderSide
(
null
),
isNot
(
throwsNoSuchMethodError
));
});
}
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