Google search engine
Home Blog Page 42

Example Animations in Flutter — #2

0

Introduction

In this blog, we’re going to implement some examples of basic animations in Flutter. In the previous article, I explained some basic concepts of animation which needs to be understand before diving into animation. So, if you want to understand those concepts of animation, head over to that article.


Let’s Start

First, we’ll see very simple rotation animation.

Create home_screen.dart file and copy the following code inside it

https://gist.github.com/flutter-devs/383d3c50b4d8ec79a5bacd55566f9beb#file-home_screen-dart

In initState() method, _arrowAnimationController is initialised with duration of animation equal to 300 milliseconds.

After that, _arrowAnimation is initialise with begin value of 0.0 and end value of pi (value = 180) so that, it will rotate by 180 degrees.

Now, comes the layout part of the screen, paste the following code inside build() method

https://gist.github.com/flutter-devs/2473e9cc9cf4c2e139e177ca7790566b#file-home_screen-dart

Now, let’s create firstChild() Widget, where the actual widget will be present that contains a widget that needs to be animate and another widget that starts the animation.

https://gist.github.com/flutter-devs/43b76678d571495574a857b834bc8e7c#file-home_screen-dart

In the given code, first child of Row is Icon that needs to be animated and it is wrapped with AnimatedBuilder widget.

AnimatedBuilder widget is a widget that is useful for building animations. It is more effective and efficient way of animating any Widget than calling setState() method on each change in value of animation.

2 properties of AnimatedBuilder widget are specified in the given code —

  • animation — It expects a animationController that is responsible for controlling animation. In this case, we’ve specified _arrowAnimationController which controls the arrow animation which we’re implementing
  • builder — It’s a callback function which is called everytime the value of animation changes. In the builder function, we’re returning Icon widget which is wrapped with Transform.rotate() widget.

Transform.rotate() widget is a special type of widget that transforms its child using a rotation with respect to center using its angle property which specify the angle by which the widget needs to be rotated

Now, another widget in the Row is OutlineButton which is used for starting the animation. In the onPressed() callback, we’re checking if the given animation is completed, and, if the button is again clicked, then the animation is reversed else just start the animation in forward direction

Now, let’s see a beating heart animation…

https://gist.github.com/flutter-devs/f0243fffac2d4a5fdc349336090fe01b#file-home_screen-dart

In home_screen.dart file, create two more variables _heartAnimation and _heartAnimationController of Animation and AnimationController respectively.

Inside initState() method, _heartAnimationController is initialised with duration of 1200 milliseconds. After that, _heartAnimation is initialised with the begin and end value of 150.0 and 170.0 and then, CurvedAnimation is specified with bounceOut curve, so that, the heart icon will show some bouncing effect

And atlast, we’re attaching the statusListener with _heartAnimationController, and checking if _heartAnimation is completed, then, we’re repeating the animation.

Now, we’ll attach this animation with a heart icon

https://gist.github.com/flutter-devs/89e362502fef09502479896e3f006268#file-home_screen-dart

Inside, secondChild() widget, first child of Row is heart icon on which we’ve to show animation. It is wrapped with AnimatedBuilder widget so that it will animate according to the given animation. In the size of Icon, _heartAnimation.value is specified which means that as soon as the value of _heartAnimation changes, size of icon will also change with the _heartAnimation value.

Second child of Row is OutlineButton which is responsible for starting the heartAnimation. And finally, override dispose() method, and dispose both AnimationController objects.

https://gist.github.com/flutter-devs/77a412b8927fc7c7c53ef2a9f3ec3710#file-home_screen-dart

Now, let’s move on to another animation which is a little bit complex…

Inside home_screen.dart file, add another OutlineButton which is responsible for navigating to another screen where we’ll see another beautiful animation.

https://gist.github.com/flutter-devs/9dbb73e4997b17d6cb846fb34a50483c#file-home_screen-dart

Inside AnimatedScreen class, we’ll create these two animations

  • Let’s create the first animation…

In both these animations, 3 animations are happening simultaneously —

  • First, Container size is increasing
  • Second, Container radius is changing
  • Third, Container colour is changing

Paste the following code inside AnimatedScreen class –

https://gist.github.com/flutter-devs/1e3fe5e5b266e7870c688c58dd4d7037#file-home_screen-dart

Declare 3 Animation objects — _containerRadiusAnimation, _containerSizeAnimation, _containerColorAnimation and one AnimationController object — _containerAnimationController

Inside initState() method, _containerAnimationController is initialised with the duration of 5 seconds.

After that, _containerRadiusAnimation is initialised with BorderRadiusTween which interpolates between two BorderRadius values. Here, in begin value BorderRadius of Container is 100.0 so that initially it appears as a circle and in end value BorderRadius of Container is 0.0, so that at last, it appears as a rectangle. And finally we’re attaching _containerAnimationController with _containerRadiusAnimation.

Now, _containerSizeAnimation is initialised with Tween which interpolates between two double values. Here, begin value is 0.0 so that the size of Container remains 0.0 initially and end value is 2.0. And finally we’re attaching _containerAnimationController with _containerSizeAnimation.

Now, _containerColorAnimation is initialised with ColorTween which interpolates between two Color values. Here, in begin value Color of Container is black and in end value Color of Container is white. And finally we’re attaching _containerAnimationController with _containerColorAnimation.

And finally, we’re starting the animation.

Now, let’s attach the animation with the Container…

https://gist.github.com/flutter-devs/5614a44031e44c896af5256e9ff362d4#file-animated_screen-dart

AnimatedBuilder is specified in the body of Scaffold and in the builder callback, Container is returned. In the transform property, Translation matrix is specified and value of x-coordinate is _containerSizeAnimation.value * width which means that initially, the x coordinate will be 0.0 and atlast, value of x coordinate will be 2 * (screenWidth) — 200.0 and value of y and z coordinate is 0.0 which means that it’ll only change it’s x coordinate (move horizontally).

