Step 4 : Specifying the Google API key in AndroidManifest.xml ( ANDROID )
open AndroidManifest.xml file and add the <meta-data> tag inside <application> tag
<manifest ...
<application>
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="YOUR KEY HERE"/> // add this line and replace with you API KEY
</application>
</manifest>
Step 5: Specifying API key in AppDelegate.swift ( for iOS)
in iOS you need to Specify Application delegates to make use of google maps services in IOS
To do so navigate ios/Runner/AppDelegate.swift
import UIKit
import Flutter
import GoogleMaps // add this line
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GMSServices.provideAPIKey("YOUR KEY HERE") // add this line replace with your API KEY
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
mapType: Specify which kind of map interface do you want to load.
normal.
satellite.
hybrid.
terrain.
initialCameraPosition: This will load the map with initial camera position may be currect location of the users.
onMapCreated: this will create a map with complete controls to the map you can zoom in, zoom out, go to other location in the map and many things under your controls.
Login and Registration form in android using volley
Hi Guys, Welcome to Proto Coders Point, In this android tutorial we will create an android login and Registration form using volley library and phpmyadmin as my database server.
How to keep user logged in android?
In this Android Project i am making used of sharedPreferences to store data of successful logged in uses so that we can keep the user logged in until the user manually logout himself.
Things required for this android mini project.
1. A server: with phpmyadmin installed for database holding.
2. A Hosting: where we will store our server code (.php codes)
3. Android Studio
In this Android Mini Project we gonna make use of Volley Library to Store and Retrieve data form database server using php codes.
Let’s begin creating login and registration form in android studio using volley library
Create a new Android project in android studio
Then, Let’s add the required dependencies in our android project.
Create a new directory named ‘xml‘ under res directory
right click on res > New > Directory > name it as 'xml'
Now under xml folder/directory create a new XML resource file named “network_security_config.xml” and Copy Page the below lines of network confiq code.
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">protocoderspoint.com</domain> //here replace with you localhost server or your domain name
</domain-config>
</network-security-config>
Here you need you replace protocoderspoint.com with your localhost ip address or with your domain address.
Adding Internet Permission
Then, Open AndroidManifest.xml and add the <uses-permission INTERNET />
OK, Now all the basic requirement for this android project is been added.
Login & Registration form in android using volley library.
For this project we need total 3 Activitys and 3 xml files
1. RegistrationActivity
The RegistrationActivity is where user will be able to register himself to get access for the further feature of any android application
2. LoginActivity
After the user Successfully register himself with the app, now a the user is the part of our application services and his data is registered with us in our phpmyadmin database, now the user can easily Login through the app using his login credential.
3. MainActivity
MainActivity is somewhat like any application home page or dashboard.
UI DESIGN for Login, Registration and MainActivity
button_design.xml
create a new Drawable Resource file in drawable folder and name it as button_design.xml and add the following code.
Here is java Volley Snippet code that is used to send and receive data from server.
private void Register()
{
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL_REGISTER,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try{
// after success response from server
} catch (Exception e) {
// if any exception is been cought
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// if server fails to response on time
}
})
{
@Override
protected Map<String, String> getParams() {
Map<String,String> params = new HashMap<>();
// params.put("name",sname); // passing parameters to server
return params;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
The above snippet code is how we send data from application to server and how to deal with the server response.
Here Request.Method.POST describle which Method we gonna use to store or retrieve either GET or POST.
URL_REGISTER : This is the url where out server side code is been kept, for example a url path to the server code.
JAVA CODE for Login,Registration using volley
RegistrationActivity.java
Just change the URL_REGISTER link with your file hosting server path
if you are in localhost your path may be as below :
Hi Guys, Welcome to Proto Coders Point, In this Flutter Tutorial we will integrate Flutter library called Email Validator to validate email address.
Email Validation
Usually Email Validation is done, by a String value that contains alphabets, @ symbols and a .(dot) symbol
For Example: contact@protocoderspoint.com, This email address contains all the characters required to be a perfect/valid email address.
Flutter Email Validation Library
Flutter Comes with awesome and easy to use flutter Library/Plugins. This Email validation flutter library is pre defined class that validated email addresses. You just need to call its class.
This plugin is very easy to use and understand. Visit official site to learn more here
Let’s start adding the library in our Flutter Project.
Adding Dependencies in our project
Open Pubspec.yaml and add the dependencies
dependencies:
email_validator: ^1.0.4 // add this line
Import the email validator dart class
you need to import the email_validator.dart file, where you want to make use validator library.
In my case i have imported it in main.dart file
const String email = 'contact@protocoderspoint.com';
final bool isValid = EmailValidator.validate(email);
print('Email is valid? ' + (isValid ? 'yes' : 'no'));
The above code is snippet code,
Their is a string that holds email address, a boolen type variable that stored true or false based on email address, is the email is valid it will store true else false.(isValid ? ‘yes’ : ‘no’) : is similar to if else statement.
Complete code on Email Validation in flutter
In my flutter project i have 2 dart files.
main.dart is with TextFormField() where we will check if email is valid, if entered email is valid that the user will be navigated to page2.dartmain.dart
Copy paste the below code in main.dart
Hi Guys, Welcome to Proto Coders Point, In this Flutter Tutorial we will learn how to use SQLITE in Flutter.
What is SQLite ?
SQLite is a Database Library that provides a relational database management system(RDBMS). Here Lite means a very light weight process in term of setup or administration.
Sqlite have very awesome feature : Zero Configuration, Transactional management, Serverless database support and much more.
Flutter SQLite is very small as small as 400kb in size.
SQLite Source code is open for all the developers any one can use then to develop a data storage.
Now a day’s SQLite are mostly use in storing data locally
For Example : A user plays a games with is completely offline, So all Hs data will be stored in SQLITE DATABASE Locally.
Let’s Start adding the Required Dependencies into our Flutter Project.
Flutter Sqflite library Adding dependencies
Step1: Open Pubspec.yaml file and add dependencies
dependencies:
sqflite: ^1.3.0 // add this line
NOTE : Latest feature might get added in this flutter plugin so better check out official site for latest version.
Step2: Import Sqlite dart file
Once you have added the dependencies, Now you can easily user the sqlite packages in your flutter project by just importing the dart file.
import 'package:sqflite/sqflite.dart';
How to create a Sqlite Database in Flutter?
Opening a database
Get location of database using getdatabasepath() method.
var databasesPath = await getDatabasesPath();
String path = join(databasesPath, 'student.db');
var db = await openDatabase(path);
here path is a string variable where our database path is been stored.
Closing database which is open.
await db.close();
Opening the database and creating a new TABLE in it.
Database database = await openDatabase(path, version: 1,
onCreate: (Database db, int version) async {
await db.execute(
'CREATE TABLE USER (id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT, ID INTEGER)');
});
Here in above example i have opened the database and created a new table called as USER.
Ok Now let’s implement SQFLite in our Flutter Application
Flutter Sqlite Tutorial with INSERT, UPDATE and DELETE Option.
Create a new Dart file which is actually an SQLITE_DBHelper
And there your app is ready to open a datebase/ create a new database , create a new table and store all the data in it and even delete or update the present data base using Sqflite flutter library.
Hi Guys, Welcome to Proto Coders Point, In this Flutter Tutorial we gonna implement datetime picker flutter library.
Brief about date time picker library
A date time picker is a widget library using which your flutter app user can easily select date or time.
This library comes with different set of languages :
Some of them are : Arabic(ar), Armenian(hy) , Azerbaijan(az) ,Chinese(zh) , Dutch(nl) ,English(en) and much more ( Visit official site to know more ).
Ok then Let’s start implementing the date time library in our flutter project.
Step 1: Add the Dependencies
Navigate towords / open pubspec.yaml
Then add the following date time picker dependencies, what this does it that it downloads all the required packages into our flutter project as External Libraries.
dependencies:
flutter_datetime_picker: ^1.3.5 //add this line
Then, after adding the dependencies just click on Packages Get.
Step 2: Import the package
once you have added dependencies all the package will be stored in external libraries if you want to use them you need to import the required package
For example : if you want to use the library in main.dart file you need to import it.
Hi Guys, Welcome to Proto Coders Point, In this Flutter tutorial we gonna learn how to use the image picker flutter library a package that helps getimage/flutter pick images from a gallery or camera.
Image Picker flutter library
A Flutter Plugin library for both iOS and Android that is been used to pick an images from mobile phone gallery or even you can take a new photo with the camera.
let’s straight away start implement the flutter image picker in our flutter app.
find the latest version of Image picker from official site.
VIDEO TUTORIAL
Step 1: Adding image picker dependency flutter in to our flutter project
Once you have created a new Flutter project or open your existing flutter project to implement image picker flutter library.
Then you need to add image picker dependencies,
Open pubspec.yaml then add the below lines
dependencies:
image_picker: ^0.6.3+4 //add this line in pubspec.yaml file
Step 2: Import image_picker.dart file in main.dart
Now, as you have added the required library in your project now you need to import the picker library wherever required.
import 'package:image_picker/image_picker.dart';
For Example : In my case i have imported the library in main.dart file whcih is my main activity screen.
Step 3: Configuration
1. ANDROID IMAGE PICKER CONFIGURATION
When it comes to android their is no configuration required – the plugin should work out of the box.
Just we need to set request Legacy External Storage to true Android > app > src > main >AndroidManifest.xml
By adding the above request Legacy External Strorage the app will auto ask user to grant permission to make use of storage.
2. IOS IMAGE PICKER CONFIGURATION
Add the following keys to your Info.plist file, located in
Project > ios > Runner > Info.plist
Copy paste the below permission in info.plist
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires read and write permission Photo Library</string>
used to ask uses to give permission for accessing photo library. This is Called Privacy – Photo Library Usage Description.
<key>NSCameraUsageDescription</key>
<string>This app requires read and write permission from the user.</string>
Used to take photo from device camera itself.
<key>NSMicrophoneUsageDescription</key>
<string>This app requires get access to micro phone</string>
if you intend to record an video by using camera, video offcourse need audio to be recorded, this permission is used to record audio from microphone.
Step4 : Explaination of Image Picker snippet code
File _image; //here we gonna store our image.
var image = await ImagePicker.pickImage(source: ImageSource.gallery);
Then, Here we are using ImagePicker Class to pick images from ImageSource.
var image = await ImagePicker.pickImage(source: ImageSource.camera);
Here, ImageSource can either be camera or gallery.
Camera is you want to click a image from device camera.
Gallery is you want to pick/select image from gallery of mobile phone.