Google search engine
Home Blog Page 58

Explore Firebase In-App Messaging In Flutter

0

Firebase Database is one of the best platforms for data storage in this we Firebase adds up messaging to the collection of products on the Firebase console. In-App Messaging connects all the active users who are already using our app. It sends a relevant message to the user and helps in interconnection and encourages users to use the feature of the app.

Hello friends, I will talk about my new blog on Explore Firebase In-App Messaging In Flutter. We will also implement a Firebase In-App Messaging In Flutter demo, describe his properties, and use them in your flutter applications. So let’s get started.


Table Of Contents :

Firebase In-App Messaging

Implementation

In-App Messaging Android Setup

Configuring Firebase Project

Code File

Conclusion


Firebase In-App Messaging :

Firebase In-App Messaging As the name suggests it works to send messages as I mentioned above it allows to send messages to all the active users as we have one application then the user To increase interconnection with each other, we send a message in the application to encourage the user to do something.

If a message can be configured dynamically so that the application will not need to update the message frequently, thereby prompting the active user to complete all the functions of in-app messaging by sending the message.

For Example:

Like buying an item or subscribing to content. This is also connected to firebase analytics and prediction to help you give custom and advance targeted messaging based on individual interest or engagement.

Demo Module :


Implementation :

You need to implement it in your code respectively :

Step 1: Add dependencies.

Add dependencies to pubspec — yaml file.

dependencies:
 firebase_in_app_messaging: ^0.5.0+4

dependencies:firebase_messaging: ^9.1.4

Step 2: import the package :

import 'package:firebase_in_app_messaging/firebase_in_app_messaging.dart';

import 'package:firebase_messaging/firebase_messaging.dart';

Step 3: Run flutter package get

Step 4: Classpath add to the[project]/android/build.gradlefile.

In-App Messaging Android Setup:

In your project-level build.gradle file, make sure to include Google’s Maven repository in both your buildscriptand allprojects sections.

Add the dependency for the In-App Messaging Android library to your module (app-level) Gradle file (usually app/build.gradle):

dependencies {
// Add the google services classpath
classpath 'com.google.gms:google-services'
}

Configuring Firebase Project:

To configure the project in firebase we will open the firebase console from which we will configure our project in-app messaging from which we will get a google service.json file which contains the configuration data that firebase uses internally To achieve this, we need a Firebase project so that we can further configure the project in Firebase, let’s see it in detail below.

Now we will open the firebase console to create a new project then click on add project card for the new firebase project, as soon as we click on the card, a new dialog opens in which we will set the name of our project and set the analytics location accordingly. As soon as we set the name of our project, then we will click on the Create Project button below.

for example, as shown in the image below.

After completing the first step a success message will appear indicating that we are ready for a new project

After this, in the next step, it asks whether you want to enable Google Analytics for the Firebase project or not, if yes, then enable it, although it is enabled by default, that click on the Continue button below to go to the next step

In the next step, you will enter the package name of the project by the way you can also enter the alias of the application Debug Certificate SHA-1.

After that the next step will come in the download config file, we will see there is a button on which to download google. Wrote service.json on which we will click and download it and add it to our flutter project.

Create Campaign:

When we create a new campaign then for that we have to open the firebase console after that these apps will navigate to messaging if any campaign is not in the account then click on create first campaign button and create a new campaign.

for example, as shown in the image below.

As soon as we click on the button then we are redirected to a new page now you can substitute a new campaign where we can choose the layout of our message what kind of message layout we want to make main It has 3 different layouts Model Image and Banner Message All of them have the same functionality and behavior.

Create a Campaign Message Properties:

  1. Background: Using the background property, we can change the background of our dialog with a new color.
  2. Text Colour: You can change the color of your given text in the text color property.
  3. Title: The title attribute is a type of title text that we display in a campaign.
  4. Body (Optional): The body property is used to display the main message of any dialog. This is optional.
  5. Image URL (Optional): We use the image URL property when we want to show an image in any dialog. This is optional.

When we complete all these given fields then you can see a preview of the message in your firebase console.

for example, as shown in the image below.

Target Your Message:

Now you have to select the user to whom you want to message, who has some properties.

  1. Campaign Name: In this, we will give the name of our campaign which is not visible to the user, it is used to track the campaign.
  2. Campaign Description (Optional): The campaign Detail property is mainly optional The description in it is not visible to the user.
  3. Target app and other conditions: This property specifies which message to show to the user.

for example, as shown in the image below.

Message Scheduling:

Can set campaign start date and end date using message scheduling There are many more optional things in this, there is a limit on showing messages, etc.

  1. Start time: StartTime property This is used to set the start time of the message
  2. End time: The end time property is used to specify the end time of the message given in the campaign.

for example, as shown in the image below.

Conversion Events (Optional):

Conversion Events This is kind of an optional field it allows to set the tag for click count.

for example, as shown in the image below.

Use the last step to add some key values ​​to add custom data which is optional.

Now you can finally publish it before publishing we can review it and make any changes and once it is published the campaign will be started.

When we run the application, we ought to get the screen’s output like the underneath screen capture.

Code File:

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_in_app_messaging/firebase_in_app_messaging.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
class FireBaseInAppDemo extends StatefulWidget {
@override
_FireBaseInAppDemoState createState() => _FireBaseInAppDemoState();
}

class _FireBaseInAppDemoState extends State<FireBaseInAppDemo> {

void _instanceId() async {
await Firebase.initializeApp();
FirebaseMessaging.instance.getInitialMessage();
FirebaseMessaging.instance.sendMessage();
var token = await FirebaseMessaging.instance.getToken();
print("Print Instance Token ID: " + token!);
}

@override
void initState() {
super.initState();
_instanceId();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('In App Messaging Demo'),
),
body: Center(
child: RaisedButton(
child: const Text('In-App Messaging'),
onPressed: () {
FirebaseInAppMessaging.instance.triggerEvent("");

FirebaseMessaging.instance.sendMessage();

FirebaseMessaging.instance.getInitialMessage();
},
),
),
);
}
}

Conclusion:

In this article, I have explained an Explore Firebase In-App Messaging in a flutter, which you can modify and experiment with according to your own, this little introduction was from the Explore Firebase In-App Messaging demo from our side.

I hope this blog will provide you with sufficient information on Trying up the Explore Firebase In-App Messaging in your flutter project. We showed you what the Explore Firebase In-App Messaging is and work on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.

From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, and LinkedIn for any flutter-related queries.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.

ObjectBox: A NoSql database for Flutter/Dart

0

There are few Databases in Flutter that are fast, efficient, and easy to use but when ObjectBox made its debut in Flutter, not only list grown longer but some key points have also been sorted out like improving performance and bringing much-awaited relations support from language bindings to flutter.

For those of you new to ObjectBox: ObjectBox is a superfast NoSQL object database for Flutter / Dart and here is how you can save data in your Dart / Flutter apps

In this blog, we will learn about ObjectBox: A NoSql database for Flutter/Dart. We will also implement an ObjectBox: A NoSql database for Flutter/Dart, describe his properties. So let’s get started. so let’s get started.


Table Of Contents :

ObjectBox: A NoSql database.

ObjectBox Key Features.

How to fast ObjectBox Dart

Implement

Code Implementation

Conclusion


ObjectBox: NoSql Database:

Objectbox in Flutter is a very fast NoSQL database and it is optimized for very high performance on devices like mobile desktop and very lightweight database it stores all the objects.