Width and height of Container is _containerSizeAnimation.value * height which means that it’ll gradually increase it’s size. At last, value of borderRadius is _containerRadiusAnimation.value which means that borderRadius of Container will decrease from 100.0 to 0.0

That’s all, This will create the following animation

Now, to create second animation, just remove the transform property of Container and see the effect. That will create following animation.

Complete code is available here

https://github.com/flutter-devs/flutter_animation_example


I got something wrong? Mention it in the comments. I would love to improve.

If you learnt even a thing or two, clap your hands 👏 as many times as you can to show your support!

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 FacebookGitHubTwitter, 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.


Related: Hero Animations In Flutter

Related: Exploring Text Animations In Flutter

Related: Built-in Explicit Animations in Flutter

Need expert help building your Flutter app? Talk to FlutterExperts for architecture, development, and consulting support.

Complete Guide to Error Handling in Flutter 2026

0

The Dart language offers natives like try, catch, and throw for dealing with errors and particular cases in our applications.

This blog will explore the Functional Error Handling In Flutter. We will learn how to execute a demo program and understand error handling by learning Either type from the fpdart package in your flutter applications.

If you’re looking for the best Flutter app development company for your mobile application then feel free to contact us at — support@flutterdevs.com.


Table Of Contents::

What is Functional Programming?

Demo: Parsing a Number

Either type

Comparing Either and Result

Either & the tryCatch Factory Constructor

Conclusion



What is Functional Programming?

Functional programming (or FP) is an intriguing point that advances utilizing pure functions, immutable data, and a revelatory programming style, assisting us with composing all the more perfect and viable code.

This is rather than object-arranged programming (OOP), which depends on variable states and a basic programming style to depict the information and conduct of the items in our framework.

Since numerous advanced languages support both functional and object-situated ideal models, you can take on one style or the other as you see fit in your code.

In fact, you may have already used FP in your Dart and Flutter code by:

  • passing a function as an argument to another capability, (for example, a > callback)
  • utilizing the map, where, reduce functional operators on Iterable sorts like list and streams
  • working with generics and type inference

Demo: Parsing a Number

If we have any desire to parse a String containing a numerical value into a double, we can compose code like this:

final value = double.parse('155.50');

However, what would happen if we tried running this?

final value = double.parse('not-a-number'); 

This code throws an exception at runtime.

In any case, the mark of the parse function doesn’t let us know this, and we need to peruse the documentation to find out:

static double parse(String source);

If we want to handle the FormatException, we can use a try/catch block:

try {
final value = double.parse('not-a-number');
// handle success
} on FormatException catch (e) {
// handle error
print(e);
}

However, on large codebases, it’s challenging to figure out what abilities could throw and which don’t.
Ideally, we accept the signature of our functions ought to make it unequivocal that they can return an error.

Either type:

Either type from the fpdart package allows us to determine both the disappointment and achievement types as a component of the capability signature:

import 'package:fpdart/fpdart.dart';

Either<FormatException, double> parseNumber(String value) {
try {
return Either.right(double.parse(value));
} on FormatException catch (e) {
return Either.left(e);
}
}

The values inside Either. left and Error. right should match the sort explanations we have characterized (FormatException and double for this situation). Continuously use Either. left to represent errors, and Either. right to represent the return esteem (achievement).

Comparing Either and the Result:

From the beginning, Either is the same as the Result type that is accessible in the multiple_result package:

Result<FormatException, double> parseNumber(String value) {
try {
return Success(double.parse(value));
} on FormatException catch (e) {
return Error(e);
}
}

In fact, only the basic syntax changes:

  • Either.right ↔ Success
  • Either.left ↔ Error

But Either has a much more extensive and powerful API.

Either & the tryCatch Factory Constructor:

If we have any desire to improve on our execution, we can utilize the tryCatch factory constructor:

Either<FormatException, double> parseNumber(String value) {
return Either.tryCatch(
() => double.parse(value),
(e, _) => e as FormatException,
);
}

This is how tryCatch is implemented:


factory Either.tryCatch(
R Function() run, L Function(Object o, StackTrace s) onError) {
try {
return Either.of(run());
} catch (e, s) {
return Either.left(onError(e, s));
}
}

Note that the onError callback gives the error and stack trace as arguments, and the error type is Object.

But since we know that the double.parse the function can only ever throw a FormatException, it’s safe to cast e as a FormatException in our parseNumber function.

Conclusion:

I hope this blog will provide you with sufficient information on Trying Functional Error Handling In Flutter. We’ve now ventured into the world of functional programming, by learning about Either and the fpdart package.

  • we can utilize Either<L, R> as an option in contrast to throwing exceptions at whatever point we need to proclaim mistakes expressly in the mark of our capabilities/strategies.
  • If we use Either and don’t deal with errors, our code will not arrange. This is superior to finding errors at runtime during development.
  • Either accompanies a broad Programming interface, making it simple to control our data with a valuable practical operator like map, mapLeft, fold, and numerous others.

❤ ❤ 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! For any flutter-related queries, you can connect with us on FacebookGitHubTwitter, and LinkedIn.

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.

Related: Flash Error Messages In Flutter

Related: SMS Using Twilio In Flutter

Need expert help building your Flutter app? Talk to FlutterExperts for architecture, development, and consulting support.


Bottom Navigation Bar with Provider in Flutter 2026

In this article, I’ll be showing you how you can use Flutter Provider package in the BottomNavigationBar.

What is Provider?

Provider is a new state management approach recommended by the Flutter team.

Note
setState also works fine for many case , you should not use it every where .
But in case you have a messy code like you have a FutureBuilder in the build then setState will definately cause problem.

Let’s see how we can use it in BottomNavigationBar.

Step 1: Add the dependency in your pubspec.yaml.

