Custom Theme using Theme Extensions

By | December 16, 2022

Theme extensions were introduced in Flutter 3. But what are Theme Extensions? As the name says, it helps to extend the inbuilt themes with our own extensions. Let’s jump into an example So when you create a flutter app, your basic root widget will look like this return MaterialApp( title: ‘Flutter Theme Extensions’, theme: ThemeData( primarySwatch: Colors.blue, ),… Read More »

James

Flutter Best Practices — Part 2

By | October 17, 2022

1. Avoid Functional Widgets We usually have a situation where we need to separate out UI code from the widget, But we avoid creating a separate widget and use function which returns Widget. This practice have some benefits, like you don’t need to pass all parameters in your new widget, You have less code and less files. But this approach… Read More »

James

Flutter Best Practices — Part 1

By | October 13, 2022

1. Placeholder Widgets Use SizedBox instead of Container as Placeholder widgets. Take a look at the below use-case return _loaded ? Container() : YourWidget(); The SizedBox is a const constructor and creates a fixed-size box. The width and height parameters can be null to indicate that the size of the box should not be constrained in the corresponding dimension. Hence, when we… Read More »

James

Debugging Network Calls in Flutter with Alice

By | June 21, 2022

In this article I am showing a useful plugin to debug network calls in Flutter. Alice! You can find the alice package here. Alice is an HTTP Inspector tool for Flutter which helps debugging http requests. It catches and stores http requests and responses, which can be viewed via simple UI. It is simple to integrate! First add… Read More »

James

Chocolate Feast Problem

By | June 10, 2021

Little Bobby loves chocolate. He frequently goes to his favorite 5 & 10 store, Penny Auntie, to buy them. They are having a promotion at Penny Auntie. If Bobby saves enough wrappers, he can turn them in for a free chocolate. Example n = 15 c = 3 m = 2 Answer 5 + 2 + 1 +… Read More »

James

Minimum Distances between Similar numbers in an array

By | June 8, 2021

The distance between two array values is the number of indices between them. Given , find the minimum distance between any pair of equal elements in the array. If no such value exists, return -1. Example arr = [3, 2, 1, 2, 3]; Minimum Distance = 2 (Distance between 2’s)

James

MVVM in Android – ViewModels, ViewModelScope, Retrofit all with a Simple Example.

By | June 6, 2021

Let’s learn how to implement MVVM in Android. It’s actually really simple. ViewModel is just another class that that implements the main Business Logic. ViewModel is a middle man between your view and your Data class(Repo/any Data Provider). It can be represented simply like this. Here the View just displays the data. ViewModel doesn’t know where the data… Read More »

James

Theming your App in Flutter using BLoc, Save & Reload

By | December 6, 2020

In this article, we will see how we can use BLoc to Theme your app in Flutter. To understand BLoC with a real world example, you can refer to my previous post on BLoC here. Part 1 Part 1 For this demo also we will need the below plugins If you follow my previous tutorial, it would be… Read More »

James

BLOC Pattern in Flutter explained with Real Example

By | October 5, 2020

In this article we will learn BLoc pattern in flutter for State Management with a simple real world example. Watch Video Tutorial For this example, we will try to consume a web service. The service we are going to use is https://jsonplaceholder.typicode.com/albums What BLoc does? BLoc helps to separate you presentation and business logic. So in simple terms,… Read More »

James

How to use YouTube APIs and Play YouTube videos in Flutter.

By | August 27, 2020

In this article we are gonna talk about how to use YouTube API’s and play YouTube videos in Flutter. Watch Video Tutorial Add Dependencies Open pubspec.yaml file in your Flutter project and add below dependencies Now, Let’s create two screens Home Screen Video Player Screen In the HomeScreen we will show the list of videos. API Key We… Read More »

James

Reusable Widgets & Reusable Custom AppBars in Flutter.

By | July 17, 2020

We will be talking about how to reuse widgets and create custom reusable AppBars in this article. It’s so easy in flutter. Composing widgets and making it a more powerful and reusable one is so much easy in flutter. Watch Video Tutorial Let’s start at one of the wrong ways that beginners used to do. Let’s say I… Read More »

James

Local Notifications in Flutter

By | July 4, 2020

Hello everyone, In this article we will learn how to show local notifications in Flutter. What we are going to learn? Show Simple notifications Show Repeated Notifications Show Scheduled Notifications Show Notifications at a particular time and day of a week Show Notification with an attachment Show Notifications with HTML content Cancel a Notification. Cancel all Notifications Deal… Read More »

James

Select Image from Camera/Gallery, Save Image in App’s Directory in separate Thread, Load Image from App’s Directory to UI.

By | June 7, 2020

In this article, we will how to select an image by capturing from camera or gallery, then we will save the image in app’s temporary directory in a separate thread and then load it from there. Watch Video Tutorial For this demo we need three packages. Add Dependencies Open pubspec.yaml file and then add the below dependencies. path_provider:… Read More »

James

Chat Application in Flutter Using Socket IO

By | May 18, 2020

In this article we will see how we can create a chat application in flutter using Socket IO node js server. For this we need to have a server installed with Node js Socket IO and related dependencies So let’ start with Flutter. Here we need three screens Login screen Chat Users List screen Chat Screen. Login Screen… Read More »

James

Easy StateManagement in Flutter using Providers, MultiProviders, ChangeNotifiers and Consumers

By | March 15, 2020

With Providers and MultiProviders we can do easy StateManagement in Flutter. State Management in Flutter Watch Video Tutorial Add Dependencies First Go to your pubspec.yaml file add the below dependency, I would recommend to add the latest dependency version, at this moment it is 4.0.4 provider: ^4.0.4 The Providers will have  Change Notifiers Consumers The Basic flow to update… Read More »

James

Socket Programming in Flutter, Build Chat Apps in Flutter

By | February 16, 2020

Today’s video will let you know how to create sockets in Flutter to make bi-directional communication possible. First we will go with the ‘IOWebSocketChannel‘ class. Watch Video Tutorial You can read about IOWebSocketChannel by following this link. Let’s use the Official Sample first. Create a new file SocketDemo.dart and add the below code into it. This will create… Read More »

James

Wrap Widget & Chip Widgets in Flutter

By | January 30, 2020

Wrap widget is such a useful widget in many circumstances. Watch Video Tutorial First Let’s create a Chip Widget. The above code creates a Chip widget and you can add it to the UI as you want. If we add it inside a row…then this happens… But we want the chips that overflow to be wrapped to the… Read More »

James

Firebase Push Notifications in Flutter

By | January 14, 2020

This article will show how to send push notifications in Flutter using Firebase. We will start with Android. Add Dependency For sending push notifications we use a plugin called firebase_messaging… https://pub.dev/packages/firebase_messaging Open your pubspec.yaml file and add this dependency Firebase Account Make sure you have a firebase account before proceeding. Once you have created your account, proceed by… Read More »

James

Using extension-methods in Flutter

By | January 6, 2020

This article will help you to understand what are extension methods and what is the use of extension methods. Extension functions can be added to classes which are already compiled. So if you want to extend a library which is already added in your app, you can make use of Extension methods. Watch Video Tutorial Let’s take a… Read More »

James

App Theming in Flutter – Dark Mode/ Light Mode

By | December 31, 2019

In this article, we will see how to theme our apps in Flutter. As you know Google and Apple has released Dark Mode and Light Modes in their latest OS releases in Android 10 and iOS 13. So we have to make sure that our apps works perfectly when the user switch modes in their devices. Watch Video… Read More »

James

Proper way to Handle Exceptions in Flutter

By | December 23, 2019

Today we will see how we can properly handle errors and exceptions in Flutter. Watch Video Tutorial For this example we will be doing a service call and handle exceptions related to that. We will create a sample service here In the above example we are catching all exceptions using a simple try catch block which is not… Read More »

James