Search This Blog

Sunday, February 17, 2019

Android - GPS Location and Address with new google map API in kotlin.

Today, mobile phones are more powerful that offers GPS Location to users in mobile applications. To use GPS location and google map, the Android SDK offers the location API that is updated by the Android SDK development team day by day for optimizing mobile battery life and other aspects. Android location APIs make a location-aware application, without needing to focus on the details of the location technology.

GPS location tracker works with the help of Google Play services, which facilitates adding location awareness to an application with automated location tracking, geofencing, and activity recognition that returns a location object. The location object represents a geographic location which consists of latitude, longitude, timestamp, and other information.


Saturday, February 9, 2019

Flutter - No connected devices.

flutter no device connected
To develop a mobile application, we always need a testing real device or Android Emulator device to test developed features. In this post, we going to share some tips to connect a device with a development IDE. Maybe this is very useful for those people facing device connectivity problem. So here, we have some tips that you can use to resolve it.


Sunday, February 3, 2019

Flutter - Equivalent of RelativeLayout in Flutter

If you have worked with native Android application development. Then you definitely know about the Relative Layout. The Relative Layout is a very flexible layout that used for custom layout designing. It gives us the flexibility to position a view based on the relative or sibling component’s position.
flutter relative layout alternative widget
In Flutter, we can design a screen with the help of StatelessWidget and StateFulWidget. So, if you are thinking such kind of layout in Flutter. Then you can use Column, Row and Stack widgets to design your application screen in Flutter. Flutter layouts are usually built using a tree of these widgets. These widgets take constructor arguments that specify rules for how the children are laid out relative to the parent, and you can also influence the layout of individual children by wrapping them in Expanded, Flexible, Positioned, Align, or Center widgets that are explained here


Monday, January 28, 2019

Android - Introduction and Example of Jetpack Navigation Architecture.

Today, All mobile application contains more than one screens to provide all necessary feature to the end users. Like user can move from splash screen to home screen.

From this home screen, the user can perform other tasks that show a result in other screens. These screens will usually take the form of activity and fragment within the app. An end user can navigate on all other screens with the help of screen gestures, button clicks, and menu selections. All of the work involved in navigation between destinations and stack that is handled by a navigation controller. Without navigation, we have to write a very big manual code to move from one screen to another screen that creates complex navigation paths.

Saturday, January 19, 2019

Flutter - GET and POST http requests

To get dynamic data in a mobile application. We need to connect with a server to get and post some data. To achieve it, we always use HTTP to perform curl requests and create a connection between applications and server at a certain period to send or receive the data request from an application to the server.

Flutter providing us http to connect a mobile application with a server to perform GET, POST and other requests. POST and GET are two most commonly used HTTP methods for request and response between the client and the server. GET method basically requests data from a specified resource, whereas Post method submits data to be processed to a specified resource.

In this post,  we are going to learn about HTTP/HTTPS POST & GET Requests. We'll see, how can get data from the server with the help of a utility class that we have created to perform GET and POST in this sample. In this example, we'll get movie list from themoviedb. We have generated a testing key from here. To run the following sample we have to create it. So create it before start development. The final output of this post example will look like below. When you'll create project with the help of following steps. 

Let's start the development of this sample with the help of following steps:

Creating a new Project
1. Create a new project from File ⇒ New Flutter Project with your development IDE.

2. Open pubspec.yaml file and add following dependancies

 http: ^0.12.0
 transparent_image: ^0.1.0