provider : <latest-version>

Step 2: Create a provider class

class BottomNavigationBarProvider with ChangeNotifier {
int _currentIndex = 0;

get currentIndex => _currentIndex;

set currentIndex(int index) {
_currentIndex = index;
notifyListeners();
}
}

In this provider, I am storing the current value of the BottomNavigationBar and when the current value is set into to provider, the BottomNavigationBar will be notified with the current value and update the tab.

Step 3: Wrap parent Widget with ChangeNotifierProvider

home: ChangeNotifierProvider<BottomNavigationBarProvider>(
child: BottomNavigationBarExample(),
builder: (BuildContext context) => BottomNavigationBarProvider(),
),

I have wrapped my widget with ChangeNotifierProvider so my widget will be notified when the value changes.

Step 4: Create tabs for BottomNavigationBar

/media/7d35f19dd026ff04c66dc5949141d9d6

I have three widgets tabs which I’ll attach with my bottom navigation bar.

Step 4: Create BottomNavigationBar with provider

/media/f685773a51366e2d6cf18b838fa21e07

So I have created a list for the screens and change the screens with an index which is provided by the provider and the tab changes the provider updates the index.

Here is the code for the above example :

flutter-devs/Flutter-BottomBarProvider
A sample application for bottom bar using Provider. – flutter-devs/Flutter-BottomBarProvidergithub.com

Persistent BottomNavigationBar

Provider works great when changing the tabs without using setState but if you want to keep your state of the screens attached with the tabs, try using PageStorageBucket , I have attached an example by Tensor Programming below:

tensor-programming/flutter_presistance_bottom_nav_tutorial
Contribute to tensor-programming/flutter_presistance_bottom_nav_tutorial development by creating an account on GitHub.github.com


Thanks for reading this article ❤

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

Clap 👏 If this article helps you.

Connect with me on Linkedin and Github


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 FacebookGitHubTwitter, 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.

Need expert help building your Flutter app? Talk to FlutterExperts for architecture, development, and consulting support.


Firebase ML Kit in Flutter — Part 1

0

Firebase is basically a mobile and web application development platform used to help in building high-quality apps.

Flutter is basically a mobile application development framework used to build apps for both Android and iOS from a single codebase.

Firebase provides a variety of products such as realtime-database, cloud storage, ML Kit, etc. and we can integrate them in Android, iOS and Flutter application. So in this series, I will cover how to integrate Firebase ML Kit in your Flutter application. But first of all, let’s see how to setup Firebase in your Flutter app (for both Android and iOS).

Firebase Setup:

  1. Create a new project in Firebase console.

2) After your project is ready, the following screen will appear in the console, if you want to setup firebase for your Android app then click on Android icon else click on iOS icon for the iOS application. In this blog, we will set up for both platforms.

In order to add firebase to your project, you first need to create a new flutter application. Open your terminal and copy the following command for creating a new flutter project. Here “mlkit_demo” is the name of a project.

Setup for Android app :

  • After clicking on Android icon in firebase console, you will see the following screen, In order to add Firebase in your Android app, you will need app’s package name and SHA-1 certificate.
  • For app’s package name, open your flutter application and inside this go to “android/app/src/AndroidManifest.xml”.
  • For SHA-1 certificate, copy the following command. After writing this command it will ask for the keystore password, the password is: “android
  • After registering your app with firebase, download “google-services.json” file and copy this file inside the “android/app” directory.
  • Now, add some Google services and firebase dependencies to your Android app.

That’s it for Android. Now we’ll set up for iOS app.


Setup for iOS app :

  • After clicking on the iOS icon in the console, you will see the following screen. In order to add Firebase in your iOS app, you will need iOS bundle ID, in case of iOS, it doesn’t matter that you have to write only the app’s package name instead you can give any name to it. For this project, I am giving it as “mlkit.demo”.
  • After registering your app with firebase, download “GoogleService-Info.plist” file and copy this file inside “ios/Runner” directory.

That’s it for iOS as well, Now I will add some packages to our flutter app that we created earlier in this blog.


Open “pubspec.yaml” file from your flutter app and add the following package inside it. After adding this, get your packages.

firebase_ml_vision:

That’s it from this blog, in the next part of the series I will show you some of the exciting features of Firebase ML Kit.


I got something wrong? Mention it in the comments. I would love to improve.

If you learnt even a thing or two, clap your hands 👏 as many times as you can to show your support

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 FacebookGitHubTwitter, 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.

Related: Maintain Activity Log in Firebase Using FlutterFlow

Related: Using Firebase Firestore in Flutter

Need expert help building your Flutter app? Talk to FlutterExperts for architecture, development, and consulting support.


Developing packages in Flutter

Introduction

In this blog, I’m going to show you how to develop a package in Flutter and upload it to pub.dev

Let’s Start

Open up the Android Studio and select Start a new Flutter project and then, a dialogue will open. In this dialogue, select Flutter package option as shown in the below images

Now, enter all the details of your package such as package name, project location, and package description. In this blog, we’re gonna create a custom switch, so give the package name as “custom_switch”

Now, your project is created. Delete the boilerplate code that is created as part of the project

Create a stateful widget class and name it CustomSwitch and include the SingleTickerProviderStateMixin in this class as shown below.

https://gist.github.com/flutter-devs/d2d21e3911c40cb624e48ba5f8fb21a2#file-custom_switch-dart

In the above code, we’re also declaring 3 member variables —

  • value — This is the value of our switch. If switch is ON then value will be true else value will be false
  • onChanged — This is the void callback which is used to change the value of switch from true to false and vice-versa
  • activeColor — This is the color shown when the switch is ON

Now, add the following code inside _CustomSwitchState class

https://gist.github.com/flutter-devs/e585ff4ae3f76881345795b25c7cc53c#file-custom_switch-dart

