custom_alert_dialog.dart 771 B

12345678910111213141516171819202122232425262728
  1. import 'package:flutter/material.dart';
  2. class CustomAlertDialog extends StatelessWidget {
  3. @override
  4. Widget build(BuildContext context) {
  5. Widget myFlatButton(title, color, value) {
  6. return FlatButton(
  7. child: Text(
  8. title,
  9. style: TextStyle(color: color),
  10. ),
  11. onPressed: () => Navigator.of(context).pop(value),
  12. );
  13. }
  14. return AlertDialog(
  15. title: Text('Confirm delete'),
  16. content: Text('Do you really want to delete this?'),
  17. actions: <Widget>[
  18. myFlatButton('Delete', Colors.redAccent, true),
  19. myFlatButton('Cancel', Colors.grey, false),
  20. ],
  21. contentPadding: EdgeInsets.fromLTRB(25, 15, 25, 5),
  22. insetPadding: EdgeInsets.symmetric(horizontal: 20),
  23. );
  24. }
  25. }