Created
February 24, 2020 07:21
-
-
Save shafinr23/5f3b96b9e739b01847ce03a597c7072e to your computer and use it in GitHub Desktop.
showing a error in registerpage in fierbase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:firebase_auth/firebase_auth.dart'; | |
import 'package:flash_chat/components/paddingButton.dart'; | |
import 'package:flash_chat/constants.dart'; | |
import 'package:flash_chat/screens/chat_screen.dart'; | |
import 'package:flutter/material.dart'; | |
class RegistrationScreen extends StatefulWidget { | |
static const String id = '/registration'; | |
@override | |
_RegistrationScreenState createState() => _RegistrationScreenState(); | |
} | |
class _RegistrationScreenState extends State<RegistrationScreen> { | |
final _auth = FirebaseAuth.instance; | |
String email; | |
String password; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
backgroundColor: Colors.white, | |
body: SingleChildScrollView( | |
child: Padding( | |
padding: EdgeInsets.symmetric(horizontal: 24.0), | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
crossAxisAlignment: CrossAxisAlignment.stretch, | |
children: <Widget>[ | |
Hero( | |
tag: 'logo', | |
child: Container( | |
height: 200.0, | |
child: Image.asset('images/logo.png'), | |
), | |
), | |
SizedBox( | |
height: 48.0, | |
), | |
TextField( | |
keyboardType: TextInputType.emailAddress, | |
textAlign: TextAlign.center, | |
onChanged: (value) { | |
email = value; | |
}, | |
decoration: kTextFieldDecration.copyWith( | |
hintText: ' Enter your Email', | |
), | |
), | |
SizedBox( | |
height: 8.0, | |
), | |
TextField( | |
obscureText: true, | |
textAlign: TextAlign.center, | |
onChanged: (value) { | |
password = value; | |
}, | |
decoration: kTextFieldDecration.copyWith( | |
hintText: ' Enter your PassWord', | |
), | |
), | |
SizedBox( | |
height: 24.0, | |
), | |
PaddingButton( | |
name: 'Register', | |
colors: Colors.blueAccent, | |
press: () async { | |
// print(email); | |
// print(password); | |
try { | |
final newUser = await _auth.createUserWithEmailAndPassword( | |
email: email.trim(), password: password.trim()); | |
if (newUser != null) { | |
Navigator.pushNamed(context, ChatScreen.id); | |
} | |
} catch (e) { | |
print(e); | |
} | |
}, | |
), | |
], | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment