toastStory top-level property
Story
toastStory
getter/setter pair
Implementation
Story toastStory = Story(
name: 'Toast',
builder: (context) {
final position = context.knobs.options(
label: 'Position',
options: [
Option(label: 'Top', value: ToastPosition.top),
Option(label: 'Bottom', value: ToastPosition.bottom),
Option(label: 'Center', value: ToastPosition.center),
Option(label: 'Top Left', value: ToastPosition.topLeft),
Option(label: 'Top Right', value: ToastPosition.topRight),
Option(label: 'Bottom Left', value: ToastPosition.bottomLeft),
Option(label: 'Bottom Right', value: ToastPosition.bottomRight),
],
initial: ToastPosition.bottom,
);
final backgroundColor = context.knobs.options(
label: 'Background Color',
options: [
Option(label: 'Black', value: Colors.black),
Option(label: 'Red', value: Colors.red),
Option(label: 'Green', value: Colors.green),
Option(label: 'Blue', value: Colors.blue),
],
initial: Colors.white,
);
final duration = context.knobs.options(
label: 'Duration',
options: [
Option(label: '3 Seconds', value: Duration(seconds: 3)),
Option(label: '5 Seconds', value: Duration(seconds: 5)),
Option(label: '7 Seconds', value: Duration(seconds: 7)),
Option(label: '10 Seconds', value: Duration(seconds: 10)),
],
initial: Duration(seconds: 3),
);
final width = context.knobs.slider(
label: 'Width',
min: 100,
max: 500,
initial: 349,
);
final height = context.knobs.slider(
label: 'Height',
min: 10,
max: 200,
initial: 55,
);
final borderRadius = context.knobs.slider(
label: 'Border Radius',
min: 0,
max: 100,
initial: 8,
);
final hasIcon =
context.knobs.boolean(label: 'Show Icon', initial: false);
return Center(
child: Builder(
builder: (context) => DDSButton(
onPressed: () {
showDDSToast(
context: context,
outerBackgroundColor: backgroundColor,
innerBackgroundColor: backgroundColor,
borderRadius: borderRadius,
width: width,
innerBoxShadow: [],
innerBoxHeight: height,
outerBoxHeight: height,
padding: EdgeInsets.all(12),
duration: duration,
icon: hasIcon
? Icon(
Icons.circle_outlined,
size: 10,
color: Colors.black,
)
: null,
position: position);
},
label: "Show Toast",
shape: ButtonShape.roundedRectangle,
minWidth: 100,
width: 150,
),
),
);
});