flutter_alert 0.4.0 flutter_alert: ^0.4.0 copied to clipboard
Flutter package which shows a crossplatform alert messages on Android (Material) and iOS (Cupertino).
import 'package:flutter/material.dart';
import 'package:flutter_alert/flutter_alert.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHome(),
);
}
}
class MyHome extends StatelessWidget {
void _showDialog(BuildContext context) {
showAlert(
context: context,
title: "Delete file?",
body: "Should we delete the file XYZ?",
actions: [
AlertAction(
text: "Delete",
isDestructiveAction: true,
onPressed: () {
// TODO
},
),
],
cancelable: true,
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("OK"),
),
floatingActionButton: FloatingActionButton(
onPressed: () => _showDialog(context),
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}