modal_dialog 1.0.0 modal_dialog: ^1.0.0 copied to clipboard
Modal Dialog System
Modal Dialog System #
A Modal Dialog System based on the Bootstrap framework.
Install #
Edit your pubspec.yaml
and add the library dependency:
dependencies:
modal_dialog: <version number>
Gets the dependencies:
> pub get
Adds the Bootstrap's CSS link to your web page (see Getting started - Bootstrap):
<!DOCTYPE html>
<html>
<head>
</head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!--
Alternatively you can use the minified CSS file provided by the Bootjack library:
<link rel="stylesheet" href="packages/bootjack/css/bootstrap.min.css">
-->
And finally import the library from the source code:
import 'package:modal_dialog/core.dart';
void main() {
ModalDialog dialog = new ModalConfirm('Delete record', 'Are you sure?',
accept: (ModalDialog dialog) {
print('deleting record...');
dialog.close();
});
dialog.open();
}
Examples #
- Creates a Modal Message with two buttons:
new ModalMessage('Delete record', 'Are you sure?')
..addButton('Cancel')
..addButton('Accept', type: 'primary', action: (ModalDialog dialog) {
print('Deleting record..');
dialog.close();
})
..open();
- The previous example can be written easily by using the
ModalConfirm
class:
new ModalConfirm('Delete record', 'Are you sure?',
accept: (ModalDialog dialog) {
print('Deleting record..');
dialog.close();
})..open();
- Creates a Modal Alert message:
new ModalAlert('Error', 'An error has occurred')..open();
- Creates a Modal Loading message. A Modal Dialog is not open instantly. That's why
open()
is an asynchronous function. Note the use of theawait
keyword:
ModalDialog dialog = new ModalLoading();
await dialog.open();
try {
String data = await HttpRequest.getString('some url');
print(data);
} finally {
dialog.close();
}