_circleAnimation and _animationController objects are created of type Animation and AnimationController respectively.

In initState() method, the _animationController object is initialized with a duration of 60 milliseconds. After that, _circleAnimation is initialized with AlignmentTween, because as shown in the thumbnail image, alignment of a white circle inside the switch is changing on every change in the value of the switch

In the begin value of AlignmentTween, we’re checking, if the value of the switch is true, then the Alignment will be centerRight else the Alignment will be centerLeft and at last, we’re attaching the animationController with this animation with Linear curve.

Now, paste the following code inside build() method —

https://gist.github.com/flutter-devs/9b235f7597f595c91b41953574cefa30#file-custom_switch-dart

In the following code, AnimatedBuilder widget is returned which means that it helps to animate its descendant widgets. Inside this, Container of width 70.0 & height 35.0 is returned. In the color property of Container, we’re checking if the alignment of white circular container is centerLeft(Switch OFF), then the color would be grey else color would be activeColor.

Now, in the child of Container, Row widget is returned. In the case of first children of Row, we’re checking if the alignment of a white circular container is centerRight (Switch ON) then, “ON” text will be displayed else an empty Container.

In the case of second children of Row, we’re adding the white circular Container and wrapping it with Align widget and in the alignment property, the value of _circleAnimation is given which means as soon as the value of _circleAnimation changes, alignment of white container changes.

In the case of third children of Row, we’re checking if the alignment of the white circular container is centerLeft (Switch OFF) then, “OFF” text will be displayed else an empty Container.

Now, the last step is to apply gestures on Switch. Wrap the root Container with GestureDetector widget and in the onTap() method paste the following code

https://gist.github.com/flutter-devs/85ebd7bd8da22b8f7e6e2bfca62b1474#file-custom_switch-dart

In this, we’re checking if the current playing animation is completed, then, simply reverse it else, forward it. And, if the value of switch is false, then we’re changing it’s value to true using onChanged() VoidCallback which we’ve defined in above steps else, we’re changing the value to false.

That’s all, now the CustomSwitch class is completed. Now, let’s create an example app which will use this package to display a switch in the app.

Create a new flutter project and name it “example” and to use “custom_switch” package in this project before uploading it to pub.dev, add the following code inside pubspec.yaml file —

https://gist.github.com/flutter-devs/0936c24a24fbdd4d62e6353085603804#file-pubspec-yaml

Now, go to main.dart file, and paste the following code inside it —

https://gist.github.com/flutter-devs/d90d25721a9e8e53d65d5f69ddd58b2c#file-main-dart

  • In line 1, we’re importing the custom_switch package.
  • In line 27, bool variable is initialised with the initial value of false, so that initially switch remains off
  • In line 39, CustomSwitch widget is added. Active color of switch is given as pinkAccent, value property is given the value of status variable and in onChanged() callback, value of status variable is changed with the value parameter of onChanged() callback
  • In line 50, Text widget is added and value of status variable is given as it’s text.

Now, run the app and you’ll see the following output —

Now, we’ve successfully added the code for CustomSwitch package. Now, let’s see what all other details are required to be added to publish the package to official packages directory.

In the pubspec.yaml file, you are required to add following details — name, description, version, author & homepage

https://gist.github.com/flutter-devs/34d524043698eec1657b6269911e9d76#file-pubspec-yaml

At last, you have to run one command that is used to check if our package has any warnings or not, whether it can be published or not? So, paste the following code inside the terminal window —

Now, press Enter and it will tell if there is any warnings in our package or not. In our case, it has 0 warnings

Finally, upload the package using the following command and your package will display on the official packages directory (It will take some time to display your package on the official packages directory)

Package Link — https://pub.dev/packages/custom_switch


Did I get something wrong? Mention it in the comments. I would love to improve.

If you learned even a thing or two, clap your hands 👏 as many times as you can to show your support! This motivates me to write more.

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 FacebookGitHubTwitter, 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.

Related: Dough Package For Smooshy UI Flutter

Need expert help building your Flutter app? Talk to FlutterExperts for architecture, development, and consulting support.


Step-by-Step Flutter Countdown Timer Animation for 2026

0

In this article, I will be building a count down timer with the help of the animation and using custom paint.

First of all, create an app which returns the MaterialApp.

Now create a new Widget CountDownTimer and make sure that it must be a Stateful Widget because we are using animation and we will need to add TickerProviderStateMixen .

class CountDownTimer extends StatefulWidget {
@override
_CountDownTimerState createState() => _CountDownTimerState();
}

class _CountDownTimerState extends State<CountDownTimer>
with TickerProviderStateMixin {
}

Create an Animation Controller

Create an animation controller and initialise it in initState() .

AnimationController controller;

@override
void initState() {
super.initState();
controller = AnimationController(
vsync: this,
duration: Duration(seconds: 5),
);
}

I am right now using only 5-second duration for my animation to happen.

Create a Circular progress bar using Custom paint

Create a class which extends CustomPainter

class CustomTimerPainter extends CustomPainter

Add properties

Now we will need some properties so we can customize my custom painter class from my widgets screen.

class CustomTimerPainter extends CustomPainter {
CustomTimerPainter({
this.animation,
this.backgroundColor,
this.color,
}) : super(repaint: animation);

final Animation<double> animation;
final Color backgroundColor, color;
}

I am using background color and color property for my Circular progress bar and to animate my progress bar, I will need an animation.

Override methods

We will override our paint method which will use to paint our circular progress bar.

First, we will paint a circle and we will create an arc will move around the circle.

In the paint method, create a Paint object and add properties.

Paint paint = Paint()
..color = backgroundColor
..strokeWidth = 10.0
..strokeCap = StrokeCap.butt
..style = PaintingStyle.stroke;

Now draw a circle

canvas.drawCircle(size.center(Offset.zero), size.width / 2.0, paint);

When the circle is painted then will need to draw an arc to move.

