Cupertino AlertDialog Action iOS Style In Flutter

Cupertino AlertDialog Action iOS Style In Flutter :

CupertinoAlertDialog is  An iOS-style alert dialog.

In this tutorial we want to look at a popular style of dialog in flutter called CupertinoDialog.

Generally we utilize an alert dialog to tell the user about situations that need user attention or acknowledgement.

AlertDialogs can have the following:

  1. Title(Optional) – displayed above content
  2. Content(Optional) – displayed between content and list of actions.
  3. List of actions(Optional) – displayed below the content
  4. The title is displayed above the content and the actions are displayed below the content.

CupertinoAlertDialogs do style their titles and content (typically a message) to match the standard iOS title and message dialog text style.

CupertinoAlertDialog API Definition
CupertinoAlertDialog derives from the StatelessWidget which further derives from the Widget class.

CupertinoAlertDialog Properties

  1. title → Widget : The (optional) title of the dialog is displayed in a large font at the top of the dialog.
  2. content → Widget : The (optional) content of the dialog is displayed in the center of the dialog in a lighter font.
  3. actions → List : The (optional) set of actions that are displayed at the bottom of the dialog.
  4. scrollController → ScrollController : A scroll controller that can be used to control the scrolling of the content in the dialog.
  5. actionScrollController → ScrollController : A scroll controller that can be used to control the scrolling of the actions in the dialog.
Cupertino AlertDialog

Cupertino Dialog Action iOS Style.dart

 void _showDia() {
    var scrollController = ScrollController();
    var actionScrollController = ScrollController();
    var dia = CupertinoAlertDialog(
      title: Text("title"),
      content: Text("content............"),
      actions: <Widget>[
        CupertinoDialogAction(
          child: Text("yes"),
          onPressed: () {},
          isDefaultAction: true,
          isDestructiveAction: false,
        ),
        CupertinoDialogAction(
          child: Text("delete"),
          onPressed: () {},
          isDefaultAction: false,
          isDestructiveAction: true,
        ),
        CupertinoDialogAction(
          child: Text("cancel"),
          onPressed: () {
            Navigator.of(context, rootNavigator: true).pop();
          },
          isDefaultAction: true,
          isDestructiveAction: true,
        ),
      ],
      scrollController: scrollController,
      actionScrollController: actionScrollController,
    );
    showDialog(
        context: context,
        barrierDismissible: false,//点击dialog外部是否消失,默认为true
        builder: (context) {
          return dia;
        });
  }

The flutter tutorial  is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application

For more information about Flutter. visit www.fluttertutorial.in