Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Error at child function in a Container ( mobile app flutter)

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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),
              ),
            )
          ],
        ),
      ),
    );
  }
}

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading