Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Connect firebase with flutter app 2020

Connect Firebase With Flutter App 2020
Welcome to EasyCoding with Ammara
Subscribe My Coding Channel:
https://www.youtube.com/channel/UC8UsfNYmbKiRJvI9ZhhApEw?view_as=subscriber

Subscribe my personal YouTube Channel:

                                  Let's Start
See Video for Connection:


Create registration.dart file and paste code:

import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';

class Register extends StatefulWidget {
  @override
  _RegisterState createState() => _RegisterState();
}

class _RegisterState extends State {

  final fb = FirebaseDatabase.instance;
  var retrievedName="";
  String name = "";

  @override
  Widget build(BuildContext context) {
    final ref=fb.reference().child("Student");
    return Scaffold(
      appBar: AppBar(
        title: Text("Registration"),
      ),
      body: Container(
        child: Column(
          children: [
            Padding(
              padding: const EdgeInsets.all(10.0),
              child: Text(
                'Name',
                style: TextStyle(
                  fontSize: 20,
                  fontWeight: FontWeight.bold,
                  shadows: [Shadow(
                    blurRadius: 10,
                    color: Colors.blue,
                  )]
                ),
              ),
            ),
            Flexible(child: TextField(
              onChanged: (val){
                setState(() {
                  name=val;
                });
              },
            )),
            RaisedButton(
              onPressed: (){
                ref.child("name").set(name);
              },
              child: Text("Registration"),
            ),
            RaisedButton(
              onPressed: (){},
              child: Text("Retrieve data"),
            ),
            Text("EasyCoding"),
          ],
        ),
      ),
    );
  }
}



This post first appeared on AR Programming, please read the originial post: here

Share the post

Connect firebase with flutter app 2020

×

Subscribe to Ar Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×