Dialog with flexible height and scrollable content Dialog with flexible height and scrollable content dart dart

Dialog with flexible height and scrollable content


You can use Column and Flexible.

void showCustomDialog(BuildContext context, String message) async {    await showDialog(      context: context,      builder: (BuildContext context) {        return AlertDialog(          content: Container(            width: double.maxFinite,            child: Column(                mainAxisAlignment: MainAxisAlignment.center,                mainAxisSize: MainAxisSize.min,                children: [                                        Text("Description 1",                      style: TextStyle(fontWeight: FontWeight.bold)),                  SizedBox(height: 8),                  Flexible(                    child: SingleChildScrollView(                      child: Text(message),                    ),                  ),                  ElevatedButton(                    onPressed: () {                       Navigator.of(context).pop();                    },                    child: Text("OK"),                  )                ]),          ),        );      },    );  }


I suggest changing the position of SingleChildScrollView to on top of Column and I hope that should work fine.

Something similar as below:

              height: 200,              width: 300,              child: SingleChildScrollView(                child: Column(                  crossAxisAlignment: CrossAxisAlignment.stretch,                  children: <Widget>[//Your children's column code ]