ask 0.0.3 ask: ^0.0.3 copied to clipboard
Create verification, radio, checkbox, and other dialogs using only a few lines of code.
import 'package:ask/ask.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: Scaffold(
body: Center(
child: Builder(
builder: (context) => RaisedButton(
child: Text('ask'),
onPressed: () async {
bool value = await ask(
title: 'Unsaved File',
message: 'Do you really want to discard this file?',
context: context,
defaultValue: false,
buttons: [
AskButton(
value: true,
text: 'YES',
type: AskButtonType.text,
color: Colors.red),
AskButton(
value: false,
text: 'NO',
type: AskButtonType.flat,
color: Colors.green),
]);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
'The user click the button with value ${value ? 'YES' : 'NO'}.'),
));
},
),
),
),
),
));
}