add durations to snackbars
This commit is contained in:
@@ -61,6 +61,7 @@ void showTabOpenedMessage(
|
|||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
String? tabName,
|
String? tabName,
|
||||||
void Function()? onShow,
|
void Function()? onShow,
|
||||||
|
Duration duration = const Duration(seconds: 3),
|
||||||
}) {
|
}) {
|
||||||
final message = switch (tabName.whenNotEmpty) {
|
final message = switch (tabName.whenNotEmpty) {
|
||||||
String() => "New tab '$tabName' opened in background",
|
String() => "New tab '$tabName' opened in background",
|
||||||
@@ -72,6 +73,7 @@ void showTabOpenedMessage(
|
|||||||
action: onShow.mapNotNull(
|
action: onShow.mapNotNull(
|
||||||
(onPressed) => SnackBarAction(label: 'Show', onPressed: onPressed),
|
(onPressed) => SnackBarAction(label: 'Show', onPressed: onPressed),
|
||||||
),
|
),
|
||||||
|
duration: duration,
|
||||||
);
|
);
|
||||||
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||||
@@ -106,6 +108,7 @@ void showTabSwitchMessage(
|
|||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
String? tabName,
|
String? tabName,
|
||||||
void Function()? onSwitch,
|
void Function()? onSwitch,
|
||||||
|
Duration duration = const Duration(seconds: 3),
|
||||||
}) {
|
}) {
|
||||||
ScaffoldMessenger.of(context).clearSnackBars();
|
ScaffoldMessenger.of(context).clearSnackBars();
|
||||||
|
|
||||||
@@ -119,6 +122,7 @@ void showTabSwitchMessage(
|
|||||||
action: onSwitch.mapNotNull(
|
action: onSwitch.mapNotNull(
|
||||||
(onPressed) => SnackBarAction(label: 'Switch', onPressed: onPressed),
|
(onPressed) => SnackBarAction(label: 'Switch', onPressed: onPressed),
|
||||||
),
|
),
|
||||||
|
duration: duration,
|
||||||
);
|
);
|
||||||
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||||
|
|||||||
Reference in New Issue
Block a user