ObjectBox Key Features:

There are some Key Features of ObjectBox are:

  • LIGHTSPEED: OjectBox carrying the motto of best performance and is up to the mark when it comes to delivering it, till now it has outperformed on every embedded database tested so far.
  • EASY OBJECT API: ObjectBox is specially designed for Mobile Applications and IoT Devices, it requires only a little bit of code as compared to SQLite with consisting of any kind of rows, columns, or SQL.
  • QUERYBUILDER: With ObjectBox, simply query for objects with checks at compile times; no more typos causing crashes at runtime.
  • OBJECT RELATIONS: In ObjectBox references and the relationship of Object are built-in, native references.
  • REACTIVE: Reacting to data changes is simple and powerful. Use reactive data observers from ObjectBox or integrate with RxJava.
  • MULTIPLATFORM: ObjectBox supports C, Android, plain-Java, Kotlin (Linux and Windows), POSIX, MacOS. Swift (iOS) is coming up soon.
  • INSTANT UNIT TESTING: Unit testing is with a real database is easy in ObjectBox and for this, it takes a few milliseconds, it is because of its multi-platform approach.
  • ROBUST TECHNOLOGY: Safe transactions and parallelism has been provided to you because of Its Multiversion Concurrency Control(MVCC) and ACID (Atomic, Consistent, Isolated, Durable) properties.
  • SIMPLE THREADING: Objects returned by ObjectBox within all threads. No strings attached.
  • SCHEMA MIGRATIONS: ObjectBox takes care of new object versions with added, removed, and renamed properties.
  • SYNC: ObjectBox Synchronizes online/offline data seamlessly with simple APIs.

How fast is ObjectBox Dart?

Speed is important for data persistence solutions. Accordingly, we wanted to test how ObjectBox compares performance-wise to other Flutter Dart database options. Therefore, we looked for libraries with comparable levels of storage abstraction and feature set — so not just plain SQL/Key-value storage but also ORM-like features. There doesn’t seem to be that much choice…

We looked at two popular approaches: sqflite an SQLite wrapper for Flutter (no Dart Native support), and Hive, a key-value store with Class-adapters which seems still popular although its technology is phased out (see below). As a third alternative, we pulled in Firestore, which does not really fit as it is no local database, but would be fun to compare anyway.

ObjectBox Data Sync:

ObjectBox is a kind of out-of-box data sync way to keep our data in-sync online and offline. This outbox keeps the data up to date between devices like mobile, IoT, and cloud servers, and this ObjectBox when the client comes back online Automatically updates this change.

Implementation :

You need to implement it in your code respectively :

Step 1: Add dependencies.

Add dependencies to pubspec — yaml file.

dependencies:

objectbox: ^0.11.0
objectbox_flutter_libs: any
path_provider: ^1.6.27

dev_dependencies:

build_runner: ^1.0.0
objectbox_generator: any

Step 2: import the package :

import 'package:objectbox/objectbox.dart';
import 'package:path_provider/path_provider.dart';

Step 3: Run flutter packages get in the root directory of your app.

Code Implementation :

Firstly to implement the database we will create a model class that will have @Entity() annotation and use it later to get the bindings required by ObjectBox.

Here is how lib/model/person_model.dart looks in my case:

import 'package:objectbox/objectbox.dart';

@Entity()
class PersonDetail {
String name;
String lastName;
int personAge;
int id;

PersonDetail({this.name, this.lastName, this.personAge});
}

You can notice that I have left the id parameter out of the class constructor. The reason for this is that objectbox will dynamically allocate a new id for the model class and we don’t need to worry about manually incrementing it after every operation.

Once you have implemented your model class, run the build_runner so that the objectbox can generate the required binding files.

After this, we have created a helper class in which we have defined the Person Details in which we can insert the name of the person and all his details and with the help of his id we can delete his details and update it as That we have given below reference of the code like delete insert and update.

class Helpers {

static Future<int> insert(PersonDetail person) async {
var store = await ObjectBoxStore.getStore();
var box = store.box<PersonDetail>();
return box.put(person);
}

static Future<bool> delete(int id) async {
var store = await ObjectBoxStore.getStore();
var box = store.box<PersonDetail>();
return box.remove(id);
}

static Future<PersonDetail> queryPerson(int id) async {
var store = await ObjectBoxStore.getStore();
var box = store.box<PersonDetail>();
return box.get(id);
}
}

Code File :

import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:flutter_objectbox_demo/helpers/helpers.dart';
import 'package:flutter_objectbox_demo/model/person_model.dart';
class ObjectBoxDemo extends StatefulWidget {
@override
_ObjectBoxDemoState createState() => _ObjectBoxDemoState();
}

class _ObjectBoxDemoState extends State<ObjectBoxDemo> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title:Text('Object Box Demo'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
RaisedButton(
child: Text('INSERT'),
onPressed: () async {
var person =
PersonDetail(name: "Mac", lastName: "anthony", personAge: 25);
int id = await Helpers.insert(person);
print("Sucessfull inserted an object with $id");
},
),
SizedBox(height:20,),
RaisedButton(
child: Text('UPDATE'),
onPressed: () async {
var person = await Helpers.queryPerson(1);
person.name = 'Sam';
person.lastName = 'david';
person.personAge = 30;
int id = await Helpers.insert(person);
print("Sucessfull updated an object with $id");
},
),

SizedBox(height:20,),
RaisedButton(
child: Text('DELETE'),
onPressed: () async {
bool deleted = await Helpers.delete(1);
if (deleted) {
print("Sucessfull deleted an object with id :1");
}
},
),
],
),
);
}
}

Conclusion :

In this article, I have explained ObjectBox: A NoSql database for Flutter/Dart?, which you can modify and experiment with according to your own, this little introduction was from the ObjectBox: A NoSql database for Flutter/Dart?.

I hope this blog will provide you with sufficient information on Trying up the ObjectBox: A NoSql database for Flutter/Dart? in your flutter project. We ObjectBox: A NoSql database for Flutter/Dart? is and work on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.


From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, and LinkedIn for any flutter-related queries.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.

Inheritance with Mixin in Flutter

0

What is Inheritance? Let’s assume that there is a functionality that is used on every screen of the app or in a majority of screens of the app, what you will prefer to implement this functionality writing code once or making a method with the required parameters and using that method in every screen by calling it simple. Of course, we would prefer code reusability, that’s called inheritance.

Now, if there is a class that requires more than one class property, it is not possible to extend that class to more than one class. So to avoid such inheritance ambiguity we require mixins. Mixins are really great in dart as they provide us flexibility for code reusability.

mixins are normal classes whose method can be used in another class without extending the class. In dart, we can do this by using the keyword with.

In this blog, we shall learn how we build a mixin in a flutter that records the time spend on a particular screen. This functionality is very important if we are using analytics in our app to track the user’s behavior.


Why we require a mixin to do this? Let’s say there are 50 screens in an app and we want to implement a timer in every screen then we need to write code for the timer on every screen if we do such a thing then it is not a good practice as we are using the same code in every screen again and again. So we can create a mixin for it.

Create a mixin named TimerMixin .

mixin TimerMixin {}

We will create two methods startTimer and disposeTimer which will start the timer and stop the timer.

startTimer() {
Timer.periodic(Duration(seconds: 1), (Timer timer) {
timerData.clear();
timerData.add(timer.tick.toInt());
});
return timerData;
}

