错误:此大小框(高度:50)之前应有"","",,错误:找不到方法:"大小框"


当我在代码中使用Sizedbox时,它会显示红线批注和错误。我正在使用安卓工作室开发flutter应用程序。这是我正在创建的登录UI。https://www.youtube.com/watch?v=PqZgkU_SZAE&t=111s我指的是这个youtube视频。有人能解释一下为什么会这样吗

在此处输入图像描述错误:此SizedBox(高度:50(之前应为",",错误:找不到方法:"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(),

],
)
)
],
),
),
),
);
}
}

您使用这个

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

SizedBox()之前添加逗号(,(

上一篇:

)
SizedBox(height:10), //error

正确:

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

您缺少commma(,(,并将Sizedbox更改为SizedBox执行以下操作:

Text(
'Email',
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold

),
)  , //you are missing comma here   
SizedBox(height: 50),

相关内容

最新更新