ProgressButton.icon constructor
ProgressButton.icon({
- required Map<
ButtonState, IconedButton> iconedButtons, - Function? onPressed,
- ButtonState? state = ButtonState.idle,
- Function? animationEnd,
- dynamic maxWidth = 170.0,
- dynamic minWidth = 58.0,
- dynamic height = 53.0,
- dynamic radius = 100.0,
- dynamic progressIndicatorSize = 35.0,
- double iconPadding = 4.0,
- TextStyle? textStyle,
- CircularProgressIndicator? progressIndicator,
- MainAxisAlignment? progressIndicatorAlignment,
- EdgeInsets padding = EdgeInsets.zero,
- List<
ButtonState> minWidthStates = const <ButtonState>[ButtonState.loading],
Implementation
factory ProgressButton.icon({
required Map<ButtonState, IconedButton> iconedButtons,
Function? onPressed,
ButtonState? state = ButtonState.idle,
Function? animationEnd,
maxWidth: 170.0,
minWidth: 58.0,
height: 53.0,
radius: 100.0,
progressIndicatorSize: 35.0,
double iconPadding: 4.0,
TextStyle? textStyle,
CircularProgressIndicator? progressIndicator,
MainAxisAlignment? progressIndicatorAlignment,
EdgeInsets padding = EdgeInsets.zero,
List<ButtonState> minWidthStates = const <ButtonState>[ButtonState.loading],
}) {
assert(
iconedButtons != null &&
iconedButtons.keys.toSet().containsAll(ButtonState.values.toSet()),
'Must be non-null widgets provided in map of stateWidgets. Missing keys => ${ButtonState.values.toSet().difference(iconedButtons.keys.toSet())}',
);
if (textStyle == null) {
textStyle = TextStyle(color: Colors.white, fontWeight: FontWeight.w500);
}
Map<ButtonState, Widget> stateWidgets = {
ButtonState.idle: buildChildWithIcon(
iconedButtons[ButtonState.idle]!, iconPadding, textStyle),
ButtonState.loading: Column(),
ButtonState.fail: buildChildWithIcon(
iconedButtons[ButtonState.fail]!, iconPadding, textStyle),
ButtonState.success: buildChildWithIcon(
iconedButtons[ButtonState.success]!, iconPadding, textStyle)
};
Map<ButtonState, Color> stateColors = {
ButtonState.idle: iconedButtons[ButtonState.idle]!.color,
ButtonState.loading: iconedButtons[ButtonState.loading]!.color,
ButtonState.fail: iconedButtons[ButtonState.fail]!.color,
ButtonState.success: iconedButtons[ButtonState.success]!.color,
};
return ProgressButton(
stateWidgets: stateWidgets,
stateColors: stateColors,
state: state,
onPressed: onPressed,
onAnimationEnd: animationEnd,
maxWidth: maxWidth,
minWidth: minWidth,
radius: radius,
height: height,
progressIndicatorSize: progressIndicatorSize,
progressIndicatorAlignment: MainAxisAlignment.center,
progressIndicator: progressIndicator,
minWidthStates: minWidthStates,
);
}