To keep on increasing the duration value every second, we can use the Timer periodic property to execute a reoccurring function. It takes a duration property and a callback that takes Timer . Inside the callback, we can add the timer tick into a List.

timerData.clear(); why we need this?

Let’s assume that the user keeps the screen open for a longer period of time in this case the List size will be increased a lot, so to maintain the space complexity we are removing all the elements from the List and storing the next element in it.

void disposeTimer() {
hoursStr =
((timerData[0] / (60 * 60)) % 60).floor().toString().padLeft(2, "0");

minutesStr = ((timerData[0] / 60) % 60).floor().toString().padLeft(2, "0");
secondsStr = (timerData[0] % 60).floor().toString().padLeft(2, "0");
print("$hoursStr:$minutesStr:$secondsStr");
}

disposeTimer the method will be executed when the screen disposes of it. This method will take the integer stored in the timerData and parse it to an hour, min, and second.

mixin. dart:

import 'dart:async';mixin TimerMixin {
String hoursStr = '00';
String minutesStr = '00';
String secondsStr = '00';
List<int> timerData = [];

startTimer() {
Timer.periodic(Duration(seconds: 1), (Timer timer) {
timerData.clear();
timerData.add(timer.tick.toInt());
});
return timerData;
}

void disposeTimer() {
hoursStr =
((timerData[0] / (60 * 60)) % 60).floor().toString().padLeft(2, "0");

minutesStr = ((timerData[0] / 60) % 60).floor().toString().padLeft(2, "0");
secondsStr = (timerData[0] % 60).floor().toString().padLeft(2, "0");
print("$hoursStr:$minutesStr:$secondsStr");
}
}

Now create a state full class. To use mixin in it we will use with keyword.

class DemoPage extends StatefulWidget {
const DemoPage({Key key}) : super(key: key);

@override
_DemoPageState createState() => _DemoPageState();
}

class _DemoPageState extends State<DemoPage> with TimerMixin {

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text("Hello"),
),
);
}
}

We can now use all the methods TimerMixin inside the DemoPage. Inside the initState and dispose the method we can use them.

@override
void initState() {
startTimer();
super.initState();
}

@override
void dispose() {
disposeTimer();
super.dispose();
}

main. dart:

import 'package:flutter/material.dart';
import 'package:minin_demo/mixin.dart';

void main() {
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: MyApp(),
),
);
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: RaisedButton(
color: Colors.red,
child: Text(
"Navigate",
style: TextStyle(
color: Colors.white,
),
),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DemoPage(),
),
);
},
),
),
);
}
}

class DemoPage extends StatefulWidget {
const DemoPage({Key key}) : super(key: key);

@override
_DemoPageState createState() => _DemoPageState();
}

class _DemoPageState extends State<DemoPage> with TimerMixin {
@override
void initState() {
startTimer();
super.initState();
}

@override
void dispose() {
disposeTimer();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text("Hello"),
),
);
}
}

App Flow:

The home page will contain a simple button in the center, on pressing it the user will be navigated to the new page, and on navigating back to the home page from the new page the duration spent by the user on the new page will be displayed on the run console.


🌸🌼🌸 Thank you for reading. 🌸🌼🌸

From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us:
And read more articles from FlutterDevs.com

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app 987tr project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, and LinkedIn for any flutter-related queries.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences!.

How To Integrate Flutter To Existing Android App?

0

Flutter has made it quite easy to develop complex UIs for developers. 
Flutter is a very performant app development framework that is written in Dart. It interacts efficiently and very easily on a native device. It is supported by Google.
Flutter automated testing empowers you to meet high responsiveness in your application as it helps in discovering bugs and various issues in your application. A flutter is a tool for developing mobile, desktop, web applications with code & is a free and open-source tool.

Hello friends In this blog, we will learn about How to integrate flutter into the existing android app?. In this, we will see how we will integrate any Flutter app in Android. so let’s get started.


Table Of Contents :

Integrate Flutter To Existing App.

Add Flutter to existing Android App

Implement

Code Implementation

Conclusion


Integrate Flutter To Existing App:

Flutter provides us with a platform to develop apps for Android and iOS. Using Flutter we can integrate modules of our Flutter project into any existing native projects. After integrating the Flutter project we can also develop the rest of the Flutter application and it will be automatically reflected in the parent projects.

Add Flutter to an existing Android app:

Flutter allows us to do a few things already integrated into Android apps which are explained below:

  • This is a module build wizard that allows co-editing Android projects and Flutter projects in our Android Studio.
  • It supports both types of apps like our Kotlin Java
  • It can integrate and conform to the plugins in flutter and the flutter modules can be integrated seamlessly and as soon as we add the flutter SDK hooks in our Gradle file it auto builds the flutter modules we have created. and allows it to be important Flutter plugins can integrate and conform to the preexisting platform and how Flutter modules can then be seamlessly integrated as a result.
  • Once we have integrated flutter you can also use flutter attach to the id so that we can connect to the app

Example of an existing application:

Following are the steps to integrate Flutter Project in Android Project.

Step 1:First of all we will open an android studio and for a new android project, we will select a new android studio project.

Step2:Now we can first create a screen from the android studio template with the help of the attached MVVM, name it whatever.

like you do in your android studio, select File>New>New project… and choose a template.

Step3:Now we see in the next step as soon as the android project is created a new android project opens now as soon as we run the project then a hello word written appears on the screen which is the default.

Step4:Now we will close and run our android project again before that we will create a project and select a flutter module in it in which we will set the project name and its SDK path, project location, etc.

Step5:When we create a new flutter project and run our project, some kind of output appears, which is shown in the image below.

Step6:Now we will open our android project again and right-click on our project, on right-click a dialog will open in this we will move the new section cursor and click on the module option.

Step7:As soon as we click on the module, create a new module comes, in this, we will select the option of import flutter module, in we will set the path of our flutter project and click on the finish button, which will import our flutter module.

Step8:The structure of our project changes as soon as the Flutter module is imported, we see that the Flutter project is also inbuilt in our Android project.

Now our native Android and Flutter Project is successfully integrated.

Implement:

Flutter provides FlutterActivity inside the android app that simulates the flutter experience.
We need to register flutter activity in AndroidManifest.xml.

<activity
  android:name="io.flutter.embedding.android.FlutterActivity"
  />

dependencies {implementation project(':flutter')
}

Code Implement:

You need to implement it in your code respectively:

First, we add Activity. Main. A button has been created in XML in which the name and id of the button have been given, which will help us to perform any action on the button. As below code is given in the reference.

<Button
android:id="@+id/button_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OPEN FLUTTER PROJECT"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="127dp"
tools:layout_editor_absoluteY="417dp"
/>

Next, we will define the android activity inside button in the main activity class which integrates the flutter project inside our android app it maintains its responsibilities like displaying the splash screen of android and flutter. As below code is given in the reference.

public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button button=findViewById(R.id.button_id);

//startActivity(FlutterActivity.createDefaultIntent(this));


button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(
FlutterActivity
.withNewEngine()
.initialRoute("/my_route")
.build(MainActivity.this)
);
}
});
}
}

Conclusion :

In this article, I have explained How to integrate flutter to the existing android app?, which you can modify and experiment with according to your own, this little introduction was from the How to integrate flutter to the existing android app?.

I hope this blog will provide you with sufficient information on Trying up the How to integrate flutter into the existing android app. How to integrate flutter to the existing android app? is and work on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.

