We can scroll the text up and down but no scroll bar is shown.
My purpose in showing the scroll bar was to make the user aware that there is more text below.
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Scrollable Alert Dialog'),
content: SingleChildScrollView(
child: Scrollbar(
child: Column(
children: [
// add your scrollable content here
// for example:
for (var i = 1; i <= 20; i++)
Text('Item $i'),
],
),
),
),
actions: [
TextButton(
child: Text('Close'),
onPressed: () => Navigator.of(context).pop(),
),
],
);
},
);
2
Answers
This version worked! Thanks to Yeasin Sheikh.
Perhaps the 20 items isn’t enough to make it scrollable based on your viewport. SingleChildScrollView will be scrollable only when its child size is greater than its view port. Also, you may wrap the scrollable widget with
Scrollbar
.