1
Good morning, I am creating a login screen with email authentication and password by firebase. Some layout rendering errors are happening.
this is the code:
import 'package:flutter/material.dart';
import 'package:loja_virtual/models/user_model.dart';
import 'package:scoped_model/scoped_model.dart';
class FormContainer extends StatelessWidget {
final _emailController = TextEditingController();
final _passController = TextEditingController();
final _formKey = GlobalKey<FormState>();
final _scaffoldKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
body: ScopedModelDescendant<UserModel>(
builder: (context, child, model) {
if (model.isLoading)
return Center(child: CircularProgressIndicator(),);
return Container(
margin: EdgeInsets.symmetric(horizontal: 20),
child: Form(
key: _formKey,
child: Column(
children: <Widget>[
TextFormField(
style: TextStyle(
color: Colors.white),
controller: _passController,
decoration: InputDecoration(
hintStyle: TextStyle(color: Colors.white,fontFamily: "WorkSansLight", fontSize: 18.0),
filled: true,
fillColor: Colors.white24,
hintText: "E-mail",
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(90.0)),
borderSide: BorderSide(color: Colors.white24, width: 0.5)),
prefixIcon: const Icon(
Icons.email,
color: Colors.white,
),
),
keyboardType: TextInputType.emailAddress,
validator: (text){
if(text.isEmpty || !text.contains("@")) return "E-mail inválido!";
},
),
SizedBox(height: 16.0,),
TextFormField(
style: TextStyle(
color: Colors.white),
controller: _passController,
decoration: InputDecoration(
hintStyle: TextStyle(color: Colors.white,fontFamily: "WorkSansLight", fontSize: 18.0),
filled: true,
fillColor: Colors.white24,
hintText: "Senha",
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(90.0)),
borderSide: BorderSide(color: Colors.white24, width: 0.5)),
prefixIcon: const Icon(
Icons.lock_outline,
color: Colors.white,
),
),
obscureText: true,
validator: (text){
if(text.isEmpty || text.length < 6) return "Senha inválida!";
},
),
Align(
alignment: Alignment.centerRight,
child: FlatButton(
onPressed: (){
if(_emailController.text.isEmpty)
_scaffoldKey.currentState.showSnackBar(
SnackBar(content: Text("Insira seu e-mail para recuperação!"),
backgroundColor: Colors.redAccent,
duration: Duration(seconds: 2),
)
);
else {
model.recoverPass(_emailController.text);
_scaffoldKey.currentState.showSnackBar(
SnackBar(content: Text("Confira seu e-mail!"),
backgroundColor: Colors.purple,
duration: Duration(seconds: 2),
)
);
}
},
child: Text("Esqueci minha senha",
textAlign: TextAlign.right,
style: TextStyle(color: Colors.white, fontSize: 15.0),
),
padding: EdgeInsets.zero,
),
),
SizedBox(
height: 16,
),
SizedBox(
height: 80,
width: 80,
child: new FloatingActionButton(
backgroundColor: Colors.white30,
child: Text(
"Entrar",
style: TextStyle(
fontSize: 18.0,
),
),
onPressed: () {
if (_formKey.currentState.validate()) {
}
model.signIn(
email: _emailController.text,
pass: _passController.text,
onSuccess: _onSuccess,
onFail: _onFail
);
},
),
),
],
),
),
);
},
)
);
}
void _onSuccess() {
// Navigator.of(context).pop(); Esta dando erro
}
void _onFail() {
_scaffoldKey.currentState.showSnackBar(
SnackBar(content: Text("Falha ao Entrar!"),
backgroundColor: Colors.redAccent,
duration: Duration(seconds: 3),
)
);
}
}
These are the mistakes:
I/flutter ( 4207): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 4207): The following assertion was thrown during performLayout():
I/flutter ( 4207): RenderCustomMultiChildLayoutBox object was given an infinite size during layout.
I/flutter ( 4207): This probably means that it is a render object that tries to be as big as possible, but it was put
I/flutter ( 4207): inside another render object that allows its children to pick their own size.
I/flutter ( 4207): The nearest ancestor providing an unbounded height constraint is:
I/flutter ( 4207): RenderIndexedSemantics#dc596 relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT
I/flutter ( 4207): creator: IndexedSemantics ← NotificationListener<KeepAliveNotification> ← KeepAlive ←
I/flutter ( 4207): AutomaticKeepAlive ← SliverList ← SliverPadding ← Viewport ← IgnorePointer-[GlobalKey#aaf31] ←
I/flutter ( 4207): Semantics ← Listener ← _GestureSemantics ←
I/flutter ( 4207): RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#1430c] ← ⋯
I/flutter ( 4207): parentData: index=0; layoutOffset=0.0 (can use size)
I/flutter ( 4207): constraints: BoxConstraints(w=360.0, 0.0<=h<=Infinity)
I/flutter ( 4207): semantic boundary
I/flutter ( 4207): size: Size(360.0, Infinity)
I/flutter ( 4207): index: 0
I/flutter ( 4207): The constraints that applied to the RenderCustomMultiChildLayoutBox were:
I/flutter ( 4207): BoxConstraints(0.0<=w<=360.0, 0.0<=h<=Infinity)
I/flutter ( 4207): The exact size it was given was:
I/flutter ( 4207): Size(360.0, Infinity)
This is the login screen:
The screen like this: error is not showing the texts and the button to log in
Usually I shoot component by component, starting at the bottom of the tree. So you can know which widget is causing the problem.
– vinibrsl