paint.color = color;
double progress = (1.0 - animation.value) * 2 * math.pi;
canvas.drawArc(Offset.zero & size, math.pi * 1.5, -progress, false, paint);

Change the color of the paint and update the process using the current animation value and draw the arc.

Now we also have an override method shouldRepaint .

@override
bool shouldRepaint(CustomTimerPainter old) {
return animation.value != old.animation.value ||
color != old.color ||
backgroundColor != old.backgroundColor;
}

Here is the code for the CustomTimerPainter class

https://gist.github.com/flutter-devs/cc42bd1506770b35025b59afd493e203#file-customtimerpainter-dart

Create the UI

To animate my Custom Progress bar we will wrap my an AnimatedBuilder and provide the animation and it returns a CustomPaint Widget. When My animation will start the value of the arc will update in the custom painter class and update the UI

AnimatedBuilder(
animation: controller,
builder:
(BuildContext context, Widget child) {
return CustomPaint(
painter: CustomTimerPainter(
animation: controller,
backgroundColor: Colors.white,
color: themeData.indicatorColor,
));
},
),

And to start and pause the animation Ill use the Floating Action Button, we have also Wrapped my FAB with AnimatedBuilder so we can update my play and pause status.

AnimatedBuilder(
animation: controller,
builder: (context, child) {
return FloatingActionButton.extended(
onPressed: () {
if (controller.isAnimating)
controller.stop();
else {
controller.reverse(
from: controller.value == 0.0
? 1.0
: controller.value);
}
},
icon: Icon(controller.isAnimating
? Icons.pause
: Icons.play_arrow),
label: Text(
controller.isAnimating ? "Pause" : "Play"));
}),

Now if we see the app, it will look like this

Now Wrap the CustomTimerPainter inside the Stack and add text to represent the value.

https://gist.github.com/flutter-devs/8b8a56051de58b44f0997270d76aa037#file-countdowntimer-dart

To convert the animation duration into time String.

String get timerString {
Duration duration = controller.duration * controller.value;
return '${duration.inMinutes}:${(duration.inSeconds % 60).toString().padLeft(2, '0')}';
}

Here is the code of CountDownTimer Widget

https://gist.github.com/flutter-devs/fb872f913be7aaddab061493b3988c59#file-countdowntimer-dart

I have wrapped the root body widget and added a new Container and animating with animation value.

Container(
color: Colors.amber,
height:
controller.value * MediaQuery.of(context).size.height,
),

Here this complete code

flutter-devs/CountDownTimer
Contribute to flutter-devs/CountDownTimer development by creating an account on GitHub.github.com


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.

Connect with me on Linkedin and Github


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 FacebookGitHubTwitter, 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.

Need expert help building your Flutter app? Talk to FlutterExperts for architecture, development, and consulting support.


How to manage States in Flutter using Redux

In Flutter there are many state management techniques and one of them is Redux. Generally Redux is a unidirectional data flow architecture that helps a developer to develop and maintain an App easily

Redux is designed elegantly so the user can easily interact with the App which has frequent state changes, here are the four components generally Redux contains.

  1. Action: When an event is generated then it is represented as an action and is dispatched to the Reducer.
  2. Reducer: When Reducer gets any update, it updates the store with a new state what it receives.
  3. Store: When Store receives any update it notifies to the view.
  4. View: It is recreated to show the changes which have been made.

In the above-mentioned process, the main thing which plays a vital role we fetch any third-party data is Redux Middleware, so here a question arrives what is middleware and what it does ??

Redux Middleware

When Application performs any operation like fetching any data from third-party API then middleware comes into action it manages data when it is dispatched from the action and before it reaches the reducer.

If we talk about the functioning of Redux, it works generally in two different ways which are used in any Basic App.

  1. When all the states are held in a single Store: developers can access the Stored States which is having all the data changes we need, and if we need to update state all the app will get to know.
  2. When data flows Unidirectionally: Data Flow is unidirectional and hence the data flow and handling of data become easier and the process containing all four steps which have already been mentioned earlier.

Now it is high time to understand it by an example, so here we are going to demonstrate it by a shopping cart app where we would select items into cart and remove them according to our choices.

How to use Redux in Flutter?

Before using Redux, you should know that flutter SDK does not have support for Redux but by using the flutter_redux plugin, it can be implemented.

Implementation

Step 1: Add the dependencies

Add dependencies to pubspec.yaml file.

Dependencies:

flutter_redux:
redux:

Here redux provides the architecture for the App and flutter_redux provides the store provider to manage the App.

Step 2: Import

import 'package:redux/redux.dart';
import 'package:flutter_redux/flutter_redux.dart';

And after this, we go to the implementation part of redux so first,

Wrap Material app with store provider, it is a base widget that will pass the given Redux store to all descendants that request it.

https://gist.github.com/shivanchalpandey/5705bc626dbfcd13feb7be17505d6c2f#file-main-dart

Then we create a list of items that we would add or remove

https://gist.github.com/shivanchalpandey/7326e126f2ac7e040bff3b181903e804#file-cartlist-dart

Here we have created a list in which the ListTile is having a text and an icon by which we would handle its functioning of adding or removing it to a cart list.

Now we will define a list of items in AppState class which is having both the cart Item list and main Item list.

https://gist.github.com/shivanchalpandey/c7a03f565848d380b8d6f288a4ef6b48#file-appstate-dart

It will manage states of actions and will dispatch it to reducer so here reducer plays the main role while it is being dispatched to the store.

https://gist.github.com/shivanchalpandey/3d9d95e408a4b4bdcd077285571adced#file-reducer-dart

Here in reducer class actions are being performed like adding or removing items from the cart list and main list.

Now we have to link our states which are being created to the state connector and hence it will manage all the changes we have made,

By this approach, we will connect our whole app with the states that are dispatched to the app and we can access this anywhere in the app.