3. After that open main.dart file and edit it. As we have set our theme and change debug banner property of Application. This is our main widget of the example. Here, we have created a grid list widget to display a list of search movies and we have created an instance of MovieApi() to get a list of items from the server.
import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_movies/netwoklayer/movie.dart'; import 'package:flutter_movies/netwoklayer/movie_api.dart'; import 'package:transparent_image/transparent_image.dart'; void main() => runApp(new MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( debugShowCheckedModeBanner: false, theme: new ThemeData( primaryColor: const Color(0xFF02BB9F), primaryColorDark: const Color(0xFF167F67), accentColor: const Color(0xFFFFAD32), ), home: new MainPage(), ); } } class MainPage extends StatefulWidget { const MainPage(); @override _MainPageState createState() => new _MainPageState(); } class _MainPageState extends State<MainPage> with SingleTickerProviderStateMixin { static final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>(); GuestUserApi _movieApi; TextEditingController _searchQuery; bool _isSearching = false; String searchQuery = "Search query"; List<Movie> files = new List(); @override void initState() { super.initState();
//instacne of API manager
 _movieApi=new MovieApi(); _searchQuery = new TextEditingController(); } void _startSearch() { print("open search box"); ModalRoute .of(context) .addLocalHistoryEntry(new LocalHistoryEntry(onRemove: _stopSearching)); setState(() { _isSearching = true; }); } void _stopSearching() { _clearSearchQuery(); setState(() { _isSearching = false; }); } void _clearSearchQuery() { print("close search box"); setState(() { _searchQuery.clear(); updateSearchQuery("Search query"); }); } Widget _buildTitle(BuildContext context) { var horizontalTitleAlignment = Platform.isIOS ? : CrossAxisAlignment.start; return new InkWell( onTap: () => scaffoldKey.currentState.openDrawer(), child: new Padding( padding: const EdgeInsets.symmetric(horizontal: 12.0), child: new Column( mainAxisAlignment:, crossAxisAlignment: horizontalTitleAlignment, children: <Widget>[ new Text('Seach box',style: new TextStyle(color: Colors.white),), ], ), ), ); } Widget _buildSearchField() { return new TextField( controller: _searchQuery, autofocus: true, decoration: const InputDecoration( hintText: 'Search...', border: InputBorder.none, hintStyle: const TextStyle(color: Colors.white), ), style: const TextStyle(color: Colors.white, fontSize: 16.0), onChanged: updateSearchQuery, ); } Future updateSearchQuery(String newQuery) async { setState(() { searchQuery = newQuery; }); print("search query " + newQuery); if(newQuery.length>2){ var search = await; setState(() { files.clear(); files.addAll(search.list); }); } } List<Widget> _buildActions() { if (_isSearching) { return <Widget>[ new IconButton( icon: new Icon(Icons.clear,color: Colors.white,), onPressed: () { if (_searchQuery == null || _searchQuery.text.isEmpty) { Navigator.pop(context); return; } _clearSearchQuery(); }, ), ]; } return <Widget>[ new IconButton( icon: const Icon(,color: Colors.white,), onPressed: _startSearch, ), ]; } @override Widget build(BuildContext context) { return new Scaffold( key: scaffoldKey, appBar: new AppBar( leading: _isSearching ? const BackButton() : null, title: _isSearching ? _buildSearchField() : _buildTitle(context), actions: _buildActions(), ), body: new GridView.count( primary: true, crossAxisCount: 2, childAspectRatio: 0.80, children: List.generate(files.length, (index) { if(files[index].poster_path!=null){ return getStructuredGridCell(files[index].poster_path); }else{ return getStructuredGridCell(""); } }), ), ); } Card getStructuredGridCell(String file) { return new Card( child: Stack( children: <Widget>[ Center(child: CircularProgressIndicator()), Center( child: FadeInImage.memoryNetwork( placeholder: kTransparentImage, image: ""+file, ), ), ], ), ); } }

4. In the following file, we have created a method to access our network layer method. As you can see, we using a POST method to push a query to server and parsing response with the help of base model class.

import 'dart:async'; import 'package:flutter_movies/netwoklayer/basemodel.dart'; import 'package:flutter_movies/netwoklayer/networ_util.dart'; class MovieApi { NetworkUtil _netUtil = new NetworkUtil(); Future<BaseModel> search(String query) { String BASE_TOKEN_URL = NetworkUtil.BASE_URL + "search/movie"; return, body: { "api_key": "put_your_key_here", "query": query, }).then((dynamic res) { var results = new BaseModel.searchResult(res["results"]); results.status = 200; return results; }); } }
5. Now create basemodel.dart file. As we said, we use this class to create an object from the server response.
import 'package:flutter_movies/netwoklayer/movie.dart'; class BaseModel { int status; String message; String response; List<Movie> list; obj) { if (obj != null) { this.status = obj["status"]; if (status == null) { this.status = obj["status_code"]; } this.message = obj["message"]; this.response = obj["response"] != null ? obj["response"].toString() : null; } } BaseModel.searchResult(dynamic obj) { list =<Movie>((json) => new Movie.fromJson(json)).toList(); } }
6. Now create PODA class to keep fields of a movie.
class Movie extends Object { int id; String title; String original_title; String poster_path; Movie({, this.title, this.original_title, this.poster_path, }); factory Movie.fromJson(Map<String, dynamic> json) { return new Movie( id: json['id'] as int, title: json['title'] as String, original_title: json['original_title'] as String, poster_path: json['poster_path'] as String, ); } }
7. Here, we have our main file of this post that we were talking about. This is a network util class that we can use it anywhere to perform http request in a Flutter Application. In the following class,  we have created a method for GET and POST request. You can add other methods of http according to your requirement. In this file, we have created a field BASE_URL. It contains our base address of the server. We can append a method of server function. Like in this example, we use a search method of themoviedb to get a search result. If you going to build a big application. Then you should use this pattern to perform the server task.
import 'dart:async'; import 'dart:convert'; import 'package:http/http.dart' as http; class NetworkUtil { static final BASE_URL = ""; static NetworkUtil _instance = new NetworkUtil.internal(); NetworkUtil.internal(); factory NetworkUtil() => _instance; final JsonDecoder _decoder = new JsonDecoder(); Future<dynamic> get(String url, {Map<String, String> headers, encoding}) { return http .get( url, headers: headers, ) .then((http.Response response) { String res = response.body; int statusCode = response.statusCode; print("API Response: " + res); if (statusCode < 200 || statusCode > 400 || json == null) { res = "{\"status\":"+ statusCode.toString() + ",\"message\":\"error\",\"response\":" + res + "}"; throw new Exception( statusCode); } return _decoder.convert(res); }); } Future<dynamic> post(String url, {Map<String, String> headers, body, encoding}) { return http .post(url, body: body, headers: headers, encoding: encoding) .then((http.Response response) { String res = response.body; int statusCode = response.statusCode; print("API Response: " + res); if (statusCode < 200 || statusCode > 400 || json == null) { res = "{\"status\":" + statusCode.toString() + ",\"message\":\"error\",\"response\":" + res + "}"; throw new Exception( statusCode); } return _decoder.convert(res); }); } }

