32 lines
955 B
Dart
32 lines
955 B
Dart
|
import 'package:flutter/material.dart';
|
||
|
import '../main.dart';
|
||
|
|
||
|
mixin ShowErrorDialog on State<LoginDemo> {
|
||
|
void showErrorDialog(BuildContext context, String text) {
|
||
|
// Create AlertDialog
|
||
|
AlertDialog dialog = AlertDialog(
|
||
|
title: Text("Error"),
|
||
|
content: Text(text),
|
||
|
actions: [
|
||
|
ElevatedButton(
|
||
|
child: Text("OK"),
|
||
|
style: ElevatedButton.styleFrom(
|
||
|
primary: Colors.red,
|
||
|
padding: EdgeInsets.symmetric(horizontal: 50, vertical: 20),
|
||
|
textStyle:
|
||
|
TextStyle(fontSize: 15, fontWeight: FontWeight.normal)),
|
||
|
onPressed: () {
|
||
|
Navigator.of(context).pop("Yes, Of course!"); // Return value
|
||
|
}),
|
||
|
],
|
||
|
);
|
||
|
|
||
|
// Call showDialog function to show dialog.
|
||
|
Future futureValue = showDialog(
|
||
|
context: context,
|
||
|
builder: (BuildContext context) {
|
||
|
return dialog;
|
||
|
});
|
||
|
}
|
||
|
}
|