I am doing the signup screen and I have an error in the Container, I have first child function and at the second there is an error at child(Elevated Button). Any idea what I should do? Use a Scaffold? Or create another container?`
class LoginButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 50,
width: 300,
child: Form(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
left: 40.0, right: 40.0, top: 30.0),
child: TextFormField(
style: TextStyle(color: Colors.black),
decoration: InputDecoration(
hintText: 'Nume Companie/Liber Profesionst/Client',
hintStyle: TextStyle(
fontFamily: 'Antra',
fontSize: 12.0,
color: Colors.black)),
),
),
Padding(
padding: const EdgeInsets.only(
left: 40.0, right: 40.0, top: 40.0),
child: TextFormField(
style: TextStyle(color: Colors.black),
decoration: InputDecoration(
hintText: 'Email',
hintStyle: TextStyle(
fontFamily: 'Antra',
fontSize: 12.0,
color: Colors.black)),
),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.black,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(32),
)),
I try to add a padding and a sizebox but nothing worked
>Solution :
On Column, you need to provide widget directly inside children and the Padding widget already have a child.
class LoginButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 50,
width: 300,
child: Form(
child: Column(
children: <Widget>[
Padding(
padding:
const EdgeInsets.only(left: 40.0, right: 40.0, top: 30.0),
child: TextFormField(
style: TextStyle(color: Colors.black),
decoration: InputDecoration(
hintText: 'Nume Companie/Liber Profesionst/Client',
hintStyle: TextStyle(
fontFamily: 'Antra',
fontSize: 12.0,
color: Colors.black)),
),
),
Padding(
padding:
const EdgeInsets.only(left: 40.0, right: 40.0, top: 40.0),
child: TextFormField(
style: TextStyle(color: Colors.black),
decoration: InputDecoration(
hintText: 'Email',
hintStyle: TextStyle(
fontFamily: 'Antra',
fontSize: 12.0,
color: Colors.black)),
),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.black,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(32),
)),
onPressed: () {},
child: Text(
'Login',
style: TextStyle(color: Colors.white),
),
)
],
),
),
);
}
}