Gioele
Gioele

Reputation: 348

How to make dialog scrollable?

I'm developing a Flutter App and in this app, there are some Dialogs. In these dialogs, there is only a Text; but when the text is too long, I can't scroll the text.

showDialog(
      context: context,
      barrierDismissible: true,
      builder: (context) => AlertDialog(
        title: Text(title),
        content: Text(description),
        actions: < Widget > [
          FlatButton(
            child: Text("PLAY"),
            onPressed: () {
              _launchURL(link);
            },
          )
        ],
      )
    );

Upvotes: 0

Views: 2188

Answers (1)

Aman Kataria
Aman Kataria

Reputation: 616

You can use ListBody inside SingleChildScrollView for this use case. Here you go:

 showDialog(
          context: context,
          barrierDismissible: true,
          builder: (context) => AlertDialog(
            title: Text(title),
            content: SingleChildScrollView(
              child: ListBody(
                children: <Widget>[
                  Text(description)
                ],
              ),
            ),
           actions: < Widget > [
              FlatButton(
                child: Text("PLAY"),
                onPressed: () {
                  _launchURL(link);
                },
              )
            ],
          )
        );

Upvotes: 3

Related Questions