我的应用程序不再工作了,这昨天起作用了,但是不管我尝试调试什么,即使我没有改变任何东西,只是热重新加载,都会出现未实现的错误。
昨天工作得很好。我的项目上的错误张贴在下面。它用一个列小部件写着,但我不知道它在哪里,因为它昨天运行得很好。
IT应该从LoginScreen开始,而不是直接到主屏幕,因为某种原因,当我尝试我制作的应用程序的github克隆时,它直接进入主屏幕,而不是先登录屏幕。
另外,我没有对我的主屏幕做任何更改,但在login.dart,register.dart上,仅从昨天起,防火墙认证工作,应用程序继续到主屏幕。
我增加了错误的图像
你可以尝试克隆我的项目https://github.com/rolandopeda/syncshop
误差
I/flutter ( 7581): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 7581): The following assertion was thrown during layout:
I/flutter ( 7581): A RenderFlex overflowed by 2.0 pixels on the bottom.
I/flutter ( 7581):
I/flutter ( 7581): The relevant error-causing widget was:
I/flutter ( 7581): Column
lib\login\login.dart:129
I/flutter ( 7581):
I/flutter ( 7581): The overflowing RenderFlex has an orientation of Axis.vertical.
I/flutter ( 7581): The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and
I/flutter ( 7581): black striped pattern. This is usually caused by the contents being too big for the RenderFlex.
I/flutter ( 7581): Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the
I/flutter ( 7581): RenderFlex to fit within the available space instead of being sized to their natural size.
I/flutter ( 7581): This is considered an error condition because it indicates that there is content that cannot be
I/flutter ( 7581): seen. If the content is legitimately bigger than the available space, consider clipping it with a
I/flutter ( 7581): ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex,
I/flutter ( 7581): like a ListView.
I/flutter ( 7581): The specific RenderFlex in question is: RenderFlex#7e604 relayoutBoundary=up9 OVERFLOWING:
I/flutter ( 7581): creator: Column ← ConstrainedBox ← Container ← _PointerListener ← Listener ← _GestureSemantics ←
I/flutter ( 7581): RawGestureDetector ← GestureDetector ← MouseRegion ← Semantics ← _FocusMarker ← Focus ← ⋯
I/flutter ( 7581): parentData: <none> (can use size)
I/flutter ( 7581): constraints: BoxConstraints(0.0<=w<=331.4, h=12.0)
I/flutter ( 7581): size: Size(96.0, 12.0)
I/flutter ( 7581): direction: vertical
I/flutter ( 7581): mainAxisAlignment: start
I/flutter ( 7581): mainAxisSize: max
I/flutter ( 7581): crossAxisAlignment: center
I/flutter ( 7581): verticalDirection: down
I/flutter ( 7581): ◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
I/flutter ( 7581): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 7581): Another exception was thrown: A RenderFlex overflowed by 164 pixels on the bottom.
════════ Exception caught by widgets library ═══════════════════════════════════
The following _CompileTimeError was thrown building MyApp(dirty):
Unimplemented handling of missing static target
The relevant error-causing widget was
MyApp main.dart
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:vmembershipofficial/login/register.dart';
import 'package:vmembershipofficial/screens/home_screen.dart';
import 'login/login.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
Widget _getScreenId() {
return StreamBuilder<FirebaseUser>(
stream: FirebaseAuth.instance.onAuthStateChanged, //check if we are login
builder: (BuildContext context, snapshot) {
if (snapshot.hasData) {
return HomeScreen();
} else {
return LoginPage();
}
},
);
}
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
home: _getScreenId(),
debugShowCheckedModeBanner: false,
routes: {
HomeScreen.id: (context) => HomeScreen(),
RegisterPage.id: (context) => RegisterPage(),
},
);
}
}登录
import 'package:flutter/material.dart';
import 'package:vmembershipofficial/login/register.dart';
class LoginPage extends StatefulWidget {
LoginPage({Key key}) : super(key: key);
@override
_LoginPageState createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
backgroundColor: Color(0xff0D192A),
body: Container(
child: ListView(children: <Widget>[
Padding(
padding: EdgeInsets.all(10.0),
child: Container(
width: 120,
height: 120,
margin: EdgeInsets.fromLTRB(0, 50, 0, 0),
child: Image(
image: AssetImage("assets/images/vlogo.png"),
),
),
),
Padding(
padding: EdgeInsets.all(5.0),
child: Container(
margin: EdgeInsets.all(5.0),
child: Center(
child: Text(
"Login",
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold),
),
),
),
),
//TEXTFIELDS //
Padding(
padding: EdgeInsets.all(40.0),
child: Column(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width * 0.5,
height: MediaQuery.of(context).size.height * 0.5,
padding: EdgeInsets.all(5.0),
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(10),
),
child: Center(
child: Padding(
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Enter Your Email",
hintStyle: TextStyle(color: Colors.grey[400]),
)),
),
),
),
SizedBox(height: 20.0),
Container(
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.all(5.0),
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(10),
),
child: Center(
child: Padding(
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Enter Your Password",
hintStyle: TextStyle(color: Colors.grey[400]),
)),
),
),
),
SizedBox(height: 50),
InkWell(
onTap: () {
setState(() {});
},
child: Container(
height: 50,
decoration: BoxDecoration(
color: Color.fromRGBO(211, 184, 117, 100)),
child: Center(
child: Text(
"Login",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20),
),
),
),
),
SizedBox(height: 40),
Container(
height: 10,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Don't have an account?",
style: TextStyle(color: Colors.white, fontSize: 12.0),
),
SizedBox(width: 12.0),
InkWell(
onTap: () {
setState(
() {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => RegisterPage()),
);
},
);
},
child: Text(
"Register Here",
style: TextStyle(
color: Color.fromRGBO(211, 184, 117, 100),
fontSize: 12.0),
),
)
],
),
),
SizedBox(height: 10),
InkWell(
onTap: () {
setState(() {});
},
child: Container(
height: MediaQuery.of(context).size.height,
child: Column(
children: <Widget>[
Text(
"Forgot password?",
style: TextStyle(
color: Colors.white, fontSize: 12.0),
),
],
)),
),
],
),
),
]),
),
),
);
}
}主屏幕
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:vmembershipofficial/Widgets/afterintroducing.dart';
import 'package:vmembershipofficial/Widgets/discount_carousel.dart';
import 'package:vmembershipofficial/Widgets/header_carousel.dart';
import 'package:vmembershipofficial/Widgets/introducing_vmembership.dart';
class HomeScreen extends StatefulWidget {
static final String id = 'home_screen';
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
int _currentTab = 0;
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: ListView(
children: <Widget>[
Padding(
padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 10.0),
child: Text("Explore V!", style: TextStyle(fontWeight: FontWeight.w600, fontSize: 20.0),
),
),
SizedBox(height:5.0),
HeaderCarousel(),
SizedBox(height: 30.0),
Padding(
padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 10.0),
child: Text("Discount", style: TextStyle(fontWeight: FontWeight.w600, fontSize: 20.0),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 5.0),
child: Text("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", style: TextStyle(fontSize: 12.0),),
),
DiscountCarousel(),
SizedBox(height: 30.0),
Padding(
padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 10.0),
child: Text(
"Introducing V Membership Plus", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w600),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 4.0),
child: Text("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", style: TextStyle(fontSize: 12.0),),
),
VmembershipPlus(),
SizedBox(height: 30.0),
Padding(
padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 10.0),
child: Text(
"Lorem Ipsum", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w600),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 4.0),
child: Text("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", style: TextStyle(fontSize: 12.0),),
),
SizedBox(height: 10.0,),
AfterIntroducing(),
SizedBox(height: 10.0,),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 30.0),
child: FlatButton(
padding: EdgeInsets.all(15.0),
color: Colors.blue,
textColor: Colors.white,
onPressed: () {
},
child: Text(
"LOREM IPSUM",
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.w600),
),
),
),
SizedBox(height: 50.0,),
],
),
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: _currentTab, //makes a new variable called current Tab
onTap: (int value) {
setState(
() {
_currentTab = value;
},
);
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.search, size: 30.0),
title: Text('Search', style: TextStyle(fontSize: 12.0),),
),
BottomNavigationBarItem(
icon: Icon(Icons.favorite),
title: Text('Favorites', style: TextStyle(fontSize: 12.0),),
),
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('Home', style: TextStyle(fontSize: 12.0),),
),
BottomNavigationBarItem(
icon: Icon(Icons.message),
title: Text('Messages', style: TextStyle(fontSize: 12.0),),
),
BottomNavigationBarItem(
// icon: CircleAvatar(
// backgroundImage: NetworkImage(
// 'https://randomuser.me/api/portraits/men/31.jpg'),
// radius: 15.0,
// ),
icon: Icon(Icons.account_circle),
title: Text('Account', style: TextStyle(fontSize: 12.0),),
),
],
),
),
);
}
}寄存器
import 'package:flutter/material.dart';
import 'package:vmembershipofficial/services/auth_service.dart';
class RegisterPage extends StatefulWidget {
static final String id = 'register';
@override
_RegisterPageState createState() => _RegisterPageState();
}
class _RegisterPageState extends State<RegisterPage> {
final _formKey = GlobalKey<FormState>();
String _name, _email, _password;
_submit() {
if (_formKey.currentState.validate()) {
_formKey.currentState.save();
AuthService.signUpUser(context, _name, _email, _password); //
}
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
backgroundColor: Color(0xff0D192A),
body: Container(
child: ListView(
children: <Widget>[
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.all(20.0),
child: Container(
width: 120,
height: 120,
margin: EdgeInsets.fromLTRB(0, 50, 0, 0),
child: Image(
image: AssetImage("assets/images/vlogo.png"),
),
),
),
Padding(
padding: EdgeInsets.all(5.0),
child: Container(
margin: EdgeInsets.all(5.0),
child: Center(
child: Text("Register an Account",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20)),
),
),
),
Form(
key: _formKey,
child: Column(
children: <Widget>[
SizedBox(height: 20.0),
Padding(
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Text("Email Address",
style: TextStyle(
fontSize: 10.0,
color: Color(0xFFD3B875),),),
],
),
],
),
),
SizedBox(height: 10.0),
Container(
margin: EdgeInsets.fromLTRB(20, 0, 20, 0),
padding: EdgeInsets.all(1.0),
decoration: BoxDecoration(
color: Color(0xFFD3B875),
borderRadius: BorderRadius.circular(10),
),
child: Center(
child: Padding(
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
child: TextFormField(
decoration: InputDecoration(
border: InputBorder.none,
labelText: "Email Address",
labelStyle:
TextStyle(color: Colors.black),
),
validator: (input) => !input.contains("@")
? 'Please enter a valid email'
: null,
onSaved: (input) => _email = input,
),
),
)),
SizedBox(height: 20.0),
Padding(
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Text("Choose Password",
style: TextStyle(
fontSize: 10.0,
color: Color(0xFFD3B875),),),
],
),
],
),
),
SizedBox(height: 10.0),
Container(
margin: EdgeInsets.fromLTRB(20, 0, 20, 0),
padding: EdgeInsets.all(1.0),
decoration: BoxDecoration(
color: Color(0xFFD3B875),
borderRadius: BorderRadius.circular(10),
),
child: Center(
child: Padding(
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
child: TextFormField(
decoration: InputDecoration(
border: InputBorder.none,
labelText: "Password",
labelStyle:
TextStyle(color: Colors.black),
),
validator: (input) => input.length < 8
? 'Must be at least 8 characters'
: null,
onSaved: (input) => _password = input,
obscureText: true,
),
),
)),
SizedBox(height: 20.0),
Padding(
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Text("Choose a Name",
style: TextStyle(
fontSize: 10.0,
color: Color(0xFFD3B875),),),
],
),
],
),
),
SizedBox(height: 10.0),
Container(
margin: EdgeInsets.fromLTRB(20, 0, 20, 0),
padding: EdgeInsets.all(1.0),
decoration: BoxDecoration(
color: Color(0xFFD3B875),
borderRadius: BorderRadius.circular(10),
),
child: Center(
child: Padding(
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
child: TextFormField(
decoration: InputDecoration(
border: InputBorder.none,
labelText: "Name",
labelStyle:
TextStyle(color: Colors.black),
),
validator: (input) => input.trim().isEmpty
? 'Enter a valid name'
: null,
onSaved: (input) => _name = input,
),
),
)),
SizedBox(height: 50),
Container(
width: 250.0,
child: FlatButton(
onPressed: _submit,
color: Colors.blue,
padding: EdgeInsets.all(10.0),
child: Text(
'Sign Up',
style: TextStyle(
color: Colors.white,
fontSize: 18.0,
),
),
),
),
SizedBox(height: 40),
Container(
height: 20,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Already have an account?",
style: TextStyle(
color: Colors.white, fontSize: 12.0),
),
SizedBox(width: 12.0),
InkWell(
onTap: () {
setState(() {
Navigator.pop(
context,
MaterialPageRoute(
builder: (context) =>
RegisterPage()));
});
},
child: Text(
"Login Here",
style: TextStyle(
color: Color.fromRGBO(211, 184, 117, 100),
fontSize: 12.0),
),
)
],
),
),
],
),
),
],
)
],
),
),
),
);
}
}登录屏幕

热重加载错误--无论我是否更改了,都会发生这种错误

发布于 2019-12-18 06:57:01
我在飞镖上运行你的登录屏幕代码,这就是我得到的
您持有电子邮件TextField的容器占用了屏幕宽度和高度的50%。

我建议你把
width: MediaQuery.of(context).size.width * 0.5,
height: MediaQuery.of(context).size.height * 0.5,从你的容器里。
https://stackoverflow.com/questions/59385094
复制相似问题