From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, and LinkedIn for any flutter-related queries.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.

Localization / Multi-Language In Flutter

Google’s Flutter is a very attractive app development platform. It allows to development of apps like android ios etc. based on a single codebase. It is compiled in machine language for its great performance. It is built with Dart language. As we create an app in Flutter in which we want to do localization, then we load it using the localization widget to see all the objects in which we have a collection of localized objects. ‘flutter_localizations’ library is used to set up localization in Flutter.

Hello friends, I will talk about my new blog on Localization / Multi-Language In Flutter. We will also implement a Localization / Multi-Language In Flutter. describe his properties, and use them in your flutter applications. So let’s get started.


Table Of Contents :

Flutter Localization

Implementation

How To Implement Code In Dart File

Code File

Conclusion


Flutter Localization:

The Flutter localization widget is used to view and load objects from a collection of localized values. If we create an application and want to increase the use of the application, we have to support multiple languages ​​in our apps.

With the help of localization, we can change the language of our application as android and ios is the most popular operating system of mobile so we using flutter localization will show localization on both types of device and will be localized for both field

Some Basic requirements of multiple languages.

  • Flutter localization application works by default according to the language configured in the smartphone.
  • If a language is not supported in the application, then English is the (en)default language of the language.
  • The end-user can change the working language from a list of supported languages.
  • When the user selects any of the other languages, the entire layout of the application is refreshed to display the values ​​for the chosen language

Implementation :

You need to implement it in your code respectively :

Step 1: Add dependencies.

Add dependencies to pubspec — yaml file.

First, we will add flutter_localization and intl library to pubspec. yaml.

dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutterdev_dependencies:
intl: ^0.17.0-nullsafety.2 flutter_test:
sdk: flutter

Step 2: import the package :

import 'package:flutter_localizations/flutter_localizations.dart';

Step 3: Run flutter package get

How to implement code in dart file :

Create a new dart file calledflutter_localization_demo inside the lib folder.

First, we create a dart file named l10n of the l10n package in which arb file initializes the to local list which contains all our languages which we provide in our project.

We have app_in. arb defines its language, which is a type of localization code, as an arb file is a kind of translator toolkit that is used as an input to a translation tool.

For Example:

app_en.arb, app_es.arb, app_id.arb, app_it.arb

We have initialized the English language in the app_en.arb file regarding the code given below.

Here is the code for app_en.arb:

{
"english_language": "English Language",
"hello_world": "Hello World"
}

After this, we have created a class named LocalProvider, in which the value has been set and get with the help of the provider.

class LocaleProvider with ChangeNotifier {
Locale? _locale;
Locale? get locale => _locale;

void setLocale(Locale locale){
if(!L10n.all.contains(locale)) return;
_locale = locale;
notifyListeners();
}
}

Localization adds for MaterialApp:

To implement localization in our application we will add MaterialApp widget supportedLocales and localizationsDelegates inside MyApp() class.

Add supportedLocales:

This is used to set all the languages we provide locally as it recognizes the US English language by default.supportedLocales: L10n.all,

Add localizationsDelegates in Material App:

  • GlobalMaterialLocalizations.delegate is used to get localized strings and other values for material components.
  • localizationsDelegates is a listed property in materialApp to get collection localized values from localizing delegates.
  • GlobalWidgetsLocalizations.delegate is used to define the default text direction for the widgets library.
localizationsDelegates:[
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
AppLocalizations.delegate,
],

After this, we will create a class named FlutterLocalizationDemo inside which we are using a dropdown button inside which we will set the value in our widget text and we have created a function named title which we will set the title of the language in which the language code, Country code, etc can be anything as soon as we select the language in the dropdown it will also change our given title.

Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
AppLocalizations.of(context)!.english_language,
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w500,
),
),
SizedBox(height:85.0),
DropdownButton(
value: lang,
onChanged: (Locale? val) {
provider.setLocale(val!);
},
items: L10n.all
.map((e) => DropdownMenuItem(
value: e,
child: _title(e.languageCode),
))
.toList())
],
),
)

When we run the application, we ought to get the screen’s output like the underneath screen capture.

Final Output

Code File :

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_localiztion_demo/l10n/l10n.dart';
import 'package:flutter_localiztion_demo/providers/locale_provider.dart';
import 'package:flutter_localiztion_demo/providers/localizations.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => LocaleProvider()),
],
child: Consumer<LocaleProvider>(builder: (context, provider, snapshot) {
return MaterialApp(
locale: provider.locale,
localizationsDelegates:[
//AppLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
AppLocalizations.delegate,
],
supportedLocales: L10n.all,

home: FlutterLocalizationDemo(),
);
}),
);
}
}

class FlutterLocalizationDemo extends StatelessWidget {
const FlutterLocalizationDemo({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
_title(String val) {
switch (val) {
case 'en':
return Text(
'English',
style: TextStyle(fontSize: 16.0),
);
case 'id':
return Text(
'Indonesia',
style: TextStyle(fontSize: 16.0),
);

case 'es':
return Text(
'Spanish',
style: TextStyle(fontSize: 16.0),
);

case 'it':
return Text(
'Italian',
style: TextStyle(fontSize: 16.0),
);

default:
return Text(
'English',
style: TextStyle(fontSize: 16.0),
);
}
}

return Consumer<LocaleProvider>(builder: (context, provider, snapshot) {
var lang = provider.locale ?? Localizations.localeOf(context);
return Scaffold(
appBar:AppBar(
title:Text('Localization Demo'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
AppLocalizations.of(context)!.english_language,
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w500,
),
),
SizedBox(height:85.0),
DropdownButton(
value: lang,
onChanged: (Locale? val) {
provider.setLocale(val!);
},
items: L10n.all
.map((e) => DropdownMenuItem(
value: e,
child: _title(e.languageCode),
))
.toList())
],
),
),
);
});
}
}

Conclusion:

In this article, I have explained Localization / Multi-Language In Flutter, which you can modify and experiment with according to your own, this little introduction was from the Localization / Multi-Language. In the Flutter demo from our side.

I hope this blog will provide you with sufficient information in Trying up the Localization / Multi-Language In Flutter. In Flutter in your flutter project. We showed you what the Localization / Multi-Language In Flutter is and work on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.

From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, and LinkedIn for any flutter-related queries.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.

Explore Widget Lifecycle In Flutter

0

Flutter is a mobile framework that helps to modernize both iOS and Android app from a single codebase. It is a combination of stateful and stateless widgets. Like all frameworks, Flutter also has a lifecycle associated with all the apps that our Flutter app uses. is managed by lifecycle In this article, we will take a look at different types of apps available in the flutter app, lifecycle.

In this article, we will explore the Widget Lifecycle in Flutter. We will also implement a Widget Lifecycle demo, describe its properties, and use them in your flutter applications. So let’s get started.


Table of Contents :

Flutter

Widget Lifecycle

Widget Lifecycle Method

Code Implementation

Code File

Conclusion


Flutter :

“ Flutter is Google’s UI toolkit that helps you build beautiful and natively combined applications for mobile, web, and desktop in a single codebase in record time, Flutter offers great developer tools, with amazing hot reload”

Widget Lifecycle :

Everything in Flutter is a Widget, so before knowing about Lifecycle, we should know about Widgets in Flutter.

There are two types of widgets in Flutter.

  • Stateless Widgets.
  • Stateful Widgets.

