I wanted to make a login form where the fields will be in a column of a specific width.
I wanted to be able to scroll the entire page when the window size is smaller.
import 'package:flutter/material.dart';
class LoginPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.blue,
body: SingleChildScrollView(
child: Center(
child: Container(
// height: MediaQuery.of(context).size.height ,
width: 500,
decoration: BoxDecoration(
color: Color(0xfffee6dc),
border: Border.all(
width: 0,
style: BorderStyle.none
),
borderRadius: BorderRadius.all(Radius.circular(20))),
child: Column(
children: [
Text("TEST"),
SizedBox(height: 50,),
TextFormField(),
SizedBox(height: 10,),
TextFormField(),
SizedBox(height: 10,),
TextFormField(),
SizedBox(height: 10,),
TextFormField(),
SizedBox(height: 10,),
TextFormField(),
SizedBox(height: 10,),
TextFormField(),
SizedBox(height: 10,),
TextFormField(),
SizedBox(height: 10,),
TextFormField(),
SizedBox(height: 10,),
TextFormField(),
SizedBox(height: 10,),
TextFormField(),
SizedBox(height: 10,),
],
),
),
),
));
}
}
This works, but when I maximize the window, the height of the container doesn’t adjust to the size of the window, only to its children:
When I set the height to: MediaQuery.of(context).size.height
i’s better, but now when i shrink the window it throws me an error:
A RenderFlex overflowed by ** pixels on the bottom.
2
Answers
If you like to adjust the height, it should be on top widget constraints .
you need to create new class name sizeconfig
Code of sizeconfig Class:
Now you need to call this call inside build method:
Now its Work Fine
Here is video link