NuntioStateButton.icon constructor
NuntioStateButton.icon(
- BuildContext context, {
- 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 = 5.0,
- TextStyle? textStyle,
- CircularProgressIndicator? progressIndicator,
- MainAxisAlignment? progressIndicatorAlignment,
- EdgeInsets padding = EdgeInsets.zero,
- List<
ButtonState> minWidthStates = const <ButtonState>[ButtonState.loading],
Implementation
factory NuntioStateButton.icon(
BuildContext context, {
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: 5.0,
TextStyle? textStyle,
CircularProgressIndicator? progressIndicator,
MainAxisAlignment? progressIndicatorAlignment,
EdgeInsets padding = EdgeInsets.zero,
List<ButtonState> minWidthStates = const <ButtonState>[ButtonState.loading],
}) {
assert(
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: Theme.of(context).brightness == Brightness.light
? Colors.white
: Colors.black,
fontWeight: FontWeight.w600,
fontSize: 16);
}
Map<ButtonState, Widget> stateWidgets = {
ButtonState.idle: buildChildWithIcon(
context, iconedButtons[ButtonState.idle]!, iconPadding, textStyle),
ButtonState.loading: Column(),
ButtonState.fail: buildChildWithIcon(
context, iconedButtons[ButtonState.fail]!, iconPadding, textStyle),
ButtonState.success: buildChildWithIcon(
context, 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 NuntioStateButton(
stateWidgets: stateWidgets,
stateColors: stateColors,
state: state,
onPressed: onPressed,
onAnimationEnd: animationEnd,
maxWidth: maxWidth,
minWidth: minWidth,
progressIndicatorSize: progressIndicatorSize,
progressIndicatorAlignment: MainAxisAlignment.center,
progressIndicator: progressIndicator,
minWidthStates: minWidthStates,
);
}