popup_box Flutter

Pub Build GitHub license Twitter

Table of Contents

  1. Importing the dependency
  2. Parameters
  3. Making a button
        3.1 Starter declaration
        3.2 Making the Text
        3.2 Putting together the code

Importing the dependency

  • pubsec.yaml
dependencies:
 popup_box:
  • *.dart
import 'package:popup_box/popup_box.dart';

Parameters

  • @required BuildContext context
  • @required Widget willDisplayWidget
  • @required Widget button

Usage with an example

Starter declaration

floatingActionButton: FloatingActionButton(
        onPressed: () async {
          await PopupBox.showPopupBox()}

Making a button

floatingActionButton: FloatingActionButton(
        onPressed: () async {
          await PopupBox.showPopupBox(
              context: context,
              button: MaterialButton(
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(20),
                ),
                color: Colors.blue,
                child: Text(
                  'Ok',
                  style: TextStyle(fontSize: 20),
                ),
                onPressed: () {
                  Navigator.of(context).pop();
                },
              ),

Making the Text

willDisplayWidget: Column(
                children: <Widget>[
                  Text(
                    'Hi',
                    style: TextStyle(fontSize: 40, color: Colors.black),
                  ),
                  SizedBox(
                    height: 30,
                  )
                ],
              ));

Putting together the code

floatingActionButton: FloatingActionButton(
        onPressed: () async {
          await PopupBox.showPopupBox(
              context: context,
              button: MaterialButton(
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(20),
                ),
                color: Colors.blue,
                child: Text(
                  'Ok',
                  style: TextStyle(fontSize: 20),
                ),
                onPressed: () {
                  Navigator.of(context).pop();
                },
              ),
              willDisplayWidget: Column(
                children: <Widget>[
                  Text(
                    'Hi',
                    style: TextStyle(fontSize: 40, color: Colors.black),
                  ),
                  SizedBox(
                    height: 30,
                  )
                ],
              ));
        },)

Libraries