I create a dialog with a form and a child container with a width and height of 450 and 500. I use a layoutbuilder to create a textboxform whose max height is 200 with a scrollbar and singlechildscrollview. The row is expanded to take the all the width of the widget. I have two material buttons with action included.
String _myvalue;
final _myTextController = TextEditingController();
final _formKey = GlobalKey<FormState>();
final _scrollController = ScrollController();
Widget build(BuildContext context) {
return Dialog(
child: Form(
key: _formKey,
autovalidateMode: AutovalidateMode.disabled,
child: Container(
width: 450,
height: 500,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Align(
alignment: Alignment.center,
child: Text(
"Some Text",
style: Head2Style,
),
),
Divider(height: 50),
LayoutBuilder(
builder: (context, constraints) => Container(
constraints: new BoxConstraints(
maxHeight: 200.0,
maxWidth: constraints.maxWidth),
child: Scrollbar(
isAlwaysShown: true,
controller: _scrollController,
child: SingleChildScrollView(
controller: _scrollController,
child: SizedBox(
width: 400,
child: TextFormField(
decoration: InputDecoration(
icon: Icon(Icons.note),
hintText: "My Text"),
autocorrect: true,
controller: _myTextController,
keyboardType:
TextInputType.multiline,
maxLines: null,
maxLength: 1000,
onChanged: (String value) {
setState(() {
_myvalue = value;
});
})))))),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
ElevatedButton(
onPressed: () {
if (_formKey.currentState.validate()) {
_do_something(context);
}
},
child: Text("Do something"),
),
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text("Cancel"),
)
],
)),
])//column
)//container
)//form
)//dialog;
}