【发布时间】:2021-11-28 12:34:52
【问题描述】:
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dev/utils/routes.dart';
class LoginPage extends StatefulWidget {
bool changeButton = false;
@override
State<LoginPage> createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
get name => null;
@override
Widget build(BuildContext context) {
return Material(
color: Colors.white,
child: SingleChildScrollView(
child: Column(
children: [
Image.asset(
"assets/images/login_image.png",
fit: BoxFit.cover,
),
SizedBox(
height: 20.0,
),
Text(
"Welcome",
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
),
),
SizedBox(
height: 20.0,
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 16.0, horizontal: 32.0),
child: Column(
children: [
TextFormField(
decoration: InputDecoration(
hintText: "Enter username",
labelText: "Username",
),
onChanged: (value) {
satState() {}
},
),
TextFormField(
obscureText: true,
decoration: InputDecoration(
hintText: "Enter Password",
labelText: "Password",
),
),
SizedBox(
height: 40.0,
),
InkWell(
onTap: (){
setState(() {
changeButton = true;
});
// Navigator.pushNamed(context, MyRoutes.homeRoute);
},
child: AnimatedContainer(
duration: Duration(seconds: 1),
width: 150,
height: 40,
alignment: Alignment.center,
child: Text(
"login",
style: TextStyle(
color: Colors.white,
fontWeight:FontWeight.bold,
fontSize: 18
),
),
decoration: BoxDecoration(
color: Colors.deepPurple,
borderRadius: BorderRadius.circular(8)
)
),
)
// ElevatedButton(
// child: Text("Login"),
// style: TextButton.styleFrom(
// minimumSize: Size(140, 40),
// ),
// onPressed: () {
// Navigator.pushNamed(context, MyRoutes.homeRoute);
// },
// ),
],
),
)
],
),
));
}
}
错误:
未定义名称“更改按钮”。尝试将名称更正为已定义的名称,或定义名称
请解决这个问题
【问题讨论】:
-
请分享代码,而不是图片。
标签: android flutter visual-studio-code