So it is the full description of the Redux.


Thanks for reading this article

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

Connect with me on GitHub repositories.


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.

FlutterDevs has been working on Flutter for quite some time now. You can connect with us on Facebook and Twitter for any flutter related queries.

Related: SMS Using Twilio In Flutter

Related: Using SharedPreferences in Flutter

Related: Working with MobX in Flutter

Need expert help building your Flutter app? Talk to FlutterExperts for architecture, development, and consulting support.

Implement searching with Firebase firestore | Flutter

0

Hi Everyone, In this article, I am going to show you how to search for a document in a collection.

What is the need?

Suppose we have a list of documents inside a collection and we want the search in the document list with respect to caseNumber

What do I have?

Query where(
String field, {
dynamic isEqualTo,
dynamic isLessThan,
dynamic isLessThanOrEqualTo,
dynamic isGreaterThan,
dynamic isGreaterThanOrEqualTo,
dynamic arrayContains,
bool isNull,
}){

}

Should I use isEqualTo?

List<DocumentSnapshot> documentList;
documentList = (await Firestore.instance
.collection("cases")
.document(await firestoreProvider.getUid())
.collection(caseCategory)
.where("caseNumber", isEqualTo: query)
.getDocuments())
.documents;

if you use isEqual then you will have to write the whole query, In my case, I will have to write the whole caseNumber to display the search result.

Or isGreaterThanOrEqualTo?

Flutter firestore plugin also allows searching for particular data in the document.

documentList = (await Firestore.instance
.collection("cases")
.document(await firestoreProvider.getUid())
.collection(caseCategory)
.where("caseNumber", isGreaterThanOrEqualTo: query)
.getDocuments())
.documents;

But you will not be satisfied with the result.

Source (Stack overflow)

What I really want?

Even if I type a single alphabet fo the search query I should get the most appropriate result from the firestore.

What should I do?

You will need to add the list of query options that a user will search for.

For example

For caseNumber (1011222) , user can search

[1 , 10 , 1011 , 10112 , 101122 , 1011222]

At the time when you are pushing data into the firestore you can do is to create the search query options.

{

"caseSearch": setSearchParam(caseNumber),

}

To add the list of query options

setSearchParam(String caseNumber) {
List<String> caseSearchList = List();
String temp = "";
for (int i = 0; i < caseNumber.length; i++) {
temp = temp + caseNumber[i];
caseSearchList.add(temp);
}
return caseSearchList;
}

This will result in pushing all the queries that a user can search for.

Implement

In the TextField, when text value is changing, it is quiring in the database

onChanged: (String query) {

getCasesDetailList(query);

}

Now we have the arrayContains in the query, all you need to do is check for the text value that is being typed and it firebase query will automatically search all the documents which have the caseSearch an array that contains the query.

List<DocumentSnapshot> documentList = (await Firestore.instance
.collection("cases")
.document(await firestoreProvider.getUid())
.collection(caseCategory)
.where("caseNumber", arrayContains: query)
.getDocuments())
.documents;

Now you will get all the list of documents that matches the search query.


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.

Connect with me on Linkedin and Github


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 FacebookGitHubTwitter, 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.

Related: Serverless AI with Flutter: Using Firebase, Supabase & Cloud Functions for LLM Workflows

Need expert help building your Flutter app? Talk to FlutterExperts for architecture, development, and consulting support.


Complete Guide to MobX in Flutter for 2026

T his article focus mainly on Mobx and how it’s handled in Flutter. We will be covering setState(), MobX & Redux and their association with React by getting a general Knowabouts about their inner workings. By the End of this Blog read, you might be able to Differentiate b/w Redux & MobX as State Management Technique for your flutter Apps .Without any further delay, Let’s get started:-

Everything in Flutter constitute of widgets. Widgets are the basic building blocks that can be reused at a later time. They can be Classified into — stateless(No internal state exist) & stateful(Dynamic) widgets .

What is basically this “State” ?

State is information that can be read synchronously when the widget is built and might change during the lifetime of the widget. It is the responsibility of the widget implementer to ensure that the State is promptly notified when such state changes,using State.setState which is useful mainly when State is heiharchical and matches component structure.

Though, SetState has its own limitations :

  • Share More state across components — Internal state management become troublesome when you need to share more states across components.
  • Distant leaf components need access to states — Intermediary components doesn’t need to know becomes a problem as data gets shared to all pass through components.

To prevent This ,

We manage Application state externally to component by either of:

  • Bloc
  • Rx model
  • Provider
  • Scoped model
  • MobX
  • Redux model

Where individual leaf component can Access and Manipulate state.

MOBX: STATE MANAGEMENT TECHNIQUE

"MobX is just a state-management library that makes it really simple to connect the reactive data of your application with the UI” .

Here is a quick list of the MobX features that together make it Indispensable for Flutter:-

  • It is Simple, Scaleable and Unobtrusive state management library that has been very effective library for the JavaScript apps and this also port to the Dart language aiming to bring the same levels of productivity.
  • MobX is a Battle tested state management library Transparently Functional Reactive programming (TFRP). The design principle is very simple:Anything that can be derived from the Application state, should be derived Automatically : UI, data serialization, server communication, etc.
  • MobX is a state-management library that makes it simple to connect the reactive data of your application with the UI. This wiring is completely automatic and feels very natural. As the Application-developer, you focus purely on what reactive-data needs to be consumed in the UI without worrying about keeping the two in sync.
  • It’s not really magic but it does have some smarts around what is being consumed (Observables) and where (Reactions) and automatically tracks it for you. When the Observables change, all Reactions are re-run these Reactions can be anything from a simple console log, a network call to re-rendering the UI.

React & MobX

React and MobX together are a Prominent combination. React renders the application state by providing mechanisms to translate it into a tree of renderable components whereas MobX provides the mechanism to store and update the application state that React then further uses.

