Hi Guys, Welcome to Proto Coders Point, In this Flutter Tutorial we will Implement Flutter Registration and Login page using Firebase Authentication Flutter.
In both the Registration and Login pages we have 2 Flutter TextField and an materialButton, when clicked perform an Registration or Login task.
It also has a Modal Progress HUD flutter library which will show registering or login wait progress indicatorwhen button is click until the authentication process.
Adding Flutter Firebase Dependencies into our project
Here we have created an FirebaseAuth instance that can handle creating new users with their email and password. And once user get registered successfully we navigate the user to login Screen.
Login Snippet Code of Flutter Firebase
final _auth = FirebaseAuth.instance;
String email, password;
try {
final newUser = await _auth.signInWithEmailAndPassword(
email: email, password: password);
if (newUser != null) {
//successfully login
//navigate the user to main page
// i am just showing toast message here
}
} catch (e) {}
Here we make user of signInWithEmailAndPassword firebase class method to help the user to Log-In into our Flutter Application.
Complete Source Code for Flutter Login and Registration Page using Firebase Authentication
All set you Flutter App is now been integrated with Firebase Authentication Service, your Flutter app can now handle Login and Registration using Firebase services.
Hi Guys, Welcome to Proto Coders Point , In this Tutorial we are going to add Firebase Integration in Flutter Project.
To make user of Firebase Services in our Flutter Application, We must add Firebase SDK and Required Dependencies in our Flutter Project.
Let’s Integrate Firebase with Flutter Application by Following below steps.
VIDEO TUTORIAL
Step1 : Create a new Flutter Project in android Studio
As usually you need to Create a new Flutter Project in your android-studio.
File > New > New Flutter Project
Step 2 : Create a new Firebase Project in firebase Console.
Go to Firebase console Sign-In with your Google Account, you will see and cardView to add new Firebase Project, Just Click on it
1. Give a name to your project in Firebase Console.
2. Configure Google Analytic Give some name, Agree the Form and Continue.
Just Configure the Google Analytic and accept all the Agreement Form and Continue to next process.
Then, Firebase Proejct for your flutter app is successfully been created now hit the continue button.
Step 3 : Get Started by adding Firebase to your app
Their are 4 platform where you are integrate your Flutter project with Firebase as backend.
iOS, Android, Web and Unity development. In this Tutorial we are integrating Firebase with Flutter Application Development ( Android )
So Just Click on Android Icon if you want to integrate Firebase into your flutter android part.
Step 4: Add Firebase to your Android Project.
1. Android Package Name
Navigate / Open build.gradle > search for applicationId ” ………………..” and Click next.
On the right side you will see your flutter project under the project extend android > app >build.gradle scroll-down and search for applicationId and Copy the Id also knows as packageName
Then you have copyed your AppID, come back to firebase console and paste the AppID and hit Next button thus firebase can generate a json file for your application google_services.json.
2. Adding Google_services.json file
Download Config File Genarated by Firebase copy the file and add it to your project under
Your Project Name > Android > app folder
Step 5 : Add Firebase SDK to your Project
1. Project-Level build gradle
Add Google Service Dependencies
Open Project Level Build gradle your project > android > build.gradle and add the classpath of google services in dependencies.
Open App Level Build gradle your project > android > app > build.gradle and add the implemention of google analytics in dependencies.
dependencies {
......
......
.....
implementation 'com.google.firebase:firebase-analytics:17.2.0' // add this line
}
apply plugin: 'com.google.gms.google-services' // add this line at the botton
Here you go Firebase is added successfully been added in you android section of your flutter project.
Now Once we have added our Flutter project in firebase console, Now it’s time to incorporate the flutter Package that will allow us to work with firebase using dart programming
Hi Guys, Welcome to Proto Coders Point In this Android Tutorial we will Learn about Android AsyncTask and Learn How to Fetch JSON data using AsyncTask and Handle them.
Final Project Result
What is AsyncTask ?
In android, AsyncTask is been used to run any process that should be run in background and likewise update the UI(User Interface).
Mainly AsyncTask is used to fetch data from a server and this will not effect our main Thread that is handling UI.
AsyncTask ( Asynchronous Task) Help you n running the background Process which will create a seperate Thread to run in background and then Synchronize again with the main Thread, This process will not disturb the main Thread and UI process will run smoothly.
To Execute AsyncTask you need to called Execute() method.
The Flow of AsyncTask Process
When AsyncTask class is executed onPreExecute() is called then doInBackground() is called to execute background processed and at last onPostExecute() method is called to update the data to UI.
Syntax of AsyncTask:
private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
@Override
protected void onPreExecute() {
super.onPreExecute();
// mostly used to show progress dialog
// display a progress dialog for good user experiance
}
@Override
protected Long doInBackground(URL... urls) {
// code that will run in the background
return ;
}
@Override
protected void onProgressUpdate(Integer... progress) {
// receive progress updates from doInBackground
}
@Oveerride
protected void onPostExecute(Long result) {
// update the UI after background processes completes
}
}
Here is How to execute AsyncTask class from main Thread
new DownloadFilesTask().execute();
Android AsyncTask Example Handling JSON and parse JSON
In the Below Example of AsyncTask We are performing a network operation, where we gonna fetch data from JSON File and Display them in our UI.
A Sliver AppBar in Flutter is similar to any normal AppBar, The Different here is only that Sliver AppBar come with ScrollView effect.
The Sliver App bar should be the first child of a CustomScrollView, Using with we can integrate the appbar with a scroll view so that it can vary in height and other content of the scrollview.
Implementation with Sliver AppBar Widget
Below Examples will show you how appbars can we integrated with different configurations and act with different behaviour when any user Scrolls the View up or down.
The Code base for this to work is very simply in the above lined of code you just need to change floating to true and pinned to true, this Configuration will simple pin the app bar at the top of the screen when used scroll through the app and other remaining widget will simple scroll to the end.
1. As i said before that Sliver App bar must be the child of CustomScrollView to get Scrolling effect, The CustomScrollView will make the SliverAppBar into Scrolling.
2. Here i have Used an IconButton just to Show that you can even add IconButton Widget into the Appbar. i’e IconButton, which is used with actions to show buttons on the app bar.
Flexible SpaceBar is used so that we can easily set and maximum expandable size to it when user scroll the app Down-words,
And Even we can set many other properties like background,title etc
SliverFillRemaining that fills the remaining space in the viewport. In Other words The Remaining body should not be null, is the Remaininig body is null then the app bar scrollview will not work as accepted, this value cannot be null.
So i have just Defined some widget in the remaining part in Sliver Fill Remaining
which has a child which is set to center , in turn has a child Column, then This Column have 3 children widget Image,SixedBox,and a Text.
Snippet Code
SliverFillRemaining(
child: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset('images/protocoderspointlogo.png'),
SizedBox(
height: 20.0,
),
Text(
"This is an Simple Sliver App Bar Flutter Example",
style:
TextStyle(fontSize: 15.0, fontWeight: FontWeight.w800),
),
],
),
),
)
Complete Source code of Flutter Sliver App Bar – An Collapsing ScrollView App Bar
main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: NewPage(),
);
}
}
class NewPage extends StatefulWidget {
@override
_NewPageState createState() => _NewPageState();
}
class _NewPageState extends State<NewPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
expandedHeight: 150.0,
floating: true,
pinned: true,
snap: true,
actions: <Widget>[
IconButton(
icon: const Icon(Icons.add_circle),
onPressed: () {},
),
],
flexibleSpace: FlexibleSpaceBar(
title: Text(
"Sliver App Bar Example",
style: TextStyle(fontSize: 15),
),
background: Image.asset(
'images/images.jpeg',
fit: BoxFit.cover,
),
),
),
SliverFillRemaining(
child: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset('images/protocoderspointlogo.png'),
SizedBox(
height: 20.0,
),
Text(
"This is an Simple Sliver App Bar Flutter Example",
style:
TextStyle(fontSize: 15.0, fontWeight: FontWeight.w800),
),
],
),
),
)
],
),
);
}
}
Hi Guys, Welcome to Proto Coders Point , In this Tutorial is all about a flutter Widget Library known as Modal Progress HUD, By the use of this library we can show a Circular Progress Indicator in our flutter Applications.
Demo on Progress Indicator
Modal Progress hud
In flutter progress indicator is an simple widget that is been wrap into other flutter widgets to enable modal progress indicator.
Here HUD stands for Heads Up Display.
let’s go straight into implementation of Flutter Circular Progress Indicator
Installation of Modal Progress HUD in our Flutter Project
To user this Package as a library
You need to add the required package’s dependencies into pubspec.yaml file
dependencies:
modal_progress_hud: ^0.1.3
Then, just click on Package Get
The above library of flutter circular progress indicator dependencies library version may update so to get latest version visit official site here.
Now you can use them by importing wherever required.
Importing the flutter progress indicator package wherever required
After importing the library in the required flutter page (main.dart)
Now, all you have to do is simply wrap your widget as a child of ModalProgressHUD, typically a form, together with a boolean that is maintained in local state.
Snippet Example Code
class _MyHomePage2State extends State<MyHomePage2> {
bool show=false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Progress Indicator Example"),
),
body: ModalProgressHUD(
inAsyncCall: show, // here show is bool value, which is used to when to show the progess indicator
child: Column(
children: <Widget>[
Text(" Modal Progress Indicator ")
],
),
),
);
}
}
inAsyncCall : Accepts boolean type value, by setting this to true we can show the progress indicator in our flutter application.
The current parameters are customizable in the constructor