Dialog popup

This article shows how to raise dialog popup.

Download source code

Dependencies

Add native_widgets package to pubspec.yaml.
Android will use Material Design and iOS will use Cupertino style widgets.

dependencies:
  flutter:
    sdk: flutter

  native_widgets: ^1.0.0+4
  // https://pub.dartlang.org/packages/native_widgets

PopupUtils

import 'package:flutter/material.dart';
import 'package:native_widgets/native_widgets.dart';

class PopupUtils {
  static void showAlertPopup(
      BuildContext context, String title, String detail) async {
    void showDemoDialog<T>({BuildContext context, Widget child}) {
      showDialog<T>(
        context: context,
        barrierDismissible: false,
        builder: (BuildContext context) => child,
      );
    }

    return showDemoDialog<Null>(
        context: context,
        child: NativeDialog(
          title: Text(title),
          content: Text(detail),
          actions: <NativeDialogAction>[
            NativeDialogAction(
                text: Text('OK'),
                isDestructive: false,
                onPressed: () {
                  Navigator.pop(context);
                }),
          ],
        ));
  }

  static void showDemoDialog<T>({BuildContext context, Widget child}) {
    showDialog<T>(
      context: context,
      builder: (BuildContext context) => child,
    ).then<void>((T value) {
      // The value passed to Navigator.pop() or null.
    });
  }
}

Raise popup

RaisedButton(
          child: Text('Show popup'),
          onPressed: () {
            PopupUtils.showAlertPopup(context, 'Info', "That's all folks");
          },