confirm_dialog 0.0.7 confirm_dialog: ^0.0.7 copied to clipboard
Confirm Dialog Widget JS-LIKE for Flutter. Use confirm dialog easy and simple for your flutter app.
Confirm Dialog #
Confirm Dialog Widget for Flutter(JS-LIKE). https://pub.dev/packages/confirm_dialog
Installation #
Add pubspec.yaml #
dependencies:
confirm_dialog: lastest_version
Example #
Basic #
import 'package:flutter/material.dart';
import 'package:confirm_dialog/confirm_dialog.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
title: Text('Welcome to Flutter'),
),
body: Center(
child: FlatButton(
child: Text('Confirm Dialog'),
onPressed: () async {
if (await confirm(context)) {
return print('pressedOK');
}
return print('pressedCancel');
},
),
),
),
);
}
}
Custom Message #
import 'package:flutter/material.dart';
import 'package:confirm_dialog/confirm_dialog.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
title: Text('Welcome to Flutter'),
),
body: Center(
child: FlatButton(
child: Text('Confirm Dialog'),
onPressed: () async {
if (await confirm(context, message: 'Would you like to remove?', textOK: 'Yes', textCancel: 'No')) {
return print('pressedOK');
}
return print('pressedCancel');
},
),
),
),
);
}
}