Skip to content

Instantly share code, notes, and snippets.

"-M0FJ-WJXYDS-TPehYzV" : {
"age" : "4",
"name" : "shadow",
"type" : "Cats"
},
"-M0FJLC6he0Qh9fVY9LV" : {
"age" : "7",
"name" : "max",
"type" : "Dogs"
}
void main() {
var response =
{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjIxMDcxNjg1XATLkHM3-LSmHBpY-_ER_eDcsQnHGKKmLXjHpBevyRW2HvOeWD4zbnlkoZwiL23"};
print(response["token"]);
}
dependencies:
firebase_core: ^0.5.0+1
firebase_database: ^4.1.1
firebase_auth: ^0.18.1+2
splashscreen : 1.2.0
flutter_signin_button: ^1.0.0
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
class IntroScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
User result = FirebaseAuth.instance.currentUser;
return new SplashScreen(
navigateAfterSeconds: result != null ? Home(uid: result.uid) : SignUp(),
seconds: 5,
title: new Text(
'Welcome To Meet up!',
style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: <
Widget>[
Padding(
padding: EdgeInsets.all(10.0),
child: Text("Meet Up",
final _formKey = GlobalKey<FormState>();
FirebaseAuth firebaseAuth = FirebaseAuth.instance;
DatabaseReference dbRef = FirebaseDatabase.instance.reference().child("Users");
TextEditingController emailController = TextEditingController();
TextEditingController nameController = TextEditingController();
TextEditingController passwordController = TextEditingController();
TextEditingController ageController = TextEditingController();
return Form(
key: _formKey,
child: SingleChildScrollView(
child: Column(children: <Widget>[
Padding(
padding: EdgeInsets.all(20.0),
child: TextFormField(
controller: nameController,
decoration: InputDecoration(
labelText: "Enter User Name",
child: ElevatedButton(
style: ButtonStyle(backgroundColor: MaterialStateProperty.all<Color>(Colors.lightBlue)),
onPressed: () {
if (_formKey.currentState.validate()) {
registerToFb();
}
},
child: Text('Submit'),
),
void registerToFb() {
firebaseAuth
.createUserWithEmailAndPassword(
email: emailController.text, password: passwordController.text)
.then((result) {
dbRef.child(result.user.uid).set({
"email": emailController.text,
"age": ageController.text,
"name": nameController.text
}).then((res) {