Appearance
Alert
A representation of Dialog.
NikuAlert
accepts all the props as same as AlertDialog.
To be use with showNikuDialog or n.showDialog.
// Using namespace
n.Alert();
// Using Niku Prefix
NikuAlert();
Example Usage
final alert = n.Alert()
..title = Text("Session Expired")
..content = Text("Your session have been expired, please sign in again")
..actions = [
n.Button("Ok".n)
..onPressed = showSignInPage,
];
n.showDialog(
context: context,
builder: (context) => alert,
barrierDismissible: false,
);
Adaptive Alert
Niku Alert can show native alert dialog instead for each platform (iOS, Android) by adding .adaptive
final alert = n.Alert.adaptive()
..title = Text("Delete 1 photo")
..content = Text("Are you sure to delete 1 photo?")
..actions = [
n.Button("Delete".n)
..onPressed = closeDialog
..color = Colors.red,
n.Button("Cancel".n)
..onPressed = closeDialog
..bold,
];
n.showDialog(
context: context,
builder: (context) => alert
);
Factory Method
Niku can accepts 3 factory method.
Factory Method | Equivalent Widget |
---|---|
n.Alert | AlertDialog |
n.Alert.cupertino | CupertinoAlertDialog |
n.Alert.adaptive | - |