bootstrap_like_modal 0.0.1 copy "bootstrap_like_modal: ^0.0.1" to clipboard
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);
                  },
                ),
              ],
            );
          },
        ),
      ),
    ),
  );
}
2
likes
110
pub points
0%
popularity

Publisher

unverified uploader

A Bootstrap like modal.

Documentation

API reference

License

GPL-3.0 (LICENSE)

Dependencies

bootstrap_like_breakpoints, flutter

More

Packages that depend on bootstrap_like_modal