Error: Expected ',' before this SizedBox(height: 50),, Error: Method not found: 'Sizedbox'

608 Views Asked by At

when I used Sizedbox in my code, it display redlines and errors. I'm using the android studio to develop the flutter app. this is the login UI I'm creating. https://www.youtube.com/watch?v=PqZgkU_SZAE&t=111s I refer to this youtube video. can someone please explain why this is happening

enter image description here Error: Expected ',' before this SizedBox(height: 50), Error: Method not found: 'Sizedbox'.

import 'package:flutter/cupertino.dart';
    
import 'package:flutter/material.dart';
    
import'package:flutter/services.dart';
    
    
    class LoginScreen extends StatefulWidget {
    
    
    @override
      _LoginScreenState createState() => _LoginScreenState();
      }
    
    Widget buildEmail(){
      return Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Text(
            'Email',
            style: TextStyle(
              color: Colors.white,
              fontSize: 16,
              fontWeight: FontWeight.bold
    
            ),
          )
    
          **Sizedbox (height:10),** //error
          Container(
            alignment: Alignment.centerLeft,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(10),
              boxShadow: [
                BoxShadow(
                  color:Colors.black26,
                  blurRadius: 6,
                  offset :Offset(0,2)
    
                )
              ]
              
            ),
            height:60,
            child: TextField(
              keyboardType: TextInputType.emailAddress,
    
            )
    
    
          )
        ]
    
      );
    }
    
    
             class _LoginScreenState extends State <LoginScreen> {
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: AnnotatedRegion<SystemUiOverlayStyle> (
            value: SystemUiOverlayStyle.light,
            child: GestureDetector(
              child: Stack(
                children: <Widget>[
                  Container(
                    height: double.infinity,
                    width: double.infinity,
                    decoration: BoxDecoration(
                      gradient: LinearGradient(
                        begin: Alignment.topCenter,
                        end: Alignment.bottomCenter,
                        colors:[
                          Color(0x665ac18e),
                          Color(0x995ac18e),
                          Color(0xcc5ac18e),
                          Color(0xff5ac18e),
                        ]
                      )
                    ),
    
                    child:Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        Text(
                          'Sign In',
                          style: TextStyle(
                                color: Colors.white,
                            fontSize: 40,
                            fontWeight: FontWeight.bold
    
                          ),
                        )
    
                        **SizedBox(height: 50),** //error
                        buildEmail(),
    
                      ],
                    )
                  )
                ],
              ),
            ),
          ),
        );
      }
    }
3

There are 3 best solutions below

0
keyur On

You use this

         Text(
                'Sign In',
                style: TextStyle(
                    cbuildEmail(),olor: Colors.white,
                    fontSize: 40,
                    fontWeight: FontWeight.bold),
              ),
              SizedBox(height: 50),
             buildEmail(),
3
Nabin Dhakal On

You are missing commma (,) and Change Sizedbox to SizedBox Do as follows:

Text(
            'Email',
            style: TextStyle(
              color: Colors.white,
              fontSize: 16,
              fontWeight: FontWeight.bold
    
            ),
          )  , //you are missing comma here   
SizedBox(height: 50),
0
Cynthia Konar On

Add a comma(,) before SizedBox()

Previous:

  )
  SizedBox(height:10), //error

Correct:

  ),
  SizedBox(height:10), //debugged