Before knowing about the Lifecycle, we need to understand the difference between the two widgets.

=> Stateless Widgets: Stateless Widgets in Flutter are those widgets whose state once created cannot be changed, it becomes immutable like on variables, buttons, icons, etc., or any state that cannot be changed on the app to retrieve data. Returns a widget by overwriting the build method. We use it when the UI relies on the information inside the object itself.

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container();
}
}

=> Stateful Widget: A Stateful widget maintains data and responds to whatever the data does inside the application. It is a mutable widget, so it is drawn multiple times in its lifetime.

We use this when the user dynamically updates the application screen. This is the most important of all the widgets, as it has a state widget, everyone knows that something has been updated on our screen.

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return Container();
}
}

The life cycle of the StatefulWidget Diagram.

=> A stateful widget has the following lifecycle stages:

Widget Lifecycle Methods:

The life cycle is based on the state and how it changes. A stateful widget has a state so we can explain the life cycle of flutter based on it. Stage of the life cycle:

  • createState
  • initState()
  • didChangeDependencies()
  • build()
  • didUpdateWidget()
  • setState()
  • deactivate()
  • dispose()
  • > initState(): Flutter’s initState() method is the first method that is used while creating a stateful class, here we can initialize variables, data, properties, etc. for any widget.
int a;
@override
void initState() {
a= 0;
super.initState();
}
  • > createState(): When we create a stateful widget, our framework calls a createState() method and it must be overridden.
class MyPage extends StatefulWidget {
@override
_MyPageState createState() => _MyScreenState();
}
  • > build(): The build method is used each time the widget is rebuilt. This can happen either after calling initState, didChangeDependencies, didUpdateWidget, or when the state is changed via a call to setState
@override
Widget build(BuildContext context, MyButtonState state) {
return Container(color:Colors.red);
}
  • > didChangeDependencies(): This method is called immediately after initState and when dependency of the State object changes via InheritedWidget.
@override
void didChangeDependencies() {
super.didChangeDependencies()
}
  • > didUpdateWidget(): This method is called whenever the widget configuration changes. A typical case is when a parent passes some variable to the children() widget via the constructor.
@override
void didUpdateWidget(MyHomePage oldWidget) {
super.didUpdateWidget(oldWidget)
}
  • > deactivate(): It is used when the state is removed from the tree but before the current frame change can be re-inserted into another part of the tree
@override
void deactivate() {
super.deactivate();
}
  • > dispose(): We use this method when we remove permanently like should release resource created by an object like stop animation
@override
dispose() {
animationController.dispose(); // you need this
super.dispose();
}

Implement:

You need to implement it in your code respectively:

Create a new dart file calledwidget_lifecycle_demo inside the lib folder.

Now we first took a dart file as I have mentioned above and before the build method we have defined an integer type variable whose variable name is _counter, after that I have created an increment counter method inside it in setState() Defines a _counter variable that is of increment type.

int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}

In this, we have called the method initState(),didChangeAppLifecycleState(),
deactivate() etc. As soon as our app is created it will print a message in the accordion console of its lifecycle.

@override
void initState() {
super.initState();
WidgetsBinding.instance!.addObserver(this);
print("initState");
_counter++;
}

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
print('AppLifecycleState: $state');
}

After this, we have taken the column widget inside the build method inside which the increment value is defined inside a text and in it we have taken a FloatingActionButton() which is of increment type, pressing which will increase the value of the counter.

Widget build(BuildContext context) {
print("build");
return Scaffold(
appBar: AppBar(title: Text("Flutter Widget Lifecycle")),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
SizedBox(height: 8.0,),

Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),

],
),
),

floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}

Code File:

import 'package:flutter/material.dart';
class LifeCycleExm extends StatefulWidget {
@override
_LifeCycleExmState createState() => _LifeCycleExmState();
}

class _LifeCycleExmState extends State<LifeCycleExm> with WidgetsBindingObserver {

@override
void initState() {
super.initState();
WidgetsBinding.instance!.addObserver(this);
print("initState");
}

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
print('AppLifecycleState: $state');
}

@override
void dispose() {
WidgetsBinding.instance!.removeObserver(this);
super.dispose();
}

@override
void deactivate() {
// TODO: implement deactivate
print("deactivate");
super.deactivate();
}

int _counter = 0;

void _incrementCounter() {
setState(() {
_counter++;
});
}

@override
Widget build(BuildContext context) {
print("build");
return Scaffold(
appBar: AppBar(title: Text("Flutter Widget Lifecycle")),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),

Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
SizedBox(height: 8.0,),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}

Conclusion:

In this article, I have explained an Explore Widget Lifecycle in a flutter, which you can modify and experiment with according to your own, this little introduction was from the Explore Widget Lifecycle.

I hope this blog will provide you with sufficient information on Trying up the Explore Widget Lifecycle in your flutter project. We showed you the Explore Widget Lifecycle and worked on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.

From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, and LinkedIn for any flutter-related queries.

Under The Hood Rendering In Flutter

0

Flutter widget is built using a modern framework. It is like a react. In this, we start with the widget to create any application. Each component in the screen is a widget. The widget describes what his outlook should be given his present configuration and condition. Widget shows were similar to its idea and current setup and state.

Flutter automated testing empowers you to meet high responsiveness in your application as it helps in discovering bugs and various issues in your application. A Flutter is a tool for developing mobile, desktop, web applications with code & is a free and open-source tool.

Hello friends In this blog, we will learn about Under the hood rendering in flutter?. In this, we will see how Flutter provides an overview of the architecture and how to execute dart’s code behind the scenes in mobile. so let’s get started.


Table Of Contents :

Flutter Rendring

Flutter architectural Overview

Let’s go through this rendering stepwise manner

How to run flutter code runs on the device

Conclusion


Flutter Rendering:

The rendering layer in the flutter is an abstraction dealing with the layout. This lets you build a tree of objects to render. All of these objects can be dynamically manipulated. The tree detects our objects and automatically updates the layout for its changes.

Flutter widgets are reactive. They respond to any new information from an outside source. Consider a Stateful component as a parent to another Stateless component.

In that case whenever one of the states on which the stateless component was relying on changes, the widget calls didUpdateWidget life cycle method and repaints if necessary. For example:

IconButton(
icon: Icons.add,
onPressed: (){
setState((){
this.value++;
})
}
),
Text("Value = ${this.value}")

Flutter architectural overview:

There are mainly three layers in the architecture of Flutter, each layer has a set of libraries, let us see them in detail.

  • Framework
  • Engine
  • Embedder

=> Framework: To interact with Flutter, developers use the Framework layer, which is written in the Dart language. It provides a modern responsive framework. It consists of a variety of components. It includes high-level widgets such as animations, rendering logic, etc. Cupertino also provides libraries such as Material that help implement iOS designs and Material Design.

Components of Framework:

  • Foundation: It’s a kind of basic foundation class that provides building blocks such as painting, animation gestures.
  • Widgets: Use of Widgets we provide whatever its related widget is in making the layout, in the same way, everything in Flutter is a widget.
  • Material & Cupertino: Material and Cupertino widgets are used to create layouts and convert the design of iOS.

=> Engine: Flutter’s engine is written mostly C/C++. It provides low-level implementations of Flutter’s core API, including graphics, text layout, plugin architecture, file, and network I/O, accessibility support, and the dart runtime compile toolchain. responsible for running the compiled dart code on the engine’s device with the help of dart runtime.

