step 7 : proses login dan refactor struktur folder
This commit is contained in:
70
lib/widget/customsnackbarwidget.dart
Normal file
70
lib/widget/customsnackbarwidget.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:top_snackbar_flutter/custom_snack_bar.dart';
|
||||
import 'package:top_snackbar_flutter/top_snack_bar.dart';
|
||||
|
||||
enum snackbarType { error, info, success, warning }
|
||||
|
||||
snackbarWidget(
|
||||
BuildContext context,
|
||||
String msg,
|
||||
snackbarType tipe,
|
||||
Duration displayDuration,
|
||||
) {
|
||||
switch (tipe) {
|
||||
case snackbarType.error:
|
||||
return showTopSnackBar(
|
||||
animationDuration: Duration(milliseconds: 900),
|
||||
displayDuration: displayDuration,
|
||||
dismissType: DismissType.onTap,
|
||||
Overlay.of(context),
|
||||
CustomSnackBar.error(
|
||||
message: msg,
|
||||
),
|
||||
);
|
||||
|
||||
case snackbarType.success:
|
||||
return showTopSnackBar(
|
||||
animationDuration: Duration(milliseconds: 900),
|
||||
displayDuration: displayDuration,
|
||||
dismissType: DismissType.onTap,
|
||||
Overlay.of(context),
|
||||
CustomSnackBar.success(
|
||||
message: msg,
|
||||
),
|
||||
);
|
||||
|
||||
case snackbarType.info:
|
||||
return showTopSnackBar(
|
||||
animationDuration: Duration(milliseconds: 900),
|
||||
displayDuration: displayDuration,
|
||||
dismissType: DismissType.onTap,
|
||||
Overlay.of(context),
|
||||
CustomSnackBar.info(
|
||||
message: msg,
|
||||
),
|
||||
);
|
||||
|
||||
case snackbarType.warning:
|
||||
return showTopSnackBar(
|
||||
animationDuration: Duration(milliseconds: 900),
|
||||
displayDuration: displayDuration,
|
||||
dismissType: DismissType.onTap,
|
||||
Overlay.of(context),
|
||||
CustomSnackBar.info(
|
||||
backgroundColor: Colors.orangeAccent,
|
||||
message: msg,
|
||||
),
|
||||
);
|
||||
|
||||
default:
|
||||
return showTopSnackBar(
|
||||
animationDuration: Duration(milliseconds: 900),
|
||||
displayDuration: Duration(seconds: 1),
|
||||
dismissType: DismissType.onTap,
|
||||
Overlay.of(context),
|
||||
CustomSnackBar.info(
|
||||
message: msg,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user