1

I have to add a horizontal and a vertical divider for my alert dialog as shown in figure.

The only method I am trying is here, better not to refer this code, but I need to design as expected in image.

AlertDialog(
  shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.all(Radius.circular(10.0))
  ),
  content: Column(
    mainAxisSize: MainAxisSize.min,
    children: <Widget>[
      new Row(
        children: <Widget>[
          Expanded(
            child: Container(
              decoration: BoxDecoration(
                border: Border.all(color: Colors.black)
              ),
              child: new GestureDetector(
                onTap: () => callback(AlertButton.positive),
                child: new Text(
                  positiveActionText,
                  textAlign: TextAlign.center,
                ),
              ),
            ),
          ),
          Expanded(
            child: Container(
              decoration: BoxDecoration(
                border: Border.all(color: Colors.black)
              ),
              child: new GestureDetector(
                onTap: () => callback(AlertButton.negative),
                child: new Text(
                  negativeActionText,
                  textAlign: TextAlign.center,
                ),
              ),
            ),
          ),
        ],
      ),
    ],
  ),
);

The below is an image: Expected design Image

john
  • 447
  • 1
  • 7
  • 11
  • Does this answer your question? [Flutter divider widget not appearing](https://stackoverflow.com/questions/49088934/flutter-divider-widget-not-appearing) – AskNilesh Jan 10 '20 at 12:19

3 Answers3

3

You can use CupertinoAlertDialog, which has these lines by default :

Cupertino alert dialog

In your case :

showDialog(
    context: context,
    builder: (_) => CupertinoAlertDialog(
        content: Text('Are you sure want to logout?'),
        actions: [
            CupertinoDialogAction(child: Text('Yes'), onPressed: (){}),
            CupertinoDialogAction(child: Text('No'), onPressed: (){}),
        ],
    ),
);
Augustin R
  • 7,089
  • 3
  • 26
  • 54
0

You can use the Divider widget

Divider(
  color: Colors.black87,
  height: 10.0,
  indent: 5.0,// Starting Space
  endIndent: 5.0 // Ending Space
)
Android
  • 99
  • 1
  • 1
  • 13
0
var alert = new CupertinoAlertDialog(
  title: new Text("Alert"),
  content: new Text("Test Sample 123."),
  actions: <Widget>[
    new CupertinoDialogAction(
      child: const Text('Discard'),
      isDestructiveAction: true,
      onPressed: (){}
    ),
    new CupertinoDialogAction(
        child: const Text('Cancel'),
        isDefaultAction: true,
        onPressed: () {}
    ),
  ],
);

showDialog(context: context, child: alert);
Sagar Acharya
  • 3,397
  • 4
  • 12
  • 34