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
91311156
Unverified
Commit
91311156
authored
Mar 29, 2023
by
Ayush Bherwani
Committed by
GitHub
Mar 29, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Stepper] adds stepIconBuilder property (#122816)
[Stepper] adds stepIconBuilder property
parent
d74a1bb0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
1 deletion
+60
-1
stepper.dart
packages/flutter/lib/src/material/stepper.dart
+18
-1
stepper_test.dart
packages/flutter/test/material/stepper_test.dart
+42
-0
No files found.
packages/flutter/lib/src/material/stepper.dart
View file @
91311156
...
...
@@ -106,6 +106,10 @@ class ControlsDetails {
/// * [WidgetBuilder], which is similar but only takes a [BuildContext].
typedef
ControlsWidgetBuilder
=
Widget
Function
(
BuildContext
context
,
ControlsDetails
details
);
/// A builder that creates the icon widget for the [Step] at [stepIndex], given
/// [stepState].
typedef
StepIconBuilder
=
Widget
?
Function
(
int
stepIndex
,
StepState
stepState
);
const
TextStyle
_kStepStyle
=
TextStyle
(
fontSize:
12.0
,
color:
Colors
.
white
,
...
...
@@ -207,6 +211,7 @@ class Stepper extends StatefulWidget {
this
.
controlsBuilder
,
this
.
elevation
,
this
.
margin
,
this
.
stepIconBuilder
,
})
:
assert
(
0
<=
currentStep
&&
currentStep
<
steps
.
length
);
/// The steps of the stepper whose titles, subtitles, icons always get shown.
...
...
@@ -303,9 +308,17 @@ class Stepper extends StatefulWidget {
/// The elevation of this stepper's [Material] when [type] is [StepperType.horizontal].
final
double
?
elevation
;
///
c
ustom margin on vertical stepper.
///
C
ustom margin on vertical stepper.
final
EdgeInsetsGeometry
?
margin
;
/// Callback for creating custom icons for the [steps].
///
/// When overriding icon for [StepState.error], please return
/// a widget whose width and height are 14 pixels or less to avoid overflow.
///
/// If null, the default icons will be used for respective [StepState].
final
StepIconBuilder
?
stepIconBuilder
;
@override
State
<
Stepper
>
createState
()
=>
_StepperState
();
}
...
...
@@ -373,6 +386,10 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
Widget
_buildCircleChild
(
int
index
,
bool
oldState
)
{
final
StepState
state
=
oldState
?
_oldStates
[
index
]!
:
widget
.
steps
[
index
].
state
;
final
bool
isDarkActive
=
_isDark
()
&&
widget
.
steps
[
index
].
isActive
;
final
Widget
?
icon
=
widget
.
stepIconBuilder
?.
call
(
index
,
state
);
if
(
icon
!=
null
)
{
return
icon
;
}
switch
(
state
)
{
case
StepState
.
indexed
:
case
StepState
.
disabled
:
...
...
packages/flutter/test/material/stepper_test.dart
View file @
91311156
...
...
@@ -1259,6 +1259,48 @@ testWidgets('Stepper custom indexed controls test', (WidgetTester tester) async
tester
.
widget
<
Text
>(
find
.
text
(
'Label
${index + 2}
'
));
expect
(
bodyMediumStyle
,
nextLabelTextWidget
.
style
);
});
testWidgets
(
'Stepper stepIconBuilder test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Stepper
(
stepIconBuilder:
(
int
index
,
StepState
state
)
{
if
(
state
==
StepState
.
complete
)
{
return
const
FlutterLogo
(
size:
18
);
}
return
null
;
},
steps:
const
<
Step
>[
Step
(
title:
Text
(
'A'
),
state:
StepState
.
complete
,
content:
SizedBox
(
width:
100.0
,
height:
100.0
),
),
Step
(
title:
Text
(
'B'
),
state:
StepState
.
editing
,
content:
SizedBox
(
width:
100.0
,
height:
100.0
),
),
Step
(
title:
Text
(
'C'
),
state:
StepState
.
error
,
content:
SizedBox
(
width:
100.0
,
height:
100.0
),
),
],
),
),
),
);
/// Finds the overridden widget for StepState.complete
expect
(
find
.
byType
(
FlutterLogo
),
findsOneWidget
);
/// StepState.editing and StepState.error should have a default icon
expect
(
find
.
byIcon
(
Icons
.
edit
),
findsOneWidget
);
expect
(
find
.
text
(
'!'
),
findsOneWidget
);
});
}
class
_TappableColorWidget
extends
StatefulWidget
{
...
...
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