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
cccddf8a
Unverified
Commit
cccddf8a
authored
Jan 08, 2019
by
Hans Muller
Committed by
GitHub
Jan 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tristate checkbox false to null transition, test ALL transitions (#26199)
parent
56ade3d1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
1 deletion
+51
-1
checkbox.dart
packages/flutter/lib/src/material/checkbox.dart
+1
-1
checkbox_test.dart
packages/flutter/test/material/checkbox_test.dart
+50
-0
No files found.
packages/flutter/lib/src/material/checkbox.dart
View file @
cccddf8a
...
...
@@ -342,7 +342,7 @@ class _RenderCheckbox extends RenderToggleable {
_initStrokePaint
(
paint
);
final
double
tShrink
=
(
t
-
0.5
)
*
2.0
;
if
(
_oldValue
==
null
)
if
(
_oldValue
==
null
||
value
==
null
)
_drawDash
(
canvas
,
origin
,
tShrink
,
paint
);
else
_drawCheck
(
canvas
,
origin
,
tShrink
,
paint
);
...
...
packages/flutter/test/material/checkbox_test.dart
View file @
cccddf8a
...
...
@@ -9,6 +9,7 @@ import 'package:flutter/services.dart';
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'../rendering/mock_canvas.dart'
;
import
'../widgets/semantics_tester.dart'
;
void
main
(
)
{
...
...
@@ -286,4 +287,53 @@ void main() {
SystemChannels
.
accessibility
.
setMockMessageHandler
(
null
);
semanticsTester
.
dispose
();
});
testWidgets
(
'CheckBox tristate rendering, programmatic transitions'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
(
bool
checkboxValue
)
{
return
Material
(
child:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
Checkbox
(
tristate:
true
,
value:
checkboxValue
,
onChanged:
(
bool
value
)
{
},
);
},
),
);
}
RenderToggleable
getCheckboxRenderer
()
{
return
tester
.
renderObject
<
RenderToggleable
>(
find
.
byType
(
Checkbox
));
}
await
tester
.
pumpWidget
(
buildFrame
(
false
));
await
tester
.
pumpAndSettle
();
expect
(
getCheckboxRenderer
(),
isNot
(
paints
..
path
()));
// checkmark is rendered as a path
expect
(
getCheckboxRenderer
(),
isNot
(
paints
..
line
()));
// null is rendered as a line (a "dash")
expect
(
getCheckboxRenderer
(),
paints
..
drrect
());
// empty checkbox
await
tester
.
pumpWidget
(
buildFrame
(
true
));
await
tester
.
pumpAndSettle
();
expect
(
getCheckboxRenderer
(),
paints
..
path
());
// checkmark is rendered as a path
await
tester
.
pumpWidget
(
buildFrame
(
false
));
await
tester
.
pumpAndSettle
();
expect
(
getCheckboxRenderer
(),
isNot
(
paints
..
path
()));
// checkmark is rendered as a path
expect
(
getCheckboxRenderer
(),
isNot
(
paints
..
line
()));
// null is rendered as a line (a "dash")
expect
(
getCheckboxRenderer
(),
paints
..
drrect
());
// empty checkbox
await
tester
.
pumpWidget
(
buildFrame
(
null
));
await
tester
.
pumpAndSettle
();
expect
(
getCheckboxRenderer
(),
paints
..
line
());
// null is rendered as a line (a "dash")
await
tester
.
pumpWidget
(
buildFrame
(
true
));
await
tester
.
pumpAndSettle
();
expect
(
getCheckboxRenderer
(),
paints
..
path
());
// checkmark is rendered as a path
await
tester
.
pumpWidget
(
buildFrame
(
null
));
await
tester
.
pumpAndSettle
();
expect
(
getCheckboxRenderer
(),
paints
..
line
());
// null is rendered as a line (a "dash")
});
}
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