=> Embedder:
Flutter Embedder provides the entry point for a platform-specific Flutter app. It receives a thread for the Flutter UI and it also initializes the Flutter engine. Using embedder, we can integrate Flutter’s code into the existing application as a module. Maybe the code of the ambassador is written in a language that is suitable for the platform.

For Example:

Embedder Java and C++ for Android, Embedder Objective-C/Objective-C++ for iOS and macOS, and K++ for Windows and Linux.

Let’s go through this rendering stepwise manner:

  • Now our application calls the setState() method in the iconButton.onPressed() callback.
  • Flutter then finds that the state value inside it is completely updated and needs to be recreated.
  • New Widget Widget Tree replaces the old one after the update
    After updating the New Widget widget tree replaces the old one and then renders the new one.

Rendering Pipeline(User Input):

It describes the rendering pipeline that the Flutter rendering engine takes when rendering objects. How the data flows through the system is shown in a diagram.

  • Animation: In Flutter Animation, Flutter first starts an animation ticker and then stops the Flutter rendering process as we scroll down the list of any item to move the list of items for such a scenario. We can control this by animation tricker. and determines the time when any element is moved.
  • Build: The build method builds the widget tree, taking into account the different configurations of the widget while building it, this means how the widget will look on our screen Widgets handle the same configuration that is applied to the screen.
  • Layout: As soon as our widget is built, it starts thinking about the process of layout, it is a way to efficiently determine the part of the important widgets within the UI framework. Has the ability to determine the size and position of the layout before displaying it on the screen The render tree creates a base class for each that defines an abstract model for the layout
Widget build(BuildContext context) {
return Container(
child: Row(
children: List<Widget>[
IconButton(
icon: Icons.add,
onPressed: () {
setState(() {
this.value++;
});
}),
Text("Qty: ${this.value}")
],
)
);
}
  • Paint: Flutter gets an idea of ​​the constraints of all the widgets then it can paint the entire widget to make sure there are conflicts.
  • Composting: In this step, we will see that Composting Flutter displays the actual widget coordinates on the screen. There are many reasons that keep it apart from painting. Instead of building up your entire list when someone scrolls or closes it on the new screen, Flutter can pre-draw it and plug it in where they need to go

How to run flutter code runs on the device:

Below is a simplistic representation of how the dart code runs on the device.

  • Before the code is run in Dart, first of all, the code of Dart is compiled into the Arm library code.
  • After this, the compiled code is embedded in the APK or IPA file.
  • Now when we open the app flutter embedder code is started and it starts the app.

Conclusion:

In this article, I have explained an Under The Hood Rendering in a flutter, which you can modify and experiment with according to your own, this little introduction was from the Under The Hood Rendering.

I hope this blog will provide you with sufficient information on Trying up the Under The Hood Rendering in your flutter project. We showed you the Explore Under The Hood Rendering and worked on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.

From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, and LinkedIn for any flutter-related queries.

Version Management In Flutter

0

Flutter is a portable UI toolkit. In other words, it’s a comprehensive app Software Development toolkit (SDK) that comes complete with widgets and tools. Flutter is a free and open-source tool to develop mobile, desktop, web applications. Flutter is a cross-platform development tool. This means that with the same code, we can create both ios and android apps. This is the best way to save time and resources in our entire process. In this, hot reload is gaining traction among mobile developers. Allows us to quickly see the changes implemented in the code with hot reload.

Flutter Management Version allows different types of flutter versions to be available on a project basis. This means that we can define specific types of flutter versions for different types of projects, it allows us to release multiple channels, cache it locally, so switch versions. then we don’t have to wait for setup.

In this article, we will learn about Version Management In Flutter. In this, we will see how to set up work Version Management in a flutter. so let’s get started. so let’s get started.


Table Of Contents :

FLutter Version Management (FVM)

FVM Install

Install SDK Version

Set Up IDE

Conclusion


Flutter Version Management (FVM):

When we work on our flutter project, we need to release the updated flutter and the app, verify it, and switch different types of SDK to test it, which takes us time for development. To avoid this, we use Flutter Version Management, which provides us with different types of Flutter versions for our machines. So that each time Flutter can test the app against the updated Flutter release without waiting for installation and will be able to switch to the Flutter version accordingly.

FVM Install:

First of all, we need to make sure that flutter is already installed and whether the flutter is the stable channel. if not then Type the below code in your command line.

// set flutter to stable channel
flutter channel stable// check flutter channel
flutter channel// output
Flutter channels:
master
dev
beta
* stable
  • After this, we have to determine whether our flutter is already installed or not, if not then first we will install FVM.
$ pub global activate fvm
  • We will now see that some warnings are given at the end of the installation process, so we need to add the fvm path to the shell configuration file (.bashrc, bash_profile, etc.) before taking the next step
export PATH=”$PATH:`pwd`/flutter/bin”$ fvm install
export PATH=”$PATH:`pwd`/bin/cache/dart-sdk/bin”
export PATH=”$PATH:`pwd`/.pub-cache/bin”

SDK Version lnstall:

DVM allows us to install multiple types of flutter release or channels To install the channel use stable and to install the release version of flutter we will use v2.0.5 or 1.17.0-dev.3.1 and as soon as we run — skip-setup after that it will skip the setup

$ fvm install stable or fvm install 2.0.5

Project Config SDK Version:

After that, we will see that Whether the project is configured to use a specific version or not, if not, we will install it on the appropriate version without arguments.

$ fvm install

Flutter Installed Versions List:

Now by typing in the following command we can list the installed version on our machine by using the below command FVM will store the SDK version.

$ fvm list

Upgrade SDK Version:

Using upgrade SDK version command when we need to upgrade our current SDK version so you have to call command of your flutter SDK as in normal flutter installation.

$ fvm flutter upgrade

Set Up IDE:

Now we will see how to configure IDE, below we have shown how to configure in the android studio and vs code let’s see it now.

=> Android Studio:

In Your root project directory copy the absolute following symbolic link.

Example: /absolute/path-to-your-project/.fvm/flutter_sdk

After that we will open Languages ​​and Frameworks in the menu of Android Studio -> Now search for flutter or flutter and change the path to flutter SDK. and implement the change. Now you can run it with selected versions of flutter and debug it. If you want to see the new setting made then we can use Android Studio will restart again.

=> VS Code:

Now we will configure VS Code here we will see how to complete the VS Code process.

  • We can see all the installed versions by FVM in the code by providing the path to the flutter SDK version directory.
  • After that press, Cmd + then go to Settings.json and paste the below path.
"dart.flutterSdkPaths": ["$YOUR_PATH/fvm/versions",],
  • To get the above path we will execute the fvm list command.
// copy this path
Versions path: $YOUR_PATH/fvm/versions

After that type cmd + shift + p to use the sdk and type change sdk now and now you can choose your preferred version.

Conclusion:

In this article, I have explained Version Management in a flutter, which you can modify and experiment with according to your own, this little introduction was from the Version Management In Flutter.

I hope this blog will provide you with sufficient information on Trying up the Version Management In Flutter. We showed you the Explore Version Management In Flutter and worked on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.


From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, and LinkedIn for any flutter-related queries.

Automatic Generate JSON Serializable In Flutter

0

Flutter is a portable UI toolkit. In other words, it’s a comprehensive app Software Development toolkit (SDK) that comes complete with widgets and tools. Flutter is a free and open-source tool to develop mobile, desktop, web applications. Flutter is a cross-platform development tool. This means that with the same code, we can create both ios and android apps. This is the best way to save time and resources in our entire process.