Both React and MobX provide optimal and unique solutions to common problems in Application development. React provides mechanisms to optimally render the UI by using a virtual DOM that reduces the number of costly DOM mutations. MobX provides mechanisms to optimally synchronize application state with React components by using a reactive virtual dependency state graph that is only updated when strictly needed and is never stale.

Why MobX is a solid State Management architecture for Flutter:-

  • Firstly, It uses comparatively less boilerplate code needed to implement State Management in MobX for Flutter when compared to other techniques at disposal and once all the actions are put into place, how the events will turn out and which properties to update are mainly not of concern.
  • Easy Interoperability: MobX works with plain JavaScript structures. Due to its unobtrusiveness, It works with most JavaScript libraries out of the box without Needing MobX specific library add-ons. For the same reason, you can use it with both server and client side, isomorphic and react-native applications.The result of this is that you often need to learn fewer new concepts when using MobX in comparison to other state management solutions.
  • Using Classes and Real References: With MobX you don’t need to normalize your data. This makes the library very suitable for very complex domain models.
  • Referential Integrity Is Guaranteed :Since data doesn’t need to be normalized and MobX automatically tracks the relations between state and derivations, you get referential integrity for free.
  • Rendering Through Many Levels :No problem, MobX will track them and re-render whenever one of the references changes. As a result, staleness bugs are eliminated. As a programmer, you might forget that changing some data might influence a seemingly unrelated component, but MobX won’t forget.
  • Simpler actions are easier to maintain: Modifying state when using MobX is very straightforward. You can simply write down your intentions. MobX will take care of the rest.

The basic structure of a MobX based application:

The above example makes use of the following properties of MobX that are vital. They are:-

State in MobX = Core-State + Derived-State

Observables 

https://gist.github.com/JOSHIMOH/760b7842a26a12930d8b7e76edffe4e9#file-observable-in-mobx

Actions are functions that decide how to mutate the Observables As a reason of this property, they are also called ‘Mutators’

https://gist.github.com/JOSHIMOH/770593b433d0247351a59ad116e13b41#file-actions

Computed Observables are values which depend upon observables and get triggered when the observable they depend on, changes its state.

https://gist.github.com/JOSHIMOH/df93ad0afefd974fa09a47d5f78e9a3b#file-computed-observable

Observer Widgets are a special type of widget which acts as a listener to the observable properties being rendered on the screen, and simply changes the state and re-renders them whenever any change is observed.

MobX

  • Smaller Application
  • Rapid Prototyping
  • Less Boilerplate Code
  • Observe References
- Single domain class can Encapsulate all of the update logic,
- Reacting to state changes:Real time systems
- Learning Curve is easier,
- Maintainabilty and Scalibility are not a concern
- Automatically track update

MobX Vs Redux: Comparing the opposing Paradigms

Similarities:-
Open Source client side management libraries.
Describe UI as a function of state .
No relation to React.
Work Especially well with React

https://gist.github.com/JOSHIMOH/1ef1df285139d0ce1a2fc1c6a2bc1037#file-plain-in-redux

https://gist.github.com/JOSHIMOH/a4fa2962b292be380b280d685086f7d5#file-redux

Redux:-
Action Required,
Single Store,
Plain-Object,
Immutable,
Normalized State

https://gist.github.com/JOSHIMOH/c806a9519b396fed7a5cc4378996af50#file-observable-in-mobx

MobX:-
Read and Write to State,
Multi- Store,
Observable Data,
Mutable,
Nested State

Making a simple Review App using MobX for Flutter

In this tutorial you will learn how to create a MobX version of the Review app-

Install Dependencies:

Add the following dependencies to your pubspec.yaml file.

dependencies:
mobx: ^latest version
flutter_mobx: ^latest version

Next add the following dev_dependencies:

dev_dependencies:
build_runner: ^latest version
mobx_codegen: ^latest version

In your project folder, run this command to fetch all the packages:

flutter packages get

At this point you possess all the necessary packages to continue further development:-

Implementation of MobX:

Using @observables and @actions annotations we have created reviews.dart

Observable & Actions usage pattern:

@observable
double averageStars = 0;

@action
Future<List<ReviewModel>> _getReviews() async {
final SharedPreferences _preferences =
await SharedPreferences.getInstance();
final List<String> reviewsStringList =
_preferences.getStringList('userReviews') ?? [];
final List<ReviewModel> retrievedReviews = [];

for (String reviewString in reviewsStringList) {
Map<String, dynamic> reviewMap = jsonDecode(reviewString);
ReviewModel review = ReviewModel.fromJson(reviewMap);
retrievedReviews.add(review);
}
return retrievedReviews;
}

Now we need to Run the below command inside our project folder. This generates Auto generated Code file

flutter packages pub run build_runner build

https://gist.github.com/JOSHIMOH/d6749dee5c27c6c4f430863665469e1f#file-review-g-dart

The changes need to be listened also in the UI view. This is done like where Row is wrapped alongwith Observer using builder:-

Observer(
builder: (_) {
return Row(
children: <Widget>[
InfoCard(
infoValue: _reviewsState.numberOfReviews.toString(),
),
],
);
},
),

This will generate a Ratings app with Comment and Rating functionality needed which will get displayed as list and added to average the overall rating on each new review :-

Conclusion:

MobX is framework Independent .

Though as per my suggestion , I would like to suggest you to try it out for your state management in flutter apps , Make Use of Actions if the changes are Event-based to avoid discomfort through handling.

Redux => MobX <=> MobX => Redux Easily doable .

Whatever you choose — It’s not an End game . Choose what makes you a Happy Developer!

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 FacebookGitHubTwitter, 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.

Related: SMS Using Twilio In Flutter

Need expert help building your Flutter app? Talk to FlutterExperts for architecture, development, and consulting support.