If you have followed the article carefully, you can see the app running very smoothly as shown in the above. But if you are facing any problem or you have any quires, please feel free to ask it from below comment section.


Wednesday, December 26, 2018

Flutter - Firebase cloud storage example

In mobile applications, you may notice image, video and other files that attract users and provide a better utility. These files are stored on the cloud. Cloud file storage is a storage service that is delivered over the internet.
Flutter firebase storage and database
Cloud file storage is most appropriate for unstructured data or semi-structured data, such as documents, spreadsheets, presentations, and other file-based data. There are several cloud storage providers with different features and price plans like AWS, Dropbox, Firebase storage etc.

In this post, we are going to see how you can upload a image on Firebase storage in a Flutter Application. In fact not only images you can use this firebase storage tutorial to upload any kind of file to firebase storage. I’ll explain, how you can create a Flutter application with a file upload feature that allows users to upload a image file from camera and gallery to cloud and display uploaded files in a grid list. For this, I’ll use Firebase cloud storage which can be accessed using Firebase SDK for cloud storage.

Sunday, December 16, 2018

Flutter - Auto JSON serialization and deserialization like GSON.

To make a big application, we always need some rest API's to provide a dynamic feature to the user. These API often supports JSON as a data format for communication through HTTP protocol.

If you have worked with native Android application development. You definitely missing those POJO classes in Flutter. After hit a request to the server, the server will return a JSON string. If you want to use data flexibly, we need to convert the JSON string into an object.


Wednesday, November 28, 2018

Flutter - Pull to refresh widget.

Pull to Refresh or Swipe Down is a common feature of all big mobile Application. You might have seen it in a lot of mobile apps like Twitter and Facebook provides a feature to swipe or pull down to refresh its content. When you swipe from top to bottom of the screen. After that, a loader will be shown and will disappear once the new content is loaded.

In this post, we are going to build a Flutter Application to achieve it. Flutter SDK providing us RefreshIndicator to apply a pull to refresh on any screen. To apply a pull to refresh on any screen, we have to wrap the root widget of the screen inside of RefreshIndicator. 


Friday, November 23, 2018

Flutter - ListView items custom filter.

We always use listview to display too many items like contact numbers and products in any shopping application. Let's assume a situation, you want to see an item that's placed in the bottom of list. So, it will irritate you to always scroll it down to see a particular item.

list view cutom search filter
In mobility, we can make it easy with the help of a search feature. ListView with search functionality helps the user to easily get the required results. In the search box, we can filter the data according to data entered by the user and this option is really necessary for making it user-friendly. By using this feature user can filter items by name, occupation, address, etc. Search functionality reduces navigation complexity for the user and also saves the user’s valuable time.

Sunday, November 11, 2018

Flutter - Firebase Realtime Database CRUD Operation

Firebase Realtime Database is a cloud-hosted database that helps us to store and sync data with NoSQL database in realtime to every connected client platforms like Android, iOS, and Web.  

Nowadays NoSQL databases are gaining popularity and Firebase Realtime Database is one of the NoSQL databases. Firebase store all the data in JSON format and any changes in data reflects immediately by performing a sync operation across all the platforms. This allows us to build a flexible realtime app easily with minimal efforts. 


Facebook Gruop


  • Cover art Blend

    Blend app is very advanced app there are lots of features like shayari, status, chat, feed....