In this article, we will explore the Automatic Generate JSON Serializable In Flutter using josn_serializable_package and json_annotation, and see how to use it to parse our model into Json and generate our own code by serializing it. so let’s get started.


Table Of Contents :

Generate JSON Serializable

Implementation

Code Implementation

Code File

Conclusion


JSON Serializable:

The JSON (JavaScript Object Notation) is a kind of data format that encodes an object into a string. This kind of data can be easily translated between server and browser, and server to server. Serialization is a process that converts an object into the same string. For this, we use a json_serialization package however it can generate a model class for you as per the annotations provided with the help of the json_annotation library.

Implementation :

Whenever we have to create models and factories. Because models don’t always change so you don’t need to change models all the time. So to use JSON we have to add some of the following packages which are explained below.

  • json_serializable: This is provided to a Dart build system. It generates code when it finds annotated members in a class defined with json_annotation.
  • json_annotation: It defines the annotation used by Json_serializable to create JSON serialization, deserialization type of code.
  • build_runner: We use the build_runner package to generate files using dart code.

Let us now see how we add all these packages to our pubspec.

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:

dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
json_annotation: ^4.0.1dev_dependencies:
flutter_test:
sdk: flutter

build_runner: ^2.0.5
json_serializable: ^4.1.3

Step 2: Importing

import 'package:json_annotation/json_annotation.dart';
import 'package:build_runner/build_runner.dart';
import 'package:json_serializable/json_serializable.dart';

Step 3: Enable AndriodX

org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true

How to implement code in dart file :

You need to implement it in your code respectively:

First, we will create a model class of ours which we named user. dart.

Now we will see how manual serialization is done natively supported by Dart with the dart: convert library. User dart file is ready then we will have a list of data JSON objects inside it each object will have a user name, last name, and its address which we have defined in the variable of string type as you will see in the data class we have two We need to create functions called fromJson and toJson which, respectively, translate a JSON to our user.

import 'package:json_annotation/json_annotation.dart';
part 'user.g.dart';

@JsonSerializable()
class User {
String name, lastName, add;
bool subscription;

User({this.name,this.lastName,this.add,this.subscription,});

factory User.fromJson(Map<String,dynamic> data) => _$UserFromJson(data);

Map<String,dynamic> toJson() => _$UserToJson(this);

}

Now, this _$UserFromJson(json) will be generated by json_serializer when we run the build _runner command. From which we will get the user.g.dart file.

To run the build_runner command, we will open a terminal in our Android Studio and type the following line.

flutter pub run build_runner build

When we run the command in build runner, some line will appear and after some time it is generated successfully.

INFO] Generating build script...
[INFO] Generating build script completed, took 301ms[INFO] Initializing inputs
[INFO] Reading cached asset graph...[INFO] Reading cached asset graph completed, took 305ms[INFO] Checking for updates since last build...[INFO] Checking for updates since last build completed, took 1.5s[INFO] Running build...[INFO] Running build completed, took 4.7s[INFO] Caching finalized
dependency graph...[INFO] Caching finalized dependency graph completed, took 44ms[INFO] Succeeded after 4.8s with 0 outputs (1 actions)

After the build_runner process is finished we add a new file named user.g.dart below a user file that contains our serialization code. As we make a new model, then we flow through this process.

// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'user.dart';

// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************

User _$UserFromJson(Map<String, dynamic> json) {
return User(
name: json['name'] as String,
lastName: json['lastName'] as String,
add: json['add'] as String,
subscription: json['subscription'] as bool,
);
}

Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{
'name': instance.name,
'lastName': instance.lastName,
'add': instance.add,
'subscription': instance.subscription,
};

After this, we have created a class in which we have shown a list item for which we have defined a future builder list view builder inside which we have defined the item of our user list in the text widget.

FutureBuilder<List<User>>(
future: getData(),
builder: (context, data) {
if (data.connectionState != ConnectionState.waiting &&
data.hasData) {
var userList = data.data;
return ListView.builder(
itemCount: userList.length,
itemBuilder: (context, index) {
var userData = userList[index];
return Container(
height: 100,
margin: EdgeInsets.only(top: 30, left: 20, right: 20),
decoration: BoxDecoration(
color: Colors.grey.shade200,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
padding: EdgeInsets.all(15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
'First Name: ' + userData.name,
style: TextStyle(
fontWeight: FontWeight.w600,),
),
],
),
);
});
} else {
return Center(
child: CircularProgressIndicator(),
);
}
})

When we run the application, we ought to get the screen’s output like the underneath screen capture.

Code File :

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_json_serilization_exm/main.dart';
import 'package:flutter_json_serilization_exm/model/user.dart';

class JsonSerilization extends StatefulWidget {
@override
_JsonSerilizationState createState() => _JsonSerilizationState();
}

class _JsonSerilizationState extends State<JsonSerilization> {
Future<List<User>> getData() async {
return await Future.delayed(Duration(seconds: 2), () {
List<dynamic> data = jsonDecode(JSON);
List<User> users = data.map((data) => User.fromJson(data)).toList();
return users;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Json Serialization Demo"),
),
body: Container(
child: FutureBuilder<List<User>>(
future: getData(),
builder: (context, data) {
if (data.connectionState != ConnectionState.waiting &&
data.hasData) {
var userList = data.data;
return ListView.builder(
itemCount: userList.length,
itemBuilder: (context, index) {
var userData = userList[index];
return Container(
height: 100,
margin: EdgeInsets.only(top: 30, left: 20, right: 20),
decoration: BoxDecoration(
color: Colors.grey.shade200,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
padding: EdgeInsets.all(15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(
'First Name: ' + userData.name,
style: TextStyle(
fontWeight: FontWeight.w600, fontSize: 15),
),
Text(
'Last Name: ' + userData.lastName,
style: TextStyle(
fontWeight: FontWeight.w600, fontSize: 15),
),
Text(
'Add: ' + userData.add,
style: TextStyle(
fontWeight: FontWeight.w600, fontSize: 15),
),
],
),
);
});
} else {
return Center(
child: CircularProgressIndicator(),
);
}
}),
),
);
}
}

Conclusion :

In this article, I have explained Automatic Generate JSON Serializable In Flutter, which you can modify and experiment with according to your own, this little introduction was from the Automatic Generate JSON Serializable In Flutter demo from our side.

I hope this blog will provide you with sufficient information in Trying up the Automatic Generate JSON Serializable In Flutter in your flutter project. We showed you what the Automatic Generate JSON Serializable In Flutter is and work on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.

From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, and LinkedIn for any flutter-related queries.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.

Exploring Flutter Navigator 2.0: VRouter

0

Flutter has made it quite easy to develop complex UIs for developers. 
Flutter is a very performant app development framework that is written in Dart. It interacts efficiently and very easily on a native device. It is supported by Google.
Flutter automated testing empowers you to meet high responsiveness in your application as it helps in discovering bugs and various issues in your application. Flutter is a tool for developing mobile, desktop, web applications with code & is a free and open-source tool.

Hello friends In this blog, we will learn about Exploring Flutter Navigator 2.0: VRouter?. In this, we will see how to use Flutter Navigator 2.0: VRouter. so let’s get started.

vrouter | Flutter Package
A Flutter package that makes navigation and routing easy. Learn more at vrouter.dev Here are a few things that this…pub.dev