How to build a ChatBot in Flutter using DialogFlow in 2026

0

So, it’s been a while since Flutter is out there and its upsurge these days is phenomenal. The unparalleled performance of the framework is one of the reasons for its fondness among App developers other than the fact that it helps build cross-platform apps.

Today, I am going to tell you how to build a ChatBot in Flutter using the Dialog Flow development suite. So, first let’s see the points that I am going to cover in this article:

  • Brief about Dialogflow
  • Setup and Understand the console
  • Train your Agent
  • Integrate Dialogflow in Flutter App

Let’s move on with the first part where we should know about Dialogflow which is the building block of the ChatBot.

What is Dialogflow?

Dialogflow is a development suite that incorporates Google’s machine learning expertise to build end-to-end,deploy-everywhere interfaces for websites, mobile applications, and IoT devices.

Build natural and rich conversational experiences

Give users new ways to interact with your product by building engaging voice and text-based conversational interfaces, such as voice apps and chatbots, powered by AI. Connect with users on your website, mobile app, the Google Assistant, Amazon Alexa, Facebook Messenger, and other popular platforms and devices.

Advantages of Dialogflow:

  • Powered by Google’s Machine learning
  • Built on Google’s Infrastructure
  • Optimized for Google Assistant

Setup and Understand Dialogflow console:

Moving on, Lets head over to the Dialogflow website by clicking on the https://dialogflow.com/.

  • Click on the Go to Console at the top right corner of the website.
  • Login using the Google account.
  • Create your first agent. Give it a name, set the time zone and your default language for the agent.
  • After clicking on Create , you’ll get the console with all the features that you can implement in your Agent.

Understanding the basic console:

Two things which are the base of an Agent you just created.

  • Intents
  • Entities

7`

Intents:

An intent categorizes an end-user intention for one conversation turn. For each agent, you can define many intents, where your combined intents can handle a complete conversation. When an end-user writes or says something, Dialogflow matches the end-user expression to the best intent in your agent. and based on that intent a response is provided by the agent to the end-user.

Intents are mappings between a user’s queries and actions fulfilled by your software.

There are two default Intents provided by the Dialogflow, namely:

  • Default Fallback Intent: These types of intents are used when the user’s input expression doesn’t match the Intent defined for the Agent.
  • Default Welcome Intent: These types of intents are used when the end-user starts the conversation.

Entities:

Each intent has a parameter and each intent parameter has a type, called the entity type, which dictates exactly how data from an end-user expression is extracted.

Dialogflow provides predefined system entities. For example, there are system entities for matching dates, times, colors, email addresses, and so on. You can also create your own developer entities for matching custom data. For example, you could define a product entity that can match the types of products available for purchase with an Online store agent.

Entities are objects your app or device takes action on.

Train your Agent:

Now, that you have basic knowledge about the Dialogflow console, all that you’ll need to build a basic Agent we can now move forward to train our agent with test cases.

  • Create the Intents based on your requirement
  • Add the training phrases to the Intents
  • Add the response phrases for those training phrases
  • Add the Action and Parameters if required for that Intent
  • Add the Events which will trigger the Intent on the basis of the event occurrence irrespective of the training phrases, if any.
  • Add the context to the Intent.
Training Phrases for the Intent
Response Phrases for the Intent

Once you create an Intent then you can go on creating different intents for different queries. As of now, Dialogflow allows you to create 780 Intents and after that, you need to update the machine learning algorithm manually which you can do by following the steps:

  • Click on the gear icon for your agent.
  • Click the ML Settings tab.
  • Click Train.

Once you have trained your Agent, now you’re ready to integrate your Agent to your Flutter app and before heading over to Flutter, you have to download a JSON file from the console which helps your App to connect to the Agent you’ve just created. To do that follow these steps:

  • Choose Credentials from the options.
  • From the Credentials window, Select Service account key from the dropdown menu.
  • Next, select the Dialogflow integration option from the Service Account dropdown menu and select JSON from the radio button below that.

That’s it, you’ll have a JSON file downloaded which you’ll need in the next steps.

Integrate Dialogflow in Flutter App

Now, that you have your agent ready and trained you’re all set to integrate it into your Flutter app.

  • First, add the dependency to your pubspec.yaml file. Please make sure to the latest version, check here.
dependencies:   
flutter_dialogflow: ^latest version
  • Create a folder in your project with the name assets and move the JSON file that you’ve downloaded from the Google Cloud Console into it.
  • Open the pubspec.yaml file and add,
flutter:

uses-material-design: true
assets:
- assets/[name_of_your_json_file].json

Now, I won’t show the whole code for the chat app here for that I will attach the link to the GitHub repo so feel free to look into it for the code but here I’ll let you know the part where you setup the code for Dialogflow in the app.

AuthGoogle authGoogle = await AuthGoogle(fileJson: "assets/[your_json_file_name].json").build(); 
Dialogflow dialogFlow =
Dialogflow(authGoogle: authGoogle, language: Language.english);
AIResponse response = await dialogFlow.detectIntent(query);

Note: use the same filename as mentioned in the pubspec.yaml file.

That’s all you’ll need to get your Agent to respond to your questions. The response will have your Agent responses based on your query.

Now, you’re good to go to make your first chatbot in Flutter using Dialogflow. This is the basic example of ChatBot just to give you an idea about how to start it.

Click the GitHub link below to find the source code of the ChatBot. Also, keep in mind not to directly clone the project and run it, it won’t work as I have removed my JSON credentials. All you need to do is replace the JSON file with your JSON obtained from the Google Cloud Console.

Aditsyal/flutter_chatBot
You can’t perform that action at this time. You signed in with another tab or window. You signed out in another tab or…github.com

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.

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

Related: Switch Theme Using Bloc With Cubit In Flutter

Need expert help building your Flutter app? Talk to FlutterExperts for architecture, development, and consulting support.