relative_dialog 0.1.1 icon indicating copy to clipboard operation
relative_dialog: ^0.1.1 copied to clipboard

Displays a dialog above the current contents of the app relative to the widget associated with the given BuildContext.

Relative Dialog #

A flutter package for displaying a dialog using the showDialog API relative to the widget associated with the given BuildContext.

Basic demo 2 gif.

Basic demo gif.

Example #

Builder(
  builder: (context) {
    return ElevatedButton(
      child: Text('Show relative dialog'),
      onPressed: () {
        showRelativeDialog(
          // The context of the widget that the dialog should be shown relative to.
          context: context,
          // The alignment the dialog should be positioned at relative to widget that opened it.
          alignment: Alignment.topRight,
          builder: (context) {
            return Text(
              'Done!',
              style: TextStyle(
                color: Colors.white,
              ),
            ),
          }
        );
      },
    );
  }
)

Custom Animations #

By default the dialog uses a FadeTransition animation, but custom animations can be specified using the transitionBuilder API:

Builder(
  builder: (context) {
    return ElevatedButton(
      child: Text('Show relative dialog'),
      onPressed: () {
        showRelativeDialog(
          context: context,
          alignment: Alignment.bottomRight,
          transitionBuilder: (context, animation, secondaryAnimation, child) =>
            ScaleTransition(
              alignment: Alignment.topRight,
              scale: CurvedAnimation(
                parent: animation,
                curve: Curves.easeOut,
                reverseCurve: Curves.easeIn,
              ),
              child: child,
            ),
          builder: (context) {
            return Text(
              'Done!',
              style: TextStyle(
                color: Colors.white,
              ),
            ),
          }
        );
      },
    );
  }
)

Basic demo gif.

Demo #

Full demo.

5
likes
130
pub points
35%
popularity

Publisher

unverified uploader

Displays a dialog above the current contents of the app relative to the widget associated with the given BuildContext.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on relative_dialog