bootstrap_like_modal 0.0.1 bootstrap_like_modal: ^0.0.1 copied to clipboard
A Bootstrap like modal.
example/lib/main.dart
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:bootstrap_like_modal/bootstrap_like_modal.dart';
import 'package:bootstrap_typography2/bootstrap_typography2.dart';
void main() {
// create modal
BSModal modal = BSModal(
dynamicSize: true,
content: P(
BSTextParams("Woohoo, you're reading this text in a modal!"),
),
bsModalActionsRowOptions: BSModalActionsRowOptions(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
),
);
// set title outside constructor, because we'd like to ref the modal
// so that the modal can close when the x icon is pressed
modal.title = Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
H4(
BSTextParams("Modal Example"),
),
IconButton(
icon: const Icon(
Icons.close,
color: Colors.red,
),
onPressed: () {
modal.hide();
},
),
],
);
// set actions outside modal, because we'd like to ref the modal
// so the modal can close when the close button is pressed
modal.actions = [
ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.red),
),
child: P(
BSTextParams("Close"),
),
onPressed: () {
modal.hide();
},
),
ElevatedButton(
child: P(
BSTextParams("Submit"),
),
onPressed: () {},
),
];
runApp(
MaterialApp(
home: Scaffold(
body: Builder(
builder: (context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: H1(BSTextParams("Open Modal")),
),
onPressed: () {
modal.show(context);
},
),
],
);
},
),
),
),
);
}