Table Of Contents :

Exploring Flutter Navigator

Implementation

Code Implementation

Conclusion


Exploring Flutter Navigator:

We use the router to handle the routing of any page, as its name suggests, by using the router package, we can manage the routing of our page, for this, we just need to create different routes for our page. For this, we have to define the route parameter.

Implementation:

Let us now see how we add all these packages to our pubspec.

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies :dependencies:
vrouter: ^1.1.0

Step 1: Install :

You can install packages from the command line:

flutter pub get

Step 2: Importing :

import 'package:vrouter/vrouter.dart';

Step 3: Enable AndriodX :

org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true

Code Implementation:

You need to implement it in your code respectively:

First of all, to handle the routing of any screen, we will use the VRouter widget as I have initialized this package in the implementation, in we will use the routes parameter to create our different routes and define it as below I have defined through a code reference for understanding.

VRouter(
initialUrl: '/homeItem',
routes: [
VWidget(
path: '/homeItem',
widget: HomeItemScreen(homeItemScreen: homeItem),
stackedRoutes: [
VWidget(
path: r':title',
widget: Builder(
builder: (context) => DetailsScreen(
homeItem: homeItem.firstWhere(
(homeItem) =>
homeItem.title ==
context.vRouter.pathParameters['title'],
),
),
),
),
],
),

VRouteRedirector(path: r':_(.+)', redirectTo: '/books'),
],
),

Now we will create an item list whose item class will be defined in the widget of the VRouter widget.

Before creating the list of items we will create a model class as I have referenced in the code below.

class HomeItem {
final String img;
final String title;
final String price;

HomeItem(this.img, this.title, this.price);
}

After this, we have taken the listview widget in which we have shown the image, title, and price of the item and on click of its item, a list detail screen will open.

ListView(
children: [
for (var homeItem in homeItemScreen)
GestureDetector(
onTap: () {
context.vRouter.push('${homeItem.title}');
},
child: Container(
margin: EdgeInsets.only(left: 15, right: 15, top: 20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
height: 85,
child: Row(
children: [
ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(10)),
child: Image.asset(
homeItem.img,
fit: BoxFit.cover,
height: 85,
width: 100,
),
),
SizedBox(
width: 15,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(homeItem.title,
style: TextStyle(
fontFamily: 'Poppins Regular',
fontWeight: FontWeight.w700,
fontSize: 13)),
SizedBox(
height: 2,
),
Text(homeItem.price,
style: TextStyle(
fontSize: 12, fontFamily: 'Poppins Medium')),
],
),
],
),
),
),
],
),

Now our item list is ready and visible and when we click on it, it goes to the next page whose detail class we have defined in our detail screen in builder inside stackedRoutes in the router so that the routing of our page handles.

Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(10)),
child: Image.asset(
homeItem.img,
height: 200,
fit: BoxFit.cover,
width: 1000,
),
),
SizedBox(
height: 20,
),
Text(homeItem.title, style: Theme.of(context).textTheme.headline6),
SizedBox(
height: 10,
),
Text(homeItem.price, style: Theme.of(context).textTheme.subtitle1),
],
),

When we run the application, we ought to get the screen’s output like the underneath screen capture.

Code File:

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

void main() {
List<HomeItem> homeItem = [
HomeItem('assets/images/hanging-lamp.png', 'Hamnger Lamp', '\$56.00'),
HomeItem('assets/images/furniture.png', 'Decor Furniture', '\$70.00'),
HomeItem('assets/images/home-decor.png', 'Decoration Item', '\$34.00'),
HomeItem('assets/images/marble-table.png', 'Marble Table', '\$48.00'),
HomeItem('assets/images/portable-speaker.png', 'Portable Speaker', '\$68.00'),
HomeItem('assets/images/hanging-lamp.png', 'Hamnger Lamp', '\$56.00'),
HomeItem('assets/images/furniture.png', 'Decor Furniture', '\$70.00'),
];

runApp(
VRouter(
initialUrl: '/homeItem',
routes: [
VWidget(
path: '/homeItem',
widget: HomeItemScreen(homeItemScreen: homeItem),
stackedRoutes: [
VWidget(
path: r':title',
widget: Builder(
builder: (context) => DetailsScreen(
homeItem: homeItem.firstWhere(
(homeItem) =>
homeItem.title ==
context.vRouter.pathParameters['title'],
),
),
),
),
],
),

VRouteRedirector(path: r':_(.+)', redirectTo: '/homeItem'),
],
),
);
}

class HomeItem {
final String img;
final String title;
final String price;

HomeItem(this.img, this.title, this.price);
}

class HomeItemScreen extends StatelessWidget {
final List<HomeItem> homeItemScreen;

HomeItemScreen({required this.homeItemScreen});

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey.shade100,
appBar: AppBar(
title: Text('VRouter Demo'),
),
body: ListView(
children: [
for (var homeItem in homeItemScreen)
GestureDetector(
onTap: () {
context.vRouter.push('${homeItem.title}');
},
child: Container(
margin: EdgeInsets.only(left: 15, right: 15, top: 20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
height: 85,
child: Row(
children: [
ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(10)),
child: Image.asset(
homeItem.img,
fit: BoxFit.cover,
height: 85,
width: 100,
),
),
SizedBox(
width: 15,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(homeItem.title,
style: TextStyle(
fontFamily: 'Poppins Regular',
fontWeight: FontWeight.w700,
fontSize: 13)),
SizedBox(
height: 2,
),
Text(homeItem.price,
style: TextStyle(
fontSize: 12, fontFamily: 'Poppins Medium')),
],
),
],
),
),
),
],
),
);
}
}

class DetailsScreen extends StatelessWidget {
final HomeItem homeItem;

DetailsScreen({
required this.homeItem,
});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title:Text('Detail Screen'),
),
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(10)),
child: Image.asset(
homeItem.img,
height: 200,
fit: BoxFit.cover,
width: 1000,
),
),
SizedBox(
height: 20,
),
Text(homeItem.title, style: Theme.of(context).textTheme.headline6),
SizedBox(
height: 10,
),
Text(homeItem.price, style: Theme.of(context).textTheme.subtitle1),
],
),
),
);
}
}

Conclusion:

In this article, I have explained Exploring Flutter Navigator 2.0: VRouter, which you can modify and experiment with according to your own, this little introduction was from the Exploring Flutter Navigator 2.0: VRouter demo from our side.

I hope this blog will provide you with sufficient information in Trying up the Exploring Flutter Navigator 2.0: VRouter In Flutter in your flutter project. We showed you what the Exploring Flutter Navigator 2.0: VRouter is and work on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

If I got something wrong? Let me know in the comments. I would love to improve.

Clap 👏 If this article helps you.

From Our Parent Company Aeologic

Aeologic Technologies is a leading AI-driven digital transformation company in India, helping businesses unlock growth with AI automation, IoT solutions, and custom web & mobile app development. We also specialize in AIDC solutions and technical manpower augmentation, offering end-to-end support from strategy and design to deployment and optimization.

Trusted across industries like manufacturing, healthcare, logistics, BFSI, and smart cities, Aeologic combines innovation with deep industry expertise to deliver future-ready solutions.

Feel free to connect with us
And read more articles from FlutterDevs.com.

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, and LinkedIn for any flutter-related queries.

We welcome feedback and hope that you share what you’re working on using #FlutterDevs. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences.