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
f3b1e31c
Unverified
Commit
f3b1e31c
authored
Aug 06, 2020
by
Hans Muller
Committed by
GitHub
Aug 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old button references from the Stepper widget (#63012)
parent
bd3a4cc5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
140 additions
and
20 deletions
+140
-20
stepper.dart
packages/flutter/lib/src/material/stepper.dart
+32
-13
stepper_test.dart
packages/flutter/test/material/stepper_test.dart
+108
-7
No files found.
packages/flutter/lib/src/material/stepper.dart
View file @
f3b1e31c
...
...
@@ -6,14 +6,16 @@
import
'package:flutter/widgets.dart'
;
import
'button_theme.dart'
;
import
'button_style.dart'
;
import
'color_scheme.dart'
;
import
'colors.dart'
;
import
'debug.dart'
;
import
'flat_button.dart'
;
import
'icons.dart'
;
import
'ink_well.dart'
;
import
'material.dart'
;
import
'material_localizations.dart'
;
import
'material_state.dart'
;
import
'text_button.dart'
;
import
'text_theme.dart'
;
import
'theme.dart'
;
...
...
@@ -191,7 +193,7 @@ class Stepper extends StatefulWidget {
///
/// If null, the default controls from the current theme will be used.
///
/// This callback which takes in a context and two functions
,
[onStepContinue]
/// This callback which takes in a context and two functions
:
[onStepContinue]
/// and [onStepCancel]. These can be used to control the stepper.
///
/// {@tool dartpad --template=stateless_widget_scaffold}
...
...
@@ -201,14 +203,14 @@ class Stepper extends StatefulWidget {
/// Widget build(BuildContext context) {
/// return Stepper(
/// controlsBuilder:
/// (BuildContext context, {
VoidCallback onStepContinue, VoidCallback onStepCancel
}) {
/// (BuildContext context, {
VoidCallback onStepContinue, VoidCallback onStepCancel
}) {
/// return Row(
/// children: <Widget>[
///
Fla
tButton(
///
Tex
tButton(
/// onPressed: onStepContinue,
/// child: const Text('NEXT'),
/// ),
///
Fla
tButton(
///
Tex
tButton(
/// onPressed: onStepCancel,
/// child: const Text('CANCEL'),
/// ),
...
...
@@ -407,27 +409,44 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
assert
(
cancelColor
!=
null
);
final
ThemeData
themeData
=
Theme
.
of
(
context
);
final
ColorScheme
colorScheme
=
themeData
.
colorScheme
;
final
MaterialLocalizations
localizations
=
MaterialLocalizations
.
of
(
context
);
const
OutlinedBorder
buttonShape
=
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
2
)));
const
EdgeInsets
buttonPadding
=
EdgeInsets
.
symmetric
(
horizontal:
16.0
);
return
Container
(
margin:
const
EdgeInsets
.
only
(
top:
16.0
),
child:
ConstrainedBox
(
constraints:
const
BoxConstraints
.
tightFor
(
height:
48.0
),
child:
Row
(
// The Material spec no longer includes a Stepper widget. The continue
// and cancel button styles have been configured to match the original
// version of this widget.
children:
<
Widget
>[
Fla
tButton
(
Tex
tButton
(
onPressed:
widget
.
onStepContinue
,
color:
_isDark
()
?
themeData
.
backgroundColor
:
themeData
.
primaryColor
,
textColor:
Colors
.
white
,
textTheme:
ButtonTextTheme
.
normal
,
style:
ButtonStyle
(
foregroundColor:
MaterialStateProperty
.
resolveWith
<
Color
>((
Set
<
MaterialState
>
states
)
{
return
states
.
contains
(
MaterialState
.
disabled
)
?
null
:
(
_isDark
()
?
colorScheme
.
onSurface
:
colorScheme
.
onPrimary
);
}),
backgroundColor:
MaterialStateProperty
.
resolveWith
<
Color
>((
Set
<
MaterialState
>
states
)
{
return
_isDark
()
||
states
.
contains
(
MaterialState
.
disabled
)
?
null
:
colorScheme
.
primary
;
}),
padding:
MaterialStateProperty
.
all
<
EdgeInsetsGeometry
>(
buttonPadding
),
shape:
MaterialStateProperty
.
all
<
OutlinedBorder
>(
buttonShape
),
),
child:
Text
(
localizations
.
continueButtonLabel
),
),
Container
(
margin:
const
EdgeInsetsDirectional
.
only
(
start:
8.0
),
child:
Fla
tButton
(
child:
Tex
tButton
(
onPressed:
widget
.
onStepCancel
,
textColor:
cancelColor
,
textTheme:
ButtonTextTheme
.
normal
,
style:
TextButton
.
styleFrom
(
primary:
cancelColor
,
padding:
buttonPadding
,
shape:
buttonShape
,
),
child:
Text
(
localizations
.
cancelButtonLabel
),
),
),
...
...
packages/flutter/test/material/stepper_test.dart
View file @
f3b1e31c
...
...
@@ -390,19 +390,14 @@ void main() {
constraints:
const
BoxConstraints
.
tightFor
(
height:
48.0
),
child:
Row
(
children:
<
Widget
>[
Fla
tButton
(
Tex
tButton
(
onPressed:
onStepContinue
,
color:
Colors
.
blue
,
textColor:
Colors
.
white
,
textTheme:
ButtonTextTheme
.
normal
,
child:
const
Text
(
'Let us continue!'
),
),
Container
(
margin:
const
EdgeInsetsDirectional
.
only
(
start:
8.0
),
child:
Fla
tButton
(
child:
Tex
tButton
(
onPressed:
onStepCancel
,
textColor:
Colors
.
red
,
textTheme:
ButtonTextTheme
.
normal
,
child:
const
Text
(
'Cancel This!'
),
),
),
...
...
@@ -716,4 +711,110 @@ void main() {
expect
(
tester
.
takeException
(),
isNull
);
});
testWidgets
(
'Stepper enabled button styles'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
(
ThemeData
theme
)
{
return
MaterialApp
(
theme:
theme
,
home:
Material
(
child:
Stepper
(
type:
StepperType
.
horizontal
,
onStepCancel:
()
{
},
onStepContinue:
()
{
},
steps:
const
<
Step
>[
Step
(
title:
Text
(
'step1'
),
content:
SizedBox
(
width:
100
,
height:
100
),
),
],
),
),
);
}
Material
buttonMaterial
(
String
label
)
{
return
tester
.
widget
<
Material
>(
find
.
descendant
(
of:
find
.
widgetWithText
(
TextButton
,
label
),
matching:
find
.
byType
(
Material
))
);
}
// The checks that follow verify that the layout and appearance of
// the default enabled Stepper buttons have not changed even
// though the FlatButtons have been replaced by TextButtons.
const
OutlinedBorder
buttonShape
=
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
2
)));
const
Rect
continueButtonRect
=
Rect
.
fromLTRB
(
24.0
,
212.0
,
168.0
,
260.0
);
const
Rect
cancelButtonRect
=
Rect
.
fromLTRB
(
176.0
,
212.0
,
292.0
,
260.0
);
await
tester
.
pumpWidget
(
buildFrame
(
ThemeData
.
light
()));
expect
(
buttonMaterial
(
'CONTINUE'
).
color
.
value
,
0xff2196f3
);
expect
(
buttonMaterial
(
'CONTINUE'
).
textStyle
.
color
.
value
,
0xffffffff
);
expect
(
buttonMaterial
(
'CONTINUE'
).
shape
,
buttonShape
);
expect
(
tester
.
getRect
(
find
.
widgetWithText
(
TextButton
,
'CONTINUE'
)),
continueButtonRect
);
expect
(
buttonMaterial
(
'CANCEL'
).
color
.
value
,
0
);
expect
(
buttonMaterial
(
'CANCEL'
).
textStyle
.
color
.
value
,
0x8a000000
);
expect
(
buttonMaterial
(
'CANCEL'
).
shape
,
buttonShape
);
expect
(
tester
.
getRect
(
find
.
widgetWithText
(
TextButton
,
'CANCEL'
)),
cancelButtonRect
);
await
tester
.
pumpWidget
(
buildFrame
(
ThemeData
.
dark
()));
await
tester
.
pumpAndSettle
();
// Complete the theme animation.
expect
(
buttonMaterial
(
'CONTINUE'
).
color
.
value
,
0
);
expect
(
buttonMaterial
(
'CONTINUE'
).
textStyle
.
color
.
value
,
0xffffffff
);
expect
(
buttonMaterial
(
'CONTINUE'
).
shape
,
buttonShape
);
expect
(
tester
.
getRect
(
find
.
widgetWithText
(
TextButton
,
'CONTINUE'
)),
continueButtonRect
);
expect
(
buttonMaterial
(
'CANCEL'
).
color
.
value
,
0
);
expect
(
buttonMaterial
(
'CANCEL'
).
textStyle
.
color
.
value
,
0xb3ffffff
);
expect
(
buttonMaterial
(
'CANCEL'
).
shape
,
buttonShape
);
expect
(
tester
.
getRect
(
find
.
widgetWithText
(
TextButton
,
'CANCEL'
)),
cancelButtonRect
);
});
testWidgets
(
'Stepper disabled button styles'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
(
ThemeData
theme
)
{
return
MaterialApp
(
theme:
theme
,
home:
Material
(
child:
Stepper
(
type:
StepperType
.
horizontal
,
steps:
const
<
Step
>[
Step
(
title:
Text
(
'step1'
),
content:
SizedBox
(
width:
100
,
height:
100
),
),
],
),
),
);
}
Material
buttonMaterial
(
String
label
)
{
return
tester
.
widget
<
Material
>(
find
.
descendant
(
of:
find
.
widgetWithText
(
TextButton
,
label
),
matching:
find
.
byType
(
Material
))
);
}
// The checks that follow verify that the appearance of the
// default disabled Stepper buttons have not changed even though
// the FlatButtons have been replaced by TextButtons.
await
tester
.
pumpWidget
(
buildFrame
(
ThemeData
.
light
()));
expect
(
buttonMaterial
(
'CONTINUE'
).
color
.
value
,
0
);
expect
(
buttonMaterial
(
'CONTINUE'
).
textStyle
.
color
.
value
,
0x61000000
);
expect
(
buttonMaterial
(
'CANCEL'
).
color
.
value
,
0
);
expect
(
buttonMaterial
(
'CANCEL'
).
textStyle
.
color
.
value
,
0x61000000
);
await
tester
.
pumpWidget
(
buildFrame
(
ThemeData
.
dark
()));
await
tester
.
pumpAndSettle
();
// Complete the theme animation.
expect
(
buttonMaterial
(
'CONTINUE'
).
color
.
value
,
0
);
expect
(
buttonMaterial
(
'CONTINUE'
).
textStyle
.
color
.
value
,
0x61ffffff
);
expect
(
buttonMaterial
(
'CANCEL'
).
color
.
value
,
0
);
expect
(
buttonMaterial
(
'CANCEL'
).
textStyle
.
color
.
value
,
0x61ffffff
);
});
}
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