Google search engine
Home Blog Page 48

Design Patterns in Flutter- Part 1(MVC)

0

Design Pattern is something which has been always a very Mysterious term for developers and we are very much confused between the term Software Architecture and Design patterns, So before starting anything about design patterns we need to clear this doubt regarding the Design Pattern and Software Architecture.

Software Architecture

Software Architecture is how the whole components of system software are organized and assembled. How they communicate with each other. And the Constraint the whole UI is ruled by.

So If we go through this definition we come across three important aspects and those are

  • How the whole components of system software are organized and assembled:- Architectural Pattern
  • How they communicate with each other:- Messaging & APIs
  • The constraints the whole UI is ruled by:- Quality Attributes

Design Pattern

Design Pattern could be defined as a common repeatable solution to recurring problems in software design. Design patterns can not be related to a finished design which will be directly used in code but it could be understood as a description or template for how to solve any common problem that may occur in many situations.

So If we go through this Definition we will find that

  • It is a solution to recurring problems of software development.
  • It is not a sample code which will be directly used in the project.
  • It is just a template that helps to solve any problem that occurs in software development.

Difference between Software Architecture and Design Pattern

So after going through both the definition we came to know that both of it could be differentiated on the basis

Scope:- Software Architecture has a universal scope, it has to managed at a Higher level like Server Configuration, etc.Whereas Design pattern has a Lowe level scope that comes to the project internal code pattern.

Working:- Software Architecture is all about organizing and assembling the components in such a way that their communication is very much convenient and secure. Whereas a Design pattern is about how the components are built.

So I hope this comparison clears the doubt between Software Architecture and Design Pattern. So after having a piece of knowledge that what design pattern actually we will start a few famous design patterns which are mainly used in flutter development. So, First of all, we will start with the very Basic MVC Pattern and we will see how MVC is used in Flutter.

MVC In Flutter

MVC stands for the model view controller and its main work is to have a segregated code base, it aims to separate the code and area of responsibility while software development. The main focus of MVC is to separate the interface of the project from the functionality and the data that is used in the application. As we all know that neat and arranged things are always easy to use and maintain, the same is with MVC it makes the codebase neat and arranged and it achieves these with three of its components.

  • Model:- Model compromises of the data source it may be from anywhere DB, API, JSON, etc. In some cases, it may consist of some business logic.
  • View:- View is all about the user interface, I.e displaying data and taking inputs from the user.
  • Controller:- It contains the business logic, I.e Controlling what data will be shown to the user, user input handling, etc.

Communication Flow

Differentiating the three of these basic components of projects helps the developer to write a neat and modular code which makes the code Reusable and also helps in parallel development. It becomes very easy to work on the project as it does not affect other parts of the project if something is changed in one part. So keeping them separated needs a communication flow in which they will interact with each other and achieve the functioning of the project.

So as we could see from the following flow diagram the User interacts with the View part of the project which helps the user to see the Data and provide the input to the controller through the view. Controller Active as the brain of the project does the calculation or manipulation of data from the user or takes the data from the model to work on it and provides it to the View which shows the desired data to the user. Here we find that the View shows and receives the data but it directly not interact with the Model, it is the controller that plays a role between view and model in data manipulation and data representation. The View and the Model are tightly coupled to the Controller i.e View Knows how to communicate to Controller, Controller knows how to communicate to Model and Model and View works collectively without knowing each other existence.

Code Understanding:

If you have not installed the flutter SDK or you are still getting familiar with it :

/media/eaefff34fddcc032a2b4fe36aa69b8a9

Let’s dive into the code part for an In-depth understanding of the process:-

1. Firstly, Create a new project and then clear all the code in the main.dart file. Type below command in your terminal:-

flutter create yourProjectName
  • Add the current latest version of MVC pattern package under the dependencies in pubspec.yaml file.
dependencies:   
mvc_pattern: ^latest version

Create a Model Class:

As Explained above a model class is created for both counter:-

Create the Main Controller :

The Controller is Created as this Basically Ensures the interaction with the model :

Adapting it Into The View :

The controller is then bound to the view.dart file so that the increment and decrement functionality may work as depicted.

Find the Code Version on Github at:

flutter-devs/Flutter_MVC
A new Flutter application. This project is a starting point for a Flutter application. A few resources to get you…github.com

Closing Thoughts

Design Pattern is a Quintessential tool in large scale apps in native applications which you can also practice in flutter also. In this Blog, only MVC has been explained but this will a series of blogs and in the next blogs, we will be sharing about MVP, MVVM, CLEAN, etc.

If you have not used Design Patterns in Flutter, I hope this article has provided you with valuable information about what is all about it, and that you will give it Design Patterns — a Try. Begin using them for your Flutter Apps !!

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 has been working on Flutter for quite some time now. You can connect with us on Facebook and Twitter for any flutter related queries.

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

Thank you for reading. 🌸

Related: Explore SOLID Principles In Flutter

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

CI/CD with CodeMagic | Flutter

0

These days approaches for code delivery are gradually changing when writing quality code and the fine product delivery is a need of the time and in this situation, developers find themselves in the dilemma to manage both things at the same time but now this is not a big deal because of CI/CD(Continuous Integration/Continuous Delivery). So let’s first know about CI/CD.

What is CI/CD

It can be easily understood by its name Continuous Integration/Continuous Delivery and it is the process to directly merge your product version(code) into the main branch of your code and also helps to get builds of the product on the daily basis and also look after the integration problems, CI helps to trigger the build whenever code is pushed and integration tests make sure that the new part which has been added to the application does not break the previous build of the application and if the test or the build fails then ensure that the app remains stable, While CD is Continuous Deployment or Continuous Delivery is the automatic deployment of an app (to production).

Now let’s understand how to implement it

There are various ways to implement CI/CD and we are going to get it done by using Code Magic. It was launched at Flutter Live in December 2018 in cooperation with Google, Code Magic provides various options to implement CI/CD.

You can log in with any mentioned account, and now I am going to implement it by using GitHub.

But you should remember one thing your GitHub/Bitbucket/GitLab should have a repository in which you want to implement CI/CD.

After login with any particular account, You will navigate to the home page of code magic.

You will find this kind of screen now you have to choose in which repo you want to implement CI/CD. So here in every repository, you can see a setting icon and “start new build” options so before going to build option first we need to set up our repository for different workflows and many more options are there.

So at first, we click on that icon right before the “start new build” option and you will navigate to this screen.

Here you need to set up different workflows for a different kind of delivery and testing like Default workflow, Dev workflow, QA workflow, so create it by clicking “Duplicate workflow” in ton right side of the screen.

After creating duplicate workflows you can choose which workflow you need which type of customization (as shown in the above screen).

You also need to implement the same branches in your repo and that could be master, QA, dev.

So every time you need to push your code from dev (it is your choice) and then you need to merge changes into different branches in your GitHub.

After that, you need to select different workflows one by one and customize the setting according to your need, and I started the customization from Dev workflow and the first option I found to customize is “Build triggers”.

Here I have clicked on triggered on push, so every time we push over code over GitHub we will get a new build, you can choose different options according to your need for different workflows.

After that, we move to the next option below it where we would make some changes and this is “Test”.

As you can understand by seeing it, if the test fails, it automatically stops build.

Next option is “Build

In this, you can select the flutter version, platforms, in which mode you want to release your app,

and the next part is ‘Publish,

here you can select you to publish options like where you want to share your build or changes, even you can update your app in play store and apple app store directly and for this, you only need to fill some info by clicking on Android code signing and iOS code signing, you can share your build over email by providing mail addresses directly.

After all these customizations you need to click on “start new Build” top of the page and you will navigate to this page

here you can select your branch your workflow and by clicking on which type of build you want you can move forward. when you click any of the options you will find that it started creating a new build for every platform you selected during customization

and after completing its build you will receive builds on all platforms you selected. So here is the image of my mail inbox where I received a mail of new build now I can download Apk and test if the new changes are working fine or not.

So this was the small introduction of CI/CD through code magic.

Thanks for reading this article if you find anything that could be improved please let me know, I would love to improve.


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 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, and Twitter for any flutter related queries.

Related: SMS Using Twilio In Flutter

Related: Using SharedPreferences in Flutter

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

Complete Guide to Flutter CI with Bitrise in 2026

0

Flutter has been out there from a long enough time and has been taking the Mobile Development Community by Storm. With the scope of Mobile Development apparently increasing ,the need to Integrate CI/CD Tools in your flutter Apps is a Must enriching the work pattern of Team. One of the prominent among Continuous Integration is Bitrise.

Continuous Integration:

Continuous Integration is the process of merging and syncing your code to one dedicated git provider and automating your build process upon performing the tests. The software development process is to make your development flow smoother and keep your code clean when working in a big team code merging often ends up in issues. Continuous integration is about making sure that every change is merged into one dedicated branch upon task completion and to get a corresponding build for the same.

CI using Bitrise:

Bitrise is cloud-driven CI/CD tool which has four major points as described by them:

Complete mobile development stack inclusion:

Bitrise promises support for both native as well as cross-platform, be it Java or Kotlin, Objective C or Swift, or Iconic, React or Flutter it got you all covered.

Code independence:

Whether you have your code on Github or on Bitbucket or on GitLab or on it’s private or public git service. It will get your code for you.

Hardware independence:

Since Bitrise is a cloud-driven tool you don’t need any specific hardware to make this work. All you’ve to do is just add your app to their dashboard and voila!

Build anytime:

Webhooks works on pull-request and every time a request is made the webhook gets triggered or makes a custom webhook or schedule your builds.

Let’s Start

Now, that we have had an idea about continuous integration and about Bitrise lets integrate Bitrise to our Flutter app.

Step 1: Setup your application

  • Create a basic app or choose an already existing one.
    I am going to start with the basic demo app just to give you the idea of Bitrise integration.
  • Create Flavors for your app.
    Now, I won’t go in detail about how to setup Flavors for your flutter app, for that please follow this Creating flavors of a Flutter app and Flutter Flavoring. But adding Flavors to your app is like setting it right for different build requirements. In an organization, it’s always a good practice to create flavors for your app, where you might handle different build instances for different purposes, one for Demo purposes, one for Dev, one for Staging, one for Production and every build might have different configurations, different icons, different names so with the use of flavors it gets easy to handle all these scenarios.
build.gradle:app/Android

The above-mentioned articles will help you create flavors for your flutter app for both platforms.

Step 2: Integrate your App to Bitrise CI

Now, that you’ve created flavors for your app, you can head over to Bitrise and sign up on the website or log in if you already have an account.
Once you’re in the dashboard, click Add new application. This is where you’ll integrate your App to Bitrise after following the steps.

Procedure to integrate apps into Bitrise.

Now we’ll look into these steps:

  • Choose Account
    Here, you choose your Bitrise account to which you want to add the app. Once you’ve chosen your account you’ll be required to select the privacy of your app, of the two options available i.e Private and Public. Private is for you and your team members while the Public is for everyone.
  • Connect your repository
    Now, that you’ve selected your account and the privacy mode for your app you’re asked to select the repository for the source code of your app. There’re various options like GitHub, Bitbucket, GitLab or git URLs where the source code of your app already exists.
  • Adding an SSH key to your repository
    Now, that you’ve selected your repository you may need to give it access rights to Bitrise by integrating the SSH key to the repository, this is required for Bitrise to clone your code to their virtual machines. For this, you have two options, Automatic integration or Manual integration.
    When you select the Automatic option among the two on the right top corner of the step, an auto-generated key will be registered for Bitrise and corresponding public key for your Git provider. The Manual option lets you generate your own SSH key and register them to Bitrise and to your Git provider.
  • Choose the branch
    Select the branch of your repository from which the Bitrise will fetch the source code.
  • Build configuration
    After selecting the branch Bitrise will clone and validate it and upon validation, Bitrise will ask you to select the build config of the app which and to select the tests if available in your app which we created while setting up the app. 
    There are two ways of doing this, Manual and Detected. In Manual mode, you can select the build configuration as per need while in Detected mode, Bitrise detects the existing config.
  • Select the App icon
    Select the app icon which you want you to use for your app if you have or you can skip this step for now.
  • Register a webhook
    So, you have almost added your app to Bitrise but there’s one finest and the best thing about CI’s i.e automation. I mean isn’t why we here after all? To make sure that the moment we make some changes in the code and as soon as we finish pushing the changes to the git provider Bitrise automatically tests the build and send us the build? That’s what this Webhook will do. It will keep an eye on the branch you’ve provided in the above steps for any push-requests, following which it will update its code and run the test setup by you and upon any kind of response either Build Successful or Build failure, a feedback mail to your registered mail id.
    This step is not mandatory as you can find this step later in the settings page so feel free to skip it.
  • Almost DONE!
    So, if you followed all the above steps correctly, rejoice! you’re almost done. Bitrise will automatically trigger a build for you and as soon as its completed you’ll be notified about it in your mail.

Bitrise Dashboard

Once your app is added to the Bitrise an initial build will kick off automatically and the report for the following will be mailed to you by Bitrise. Now, if you check the dashboard, on the right corner you’ll find your apps added to Bitrise. On clicking on it you’ll be navigated to the detail page where you can access the app workflow, builds, code, settings, etc.

App Detail Interface
  • Builds
    This will have all your build reports.
  • Workflow 
    This contains the nuts and bolts of your app for Bitrise integration. You can edit or create workflows as per your requirement, you can sign your app for deployment to the play store or app store, edit/create environment variables that are used in in the flow, “bitrise.yaml” file is the config file that fetches all the configuration of your app on Bitrise.
  • Team
    This will let you control your team members related to this current app/project. You can assign the Admin, Developer, Tester, all that sort of work.
  • Code
    This lets you control the trigger token and webhooks for your app.

Conclusion:

I hope you got an idea about how to work with Bitrise in Flutter. Well, there are various options out there for CI and sometimes it’s not about which is best, it’s also about what you feel comfortable with. So, you’re all ready to explore further but all these tools are efficient only if your app/project is of enterprise-level when a number of people are working as a team on a common app/project and if you’re a sole developer you don’t want to go through this hassle.

flutter-devs/flutter_bitrise
A flutter demo showing use of flutter bitrise. Contribute to flutter-devs/flutter_bitrise development by creating an…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.

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 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, and Twitter for any flutter related queries.

Related: SMS Using Twilio In Flutter

Related: Using SharedPreferences in Flutter

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

Hive NoSql Database

0

For those who don’t know about NoSql?

NoSQL, which stands for “not only SQL,” which is an alternative of traditional relational databases in which data is placed in tables and data schema is carefully designed before the database is built. NoSQL databases are especially useful for working with large sets of distributed data.

What is Hive?

Hive is a lightweight, NoSQL database, easy to implement and also having high benchmark on the devices and written in the pure dart. Until and unless you need to model your data with many relationships, in that case it recommended to use SQLite.It has no native dependencies (it runs on Flutter Web!) can be the best option. Hive supports all platforms supported by Flutter.

Hive having the concept of boxes(which store data). A Box has to be opened before use. In addition to the plain-flavoured Boxes, there are also options which support lazy-loading of values and encryption.

What are Boxes?

All data stored in Hive is organized in boxes. A box can be compared to a table in SQL, but it does not have a structure and can contain anything. For a small app, a single box might be enough. For more advanced problems, boxes are a great way to organize your data. Boxes can also be encrypted to store sensitive data.

Before you can use a box, you have to open it. For regular boxes, this loads all of its data from the local storage into memory for immediate access.

var box = await Hive.openBox<E>('testBox');

To get an already opened instance, you can call Hive.box('testBox') instead. It doesn’t matter though if you try to call openBox multiple times. Hive is smart, and it will return an already opened box with the given name if you’ve previously called that method.

To prevent holding unnecessary data in memory, you can close the box when you are done with your box. Don’t worry if you forget to close the boxes . Smarty Hive do it for you. Its also has a handy method for closing all the box.

Hive supports all primitive types, List, Map, DateTime, BigInt and Uint8List. Any object can be can stored using TypeAdapters.

In this, we are covering how to save a custom object(Employee)showing Basic CRUD operations:

Adding 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:
hive: latest version
hive_flutter: latest version
path_provider:

dev_dependencies:

flutter_test:
sdk: flutter
hive_generator:
build_runner:

Initializing and Registering Adapter:

Box _employeeBox;

@override
void initState() {
super.initState();
Hive.registerAdapter(EmployeeAdapter());
_openBox();
}


void _openBox() async{
var dir = await getApplicationDocumentsDirectory();
Hive.init(dir.path);
_employeeBox = await Hive.openBox('employeeBox');
}

Under the hood, Hive works with binary data. It cannot recognise it

Box boxObject = await Hive.openBox('employee');
boxObject.add(Employee("paras" ,62));

its throws exception. or we save this by making it TypeAdapter.

import 'package:hive/hive.dart';
part 'employee.g.dart';

@HiveType(typeId: 1)
class Employee {

@HiveField(0)
final String name;

@HiveField(1)
final int id;

Employee(this.name, this.id);

}

And in Terminal type :

flutter pub run build_runner build part ’employee.g.dart

and you are done. This will generate you a TypeAdapter.

Save (Add)

We open the Box at the time of Initialization.

_employeeBox.add(Employee(employeeNameController.text, employeeHobbyController.text));

To show saved data in List (READ)

ListView.builder(shrinkWrap: true,
itemCount: _employeeBox.length,
itemBuilder: (context ,index)
{
final employee = _employeeBox.get(index) as Employee;

return Container(
margin: EdgeInsets.symmetric(vertical: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text("${employee.name}",style: TextStyle(fontWeight: FontWeight.w400 ,fontSize: 15),), Text("${employee.hobby} ",style: TextStyle(fontWeight: FontWeight.w400 ,fontSize: 15),),
],
),
);
},)

For Updating and Deleting we use putAt() and deleteAt().

Link for repository:

https://github.com/parasarorahere/Hive-Database.git

Thanks for reading this article if you find anything that could be improved please let me know, I would love to improve.

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 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, and Twitter for any flutter related queries.

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

Push Notification In Flutter | FireBase

0

Google recently announced that more than over 2 million Developers Worldwide have laid their hands on Flutter. After the language’s roll-out at the Google I/O ‘18, This revelation from the search giant immensely Signifies diversion of developers from Native development to the Newer Technologies Building Extensive Cross-Platform Apps. Flutter started its life as an open source UI framework that helps developers build native interfaces supporting different device sizes, pixel densities & orientations creating magnificent digital experience.

In this Article ,We will have a look at How to send Push Notification in a Flutter project through the help of firebase its features and customisation available:

Introduction to Push Notification:

Push Notification is a Infallible medium of alerting app users of Information they might have opt-in from apps and services . It is also a prominent retention medium to drive User-Engagement for the apps that might have gone Unnoticed after their being Installed .

Firebase Cloud Messaging (FCM) avails a comprehending set of online tools to send notifications to the user audience intended . You can always select your target audience for the push notification on the basis of firebase predictions to dynamically segment your user & the engagement you’re trying to recieve by always keeping in sight of their relative number from the total user base. We Intend To learn Sending messages to a flutter app and the role of back-end cloud function & firebase analytics in their being broadcast notification to a Single User|Segmented Audience creating a pipeline for Push Notifications.

FCM push notifications can be comprehended to be of three types:

: Token Based Notification- This can be sent with help of user device token for sending notifications on the basis of Individual User Activities .

: Topic based Notification- This kind of Push Notification is sent for subscription based notification to the users that user might have opted-in .

: Segment based Notification : Sending Notification on the basis of firebase analytics to a segment of your user .

Firebase Cloud Messaging Project Creation

In order to send Push Notification ,We need to create a firebase project for the Firebase Cloud Messaging from firebase.google.com by logging in with your google account. This brings us to the following screen::

Add project at Firebase Console

Click on Add Project Button (+) initiating firebase project creation process.

Mention Name of project

Select the appropriate name for the project entering continue further

select analytics (if needed )

You can either select the firebase analytics and then clicking on Continue Project. Firebase messaging is now created and ready to use .

Firebase project created

This Progress indicator will show before the dashboard indicating success.

Dashboard Screen

In the project overview page, click the iOS icon to launch the setup workflow as we now needs to register your flutter project for the android and iOS application. .

Integration with iOS App

Enter iOS Bundle ID

Enter the iOS bundle ID which can be founded also at info.plist of being the next line after CFBundleIdentifier.

Make sure you enter the correct ID As this can’t be edited further at the moment .

Download GoogleService-Info.plist

Next step , We need to download the config file named as GoogleService-info.plist & repeating the similar process to register your android app there savoing the Google-service.json file .Keep those configuration files in ready-to-use with Flutter app later.

Click Project setting from the option further. Select Cloud messaging noting down the server key signified there.

Flutter Application Setup with FCM

Create a new Flutter Project making sure application name is same as package or bundle ID at the time of firebase project creation

Open pubspec.yaml entering the firebase messaging dependencies :

dependencies:
firebase_messaging:           <add-latest-version>
device_id: <add-latest-version>

Android-specific configurations

: Open build.gradle of android section. In the dependencies section add :

dependencies {classpath 'com.google.gms:google-services:4.3.3'}

: Open android/app/build.gradle . In the dependencies section add the following & In the end enter the required plugin as shown up:

dependencies {
implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation 'com.google.firebase:firebase-messaging:20.1.5'
}
apply plugin: 'com.google.gms.google-services'

Add the following intent filter inside of the activity element of your AndroidManifest so that when user taps in Content is Being Displayed.

<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

Add the google-services.json file previously downloaded by putting the file in android/app of your project file folder.

iOS Specific Configuration:

We need to register our app seperately in the firebase project for its configuration for iOS apps:

: In Xcode , Open ios/Runner/Runner.xcodeproj and check whether the Bundle identifier at general section is same from the Bundle Id entered at the Project , otherwise edit this to make them similar and Register.

: Enter the Downloaded GoogleService-Info.plist from the firebase console into Xcode project within Runner:

Important Note: Do not just copy the folder without the help of Xcode by simply copy-pasting outside of Xcode as this will likely not work

Adding Firebase SDKs

  1. Create a Podfile if you don’t already have one:
$ cd your-project-directory
$ pod init

2.Install the pods, then open your .xcworkspace file to see the project in Xcode:

pod install
open your-project.xcworkspace

3. Initialize Firebase in your app:

Import the Firebase module in your UIApplicationDelegate

import Firebase

Configure a FirebaseApp shared instance, typically in your app’s application:didFinishLaunchingWithOptions: method:

// Use Firebase library to configure APIs
  FirebaseApp.configure()

FCM Notification Types:

  1. Individual Device Token Based Notification : Personalised notification are most used for sending Push Notification as they are more apt and specific to Key needs of the user being sent on the basis of analytical methods . Though they are being sent mostly in the form of Cloud Functions but you can also send them from the firebase console which is depicted below:

In the Grow Section , Select Cloud Messaging option after this you will see a prompt to Send your first message

Cloud Messaging

Enter the Notification title & description text . We can also add the Notification Image as depicted . Before Sending the notification message a user can always preview the notification in (expanded & Initial state) the notification will likely be shown on devices.

Individual Push Notification

The only thing needed right now to send the notification is the device token which can be availed by using the device_id plugin at the dependencies:

final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();

@override
void initState() {

super.initState();


Future.delayed(Duration.zero, () {
this.firebaseCloudMessagingListeners(context);});}

void firebaseCloudMessagingListeners(BuildContext context) {
_firebaseMessaging.getToken().then((deviceToken) {
print("Firebase Device token: $deviceToken");

});
}

Device token obtained from the flutter code can be entered for the push notification enabling device specific Push Notification.

Device token

2. Segmented User Based Notification: Segmented notification are sent on the basis of various factor : country, last app engagement , user audience . Firebase Prediction Tools comes out handy for this making possible by studying your app’s analytics helping you in driving campaign driving better user engagement.

: After Successfully Entering the Notification Details . You need to select the segment of user audience on the basis of various tools alongwith firebase prediction that use your analytics to drive user campaign most suitable .

Segmented Push Notification

You will then see the preview for the segmented notification . Publish here for successfully sending of the notification.

Preview

3. Topic based Notification: Topic based notification are another personalised way of sending notification that may have opted in for a particular services . This can be done either in the background or by manually making the user subscribing to a service offered.

MaterialButton(
child: Text('Subscribe to FlutterDevs'),
onPressed: () => _fcm.unsubscribeFromTopic('FlutterDevs')
),

Here, If the User taps on the button will result in him subscribing to the topic FlutterDevs which maybe later used for sending notification on the topic .

This will result in sending notification to the subscriber of ‘FlutterDevs ’ topic.

preview

All Push Notification were recieved to the Intended Users:

Closing Thoughts:

We have Surely realised the Importance of Using Push Notification for our mobile apps quite apparently and It’s Integration with Firebase really Alleviates the problems of many apps getting unnoticed after being installed being a great retention medium for them .Firebase facilitate multiple services collection availed at a single place such as storage, cloud functions, real time databases, authentication. Hope After reading the article you must have gotten an insightful of Push Notification in Flutter with Firebase. Give it a TRY!!


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 has been working on Flutter from quite some time now. You can connect with us on Facebook and Twitter for any flutter related queries.

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

Thank you for reading. 🌸

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

www.flutterdevs.com

UI Testing in Flutter

0

Introduction

In this post, we shall discuss about the flutter UI testing. Testing the UI of the app is an essential part of a developer side. It ensures the developer that the code is working in the required widget tree or not.


Table of content

  1. Flutter Driver
  2. Adding dependencies
  3. Adding files
  4. Methods in Flutter Driver class
  5. Flutter driver element identification
  6. Enabling the flutter driver
  7. Writing the test
  8. Run the test

Flutter Driver

Flutter driver is a class that creates a driver that uses a connection provided by the given serviceClient, _peer, and appIsolate.

It is very similar to testing frameworks such as Selenium WbDriver, Protractor, Google Espresso.


Adding dependencies

Integrate your flutter app by adding flutter_driver dependency.

Edit your pubspec.yaml file.

dev_dependencies:
flutter_driver:
sdk: flutter
test: any

Adding Files

Create a folder test_driver and add two files in it app.dart and app_test.dart.

app_name/
lib/
main.dart
test_driver/
app.dart
app_test.dart

Method in Flutter Driver class

There are 33 methods in the flutter driver class till now.

Some of them are discussed below…

  • checkHealth

This method checks the status of the Flutter Driver extension.

This method return tow values.

  1. HealthStatus.ok
  2. HealthStatus.bad
  • clearTimelime

This method clears all the timeline events recorder.

The timeout argument causes a warning to be displayed to the user if the operation exceeds the specified timeout.

  • close

Closes the serverClient and _peer.

  • enterText

This method enters a text into an inputField that is currently focused.

  • forceGC

Force a garbage collection run in the VM.

  • getBottomRight, getBottomLeft, getCenter, getTopRight, getTopLeft,

Return the point at the specified location of the widget identified by the finder.

  • getText

This method returns the text in the Text widget located by the finder.

  • requestData

It sends a string and returns a string.

  • screenshot

Takes a screenshot of the event.

  • tap

This method taps the widget located by the finder.

  • waitFor

Waits until the finder locates the widget.

For more info please visit this link.


Flutter driver element identification

There are 4 methods to identify the element in flutter.

  1. bySemanticsLabel()
  2. byTooltip()
  3. byType()
  4. byValueKey()

Enabling the flutter driver

app.dart file

import 'package:flutter_driver/driver_extension.dart';
import 'package:fluttertest/main.dart' as app;

void main() {
// This line enables the extension.
enableFlutterDriverExtension();

// Call the `main()` function of the app, or call `runApp` with
// any widget you are interested in testing.
app.main();
}

Add the following code into your app.dart file

This will enable the flutter driver and call the runApp method.

Writing the test

Writing the test involves the four steps…

  1. Create SerializableFinders to locate the widgets.
  2. Connect to the app.
  3. Test the scenarios.
  4. Disconnect the app.

Create SerializableFinders to locate the widgets.

final writeDataFinder = find.byValueKey("write_data");
final addDataFinder = find.byValueKey("add_data");

Connect to the app

// Connect to the Flutter driver before running any tests.
setUpAll(() async {
driver = await FlutterDriver.connect();
});

Test the scenarios

test("check health", () async {
Health health = await driver.checkHealth();
print(health.status);
});
test("flutter drive test", () async {
await driver.tap(writeDataFinder);
await driver.enterText(dummy_data);
await driver.tap(addDataFinder);
});

In the first test, we are checking the health of the flutter driver extension.

In the second method, we are testing our flutter widgets using SerializableFinders.

Disconnect the app

tearDownAll(() async {
if (driver != null) {
driver.close();
}
});

app_test.dart

https://gist.github.com/anmolseth06/2c11d58bef1860276ca7b05d533a0e81#file-app_test-dart


Run the test

Run the following command in your terminal window…

flutter drive --target=test_driver/app.dart

This command builds and launches the target app and runs the app_test.dart in test_driver/ folder.

Github Link

flutter-devs/Flutter-UITesting-Demo
A new Flutter application. This project is a starting point for a Flutter application. A few resources to get you…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.

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


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 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, and Twitter for any flutter related queries.

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

Thank you for reading. 🌸

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

Design Patterns in Flutter- Part 2(MVP)

0

In the previous blog of this series, we saw what actually design pattern is and how it is different from Software Architecture. for more explanation, I would suggest you guys go through my previous blog for clearing basic concepts of design patterns.

So wrapping Design Patterns in simple lines

Design patterns are used for separating the Main code (Business Logic) from the UI part which will make your code more readable and very easy in testing.

What is the MVP?

MVP stands for Model View Presenter, As we could see that it consists of three words so talking about them a little bit.

  • Model: It is an interface defining the data to be displayed or otherwise acted upon in the user interface.
  • View: It is a passive interface that displays data (the model) and routes user commands (events) to the presenter to act upon that data.
  • Presenter: It acts upon the model and the view. It retrieves data from repositories (the model) and formats it for display in the view.

So We would be knowing more about these terms from our Demo App which shows a basic increment and decrement counters.

Communication Flow

We will see from this Flow Diagram that how model view and presenter are connected to make our code more readable and easier in testing.

MVP consists of model view and presenter and they are bonded in such a way that View in the topmost layer which is responsible for showing the data to the user and taking data from the user, Presenter being in the middle of View and Model takes the input from View and taking the data from Model. the Presenter contains the UI business logic for the View. All invocations from the View delegate directly to the Presenter. The Presenter is also decoupled directly from the View and talks to it through an interface. This is to allow mocking of the View in a unit test. The View and Model are entirely shielded from one another. The Model may raise events, but the Presenter subscribes to them for updating the View. The Model is the layer providing the data source to the user in any format.

How MVP is different from MVC?

MVP is the derivative of MVC, The key difference between MVC and its derivatives is the dependency each layer has on other layers, as well as how tightly bound they are to each other. For establishing the difference between these two design patterns, we will take the help of the flow diagram of both the design patterns to find out the difference in the way to find out how they are helpful in their own way.

As we could see from the flow diagram of MVC that the View is the one that interacts with the user, and it notifies the controller. The controller modifies some of the model based on user interaction. The Controller gets updated data on which models perform some business logic. The view gets updated once the controller passes the new data which has been received from the model. According to this, we could say about MVC that

  • Controllers are based on behaviors and can be shared across views
  • Can be responsible for determining which view to display

Now Coming to MVP, This Flow diagram shows that the flow chart is almost the same as it is in the case of MVC, but here the Controller is being replaced by Presenter. The view is the topmost layer of the architecture, interacts with the user and takes the input which is being passed to the presenter, and taking the data from the model it sends the data back to the View to present it to the user. So According to this, we could say about MVP that

  • The view is more loosely coupled to the model. The presenter is responsible for binding the model to the view.
  • Easier to unit test because interaction with the view is through an interface.
  • Usually view to presenter map one to one. Complex views may have multi presenters.

Code Understanding:

If you have not installed the flutter SDK or you are still getting familiar with it :

Let’s dive into the code part for an In-depth understanding of the process:-

1. Firstly, Create a new project and then clear all the code in the main.dart file. Type below command in your terminal:-

flutter create yourProjectName
  • Add the current latest version of MVP pattern package under the dependencies in pubspec.yaml file.
dependencies:   
mvp: ^1.0.0

Create a Model Class:

As Explained above a model class is created for both counter:-

class CounterModel {
int counter = 0;

CounterModel(this.counter);
}

Create the Presenter Class:

The Presenter is Created as this Basically Ensures the interaction with the model :

import 'package:fluttermvpdemo/model/CounterModel.dart';
import 'package:fluttermvpdemo/view/Counter.dart';

class Presenter {
void incrementCounter() {}
void decrementCounter() {}
set counterView(Counter value) {}
}

class BasicCounterPresenter implements Presenter {

CounterModel _counterViewModel;
Counter _counterView;

BasicCounterPresenter() {
this._counterViewModel = new CounterModel(0);
}

@override
void incrementCounter() {
this._counterViewModel.counter++;
this._counterView.refreshCounter(this._counterViewModel);
}

@override
void decrementCounter() {
this._counterViewModel.counter--;
this._counterView.refreshCounter(this._counterViewModel);
}

@override
set counterView(Counter value) {
_counterView = value;
this._counterView.refreshCounter(this._counterViewModel);
}


}

Adapting it Into The View :

The controller is then bound to the view.dart file so that the increment and decrement functionality may work as depicted.

class HomePage extends StatefulWidget {
final Presenter presenter;

HomePage(this.presenter, {Key key, this.title}) : super(key: key);

final String title;

@override
_MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<HomePage> implements Counter {
CounterModel _viewModel;

@override
void initState() {
super.initState();
this.widget.presenter.counterView = this;
}

@override
void refreshCounter(CounterModel viewModel) {
setState(() {
this._viewModel = viewModel;
});
}

@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(bottom: 30.0),
child: Text(
"Click buttons to add and substract.",
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
FloatingActionButton(
onPressed: () {
this.widget.presenter.decrementCounter();
},
tooltip: 'Decrement',
child: Icon(Icons.remove),
),
Text(
_viewModel?.counter.toString(),
style: Theme.of(context).textTheme.display1,
),
FloatingActionButton(
onPressed: () {
this.widget.presenter.incrementCounter();
},
tooltip: 'Increment',
child: Icon(Icons.add),
),
],
),
],
),
),
);
}
}

Find the code version on github at:

flutter-devs/Flutter_MVP_Demo
A new Flutter application. This project is a starting point for a Flutter application. A few resources to get you…github.com

Closing Thoughts

Design Pattern is a Quintessential tool in large scale apps in native applications which you can also practice in flutter also. In this Blog, the only MVP has been explained but this will a series of blogs, and in the next blogs, we will be sharing about MVVM, CLEAN, etc.

If you have not used Design Patterns in Flutter, I hope this article has provided you with valuable information about what is all about it, and that you will give it Design Patterns — a Try. Begin using them for your Flutter Apps !!

You can find each part of this series for the posts in the links below:

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 has been working on Flutter for quite some time now. You can connect with us on Facebook and Twitter for any flutter related queries.

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

Thank you for reading. 🌸

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

FlutterDevs Startup Incubator Programme

0

A whopping 150 million startup exist in the world today with new ones coming up everyday but not many can survive the paradigm shift of the fierce competition in the business — startup have to go through 2 way challenge — One from the Established Monopolistic Business that have dominated in the market place and the latter from the new Emerging ones that are regularly in the market having innovative ideas , making it highly likely to get swallowed by their shadows.

Even the greatest of the Idea will always need the guidance of a mentor in clearing the roadblocks.One other key challenges that startup have to deal up with is attributed to finances with their majorly relying on Investors that might loose interest if they discontinue showing progress at an upscale. Many of them also lacks in forming proper marketing strategy that place a vital factor in deciding the position and role of a business’s products or services in the market.They need to be resilient and focused to anticipate difficulties and pitfalls beforehand.

In Order to Help In Upscaling The StartUp with their current problems FlutterDevs has come up with a FlutterDevs StartUp Incubator programme helping startups. Let’s Know About the programme further:

FlutterDevs Startup Incubator Programme :

FlutterDevs Startup Incubator Programme is a platform being Initiated to avail a platform for newly emerging startups keeping in mind the factors needed for proper functioning of a young emerging Business availing all the facilities under a single roof which contains —

: UI/UX : Dedicated Team guiding for the technical and graphic designs of the product including aspects of branding, design, usability and function.

: SEO & Marketting : They can contribute by driving additional traffic & visibility in organic search by doing content/link/keyword research & content creation and the ability to do massive PR/Awareness/Brand campaigns giving a pedal to your startup.

: QA Testing : They can serve as an Umbrella facilitating smooth testing procedures by finding bugs or missteps thereby assuring that user requirements are met properly .

: Conceptualisation Team: Conceptualising team consist of core members that may guide about the market needs that you might need to capitalize.

: Development Team: A Profound Mobile Development Team having extensive experience in flutter development practices that are best suitable for your StartUp.

The In-House availability of all the key resources ensure efficient and control resulting in better user performance .

Why FlutterDevs?

FlutterDevs is a Full-Cycle Flutter app Development company and have leveraged this technology since its inception to deploy cutting edge apps across iOS and Android play stores efficiently.The possibilities with this Cross-Platform app development technology are endless and our Early adoption for this new Google tech has given us a platform to contribute our learning to the Community which we also consider as One of our Moral Responsibility . Some prominent ways FlutterDevs can help you strengthen your Startup are:

: Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase making the platform cost effective for development and maintenance.

: Fastening MVP (Minimum Viable Product) Creation Process to satisfy early Investors with Industry experts having Extensive Experience across multiple domains.

: 100+ Readymade Themes , plugin & module made on varied sectors ready to be integrated in your MVPs

: Give life to your amazing idea with the constant support of our excellent UI/UX team that will be involved in entire process providing meaningful and relevant experiences to users.

: FlutterDevs possess an In-House SEO And Digital Marketing team enhancing your marketing strategies & campaigns aligned with your goals.

FlutterDevs at Glance

What helps us demonstrate FlutterDevs as a Protruding Flutter App development company is that we possess an Extensive In-house Team of 30+ Flutter developers, Material Theming experts and a Proficient Cross Platform Testing including QA Analyst Team To strengthen Your Startup across various dimensions. Here is a showcase describing our flutter journey so far :

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 has been working on Flutter for quite some time now. You can connect with us on Facebook and Twitter for any flutter related queries.

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

Automation Testing In Flutter

0

Google recently announced that more than over 2 million Developers Worldwide have laid their hands on Flutter. After the language’s roll-out at the Google I/O ’18, This revelation from the search giant immensely Signifies diversion of developers from Native development to the Newer Technologies Building Extensive Cross-Platform Apps. Flutter started its life as an open-source UI framework that helps developers build native interfaces supporting different device sizes, pixel densities & orientations creating a magnificent digital experience.

In this article, We will have a look at How to do Automation Testing in a project through the help of fluttering its features and customisation available:

Introduction to Automation Testing:

Testing Apps with Multiple Features is Quite Cumbersome on manual Testing. Therefore, Automation Testing comes in place ensuring the tested app is not Error-prone before publishing it. Keeping into Consideration the bug solving speed and feature Intended in the Apps are not at all Compromised. Automation Testing is Quite Eventful for large scale apps were manually testing each feature might not be suitable.

Necessity of Testing?

Testing serves as a vital part of mobile application development in finding bugs & errors promptly making sure that the application works perfectly in future with the requirements :

  • It’s a vital factor in the development process that brings to market a high-quality product.
  • It helps to guarantee an in-depth analysis of functionality.
  • The testing process requires precise planning and execution

The Flutter framework provides comprehensive support for Automation Testing of Mobile Apps.

What Comprehends Automation testing?

Automation Testing is a software testing technique making sure the requirements meet the results. Testing is done by writing testing scripts with test cases. As we know that app nowadays is multi-featured apps making it rigorously difficult to test apps but this problem is removed by Automation Testing in Flutter which makes sure your app is bug-free & Performant.

Automated testing falls into three categories mainly:

We will try to explain all about Unit and Widget Testing in the Blog with the second part of the Blog explaining about Integration testing in Flutter.

Unit testing

Unit refers to a single unit referring to testing up a single module or a class making sure the basic functionality works on multiple conditions.

  • Writing Unit tests will require the addition of test package.
  • Using a TextField Validator Class containing validator methods for email & password validation. The file can be seen in the demo by the name as Validator.dart
import 'package:automation_testing_module/utils/constants.dart';class Validator {
//email validation method
static String validateEmail(String value)
{
String pattern = r'^(([^<>()[\]\\.,;:\s@\"]+(\.
[^<>() [\]\\.,;:\s@\"]+)*)'r'|(\".+\"))@((\[[0-9]{1,3}\.
[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])'r'|(([a-zA-Z\-0-9]+\.)
+[a-zA-Z]{2,}))$'
;RegExp regExp = new RegExp(pattern);
if (value.isEmpty) {
return Constants.ENTER_EMAIL;
}
if (!regExp.hasMatch(value)) {
return Constants.INVALID_EMAIL;
} //returns null when valid return null;
} // password validation method static String validatePassword(String value) {
Pattern pattern =
r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$?^&*~]).{8,}$';
RegExp regex = new RegExp(pattern);
if (value.isEmpty)
return Constants.ENTER_PASSWORD;
else if (value.length < 8)
return Constants.INVALID_PASSWORD;
else if (!regex.hasMatch(value)) return Constants.INVALID_FORMAT_PASSWORD;
return null;
}
}
  • Creating a class under test directory by name unit_test.dart.
import 'package:automation_testing_module/utils/constants.dart';
import 'package:automation_testing_module/utils/validator.dart';
import 'package:test/test.dart';
void main() {

//Email validation test
test('Email Not Entered Test', () {
var result = Validator.validateEmail('');
expect(result, Constants.ENTER_EMAIL);
});
test('Invalid Email Entered Test', () {
var result = Validator.validateEmail('akshay@aeologic');
expect(result, Constants.INVALID_EMAIL);
});
test('Valid Email Entered Test', () {
var result = Validator.validateEmail('akshay@aeologic.com');
expect(result, null);
});
  //Password validation test
test('Password Not Entered Test', () {
var result = Validator.validatePassword('');
expect(result, Constants.ENTER_PASSWORD);
});
test('Invalid Password Entered Test', () {
var result = Validator.validatePassword('1234567');
expect(result, Constants.INVALID_PASSWORD);
});
test('Invalid Password Format Entered Test', () {
var result = Validator.validatePassword('unittest');
expect(result, Constants.INVALID_FORMAT_PASSWORD);
});
test('Valid Password Test', () {
var result = Validator.validatePassword('Unittest@123');
expect(result, mull);
});
}

Above can be found is written test for Multiple Test Cases.

Run Using the following command at Terminal by:

flutter test test/unit_test.dart

Refactoring:

  • the test function is called which will create a test case with the given description and body, there are also other properties of test functions which can be used as needed but these two are appropriate to run the test.
  • We called validateEmail() method by giving null value and storing it in the result variable afterwards.
  • expect() method keep an eye whether the value passed and the expected value is similar.

Widget testingWidget Testing corresponds to the testing of the Widgets on certain circumstances which means how the widget responds on any particular event and how a widget is altered on an event occur.

  • Adding flutter_test package in pubsec.yaml. The package provides additional utilities for testing Widgets.
  • Herewith In the demo, Login Page consisting of text fields for namely email and password field is present with a Material Button. The event will occur on the tap of Material Button click event namely widget_testing_view.dart.

Code Implementation:

/media/1bccf15a228a804095203c33a34bd37d

  • If Entered data is valid and the login button is pressed a text widget will show the Valid data text.
  • Using the above widget for testing by creating a test class for the purpose namely widget_test.dart.
  • We will use the above widget for the testing and create a testing class for it named widget_test.dart
import 'package:automation_testing_module/view/widget_testing_view.dart';
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void main() {testWidgets('Login Successful',(WidgetTester widgetTester) async {

//Renders the UI from the given widget
await widgetTester.pumpWidget(LoginWidget());// Widget finders using key & type
final emailTextFieldFinder = find.byKey(Key('emailKey'));
final passwordTextFieldFinder = find.byKey(Key('passwordKey'));
final buttonFieldFinder = find.byType(MaterialButton);//enters text to the TextFormField using enterText
await widgetTester.enterText(emailTextFieldFinder,
'akshay@aeologic.com');
await widgetTester.pump();
expect(find.text('akshay@aeologic.com'), findsOneWidget);//enters text to the TextFormField using enterText
await widgetTester.enterText(passwordTextFieldFinder,
'Unittest@123');
await widgetTester.pump();
expect(find.text('Unittest@123'), findsOneWidget);//make the button click event
await widgetTester.tap(buttonFieldFinder);
await widgetTester.pump();//check for the response after button tap
final textFinder = find.text('Valid Data');
expect(textFinder, findsWidgets);

});
}

Run it by using the command flutter test test/widget_test.dart in Terminal.

Explanation:

Some prominently used methods are explained as:

  • testWidgets() function is used to create a widget test case as of test() is used in unit testing. But what it differs is the WidgetTester, it interacts with widgets and the test environment.
  • pumpWidget() function build and renders the provided widget in the test environment.
  • find() function searches for the widget using the Finder in flutter_test. The widgets can be searched using this.
  • pump() this function calls the setState() method in test environment and rebuild the widget.

So here how it goes, firstly we create a test using testWidgets() with the description and render the LoginWidget() in the test environment, once the widget is rendered the widgets are found by using the byKey() and byType() finders. Using the enterText() we input the text to the TextFormField, the button click event is called using the tap() in the test environment and if the Form validates the validDataFilled variable is set to true.

After this, we check for that the expected text is found in the widget.

Check out the demo code version on GitHub at:-

flutter-devs/Flutter_Automation_Testing
A new Flutter application. This project is a starting point for a Flutter application. A few resources to get you…github.com

Closing Thoughts

This article would serve as an Exploratory article for Flutter Testing and its working using Flutter. Automation Testing is an all- Important Tool in Large Scale Apps in native applications which has now also been introduced in flutter’s latest version also. This basically Ensures Deployment of the error Free version of the App & Decrease in Development time by Preventing any Undesirable errors to occur. Automation Testing is a must-case Scenario when it’s not practically possible to test each test case.

If you have not used Automation Testing, I hope this article has provided you with valuable information about what is all about Automation Testing, and that you will give it Automation Testing — a Try. Begin using for your apps !!

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 has been working on Flutter from quite some time now. You can connect with us on Facebook and Twitter for any flutter related queries.

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

Thank you for reading. 🌸

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

www.flutterdevs.com

Explore Flutter 1.17 & Dart 2.8

0

Introduction

Welcome to the new version of “WORLD OF WIDGETS” and “Dart”. In this post, we shall discuss about the new updates of flutter and dart together. Let’s explore the new changes with me in this blog.


Table of Content

  1. Dart 2.8
  2. Flutter 1.17

Dart 2.8

There are two changes made by the Dart team in the Dart 2.8 SDK:-

  1. Improves performance in Pubget.
  2. Keeps our packages dependencies up-to-date.

flutter pub updated

Here is what is got when I run the pub outdated or fluter pub outdated command from my terminal.

C:\Users\anmol seth\AndroidStudioProjects\dialog_box>flutter pub outdated
Dependencies Current Upgradable Resolvable Latest
giffy_dialog *1.6.1 1.7.0 1.7.0 1.7.0

dev_dependencies: all up-to-date

transitive dependencies
collection *1.14.11 1.14.12 1.14.12 1.14.12
flare_dart *2.3.2 2.3.4 2.3.4 2.3.4
flare_flutter *1.8.3 2.0.3 2.0.3 2.0.3

transitive dev_dependencies
archive *2.0.11 2.0.13 2.0.13 2.0.13
args *1.5.2 1.6.0 1.6.0 1.6.0
async *2.4.0 2.4.1 2.4.1 2.4.1
boolean_selector *1.0.5 2.0.0 2.0.0 2.0.0
charcode *1.1.2 1.1.3 1.1.3 1.1.3
crypto *2.1.3 2.1.4 2.1.4 2.1.4
image *2.1.4 2.1.12 2.1.12 2.1.12
path *1.6.4 *1.6.4 *1.6.4 1.7.0
pedantic *1.8.0+1 - - 1.9.0
petitparser *2.4.0 *2.4.0 *2.4.0 3.0.2
quiver *2.0.5 2.1.3 2.1.3 2.1.3
source_span *1.5.5 1.7.0 1.7.0 1.7.0
test_api *0.2.11 0.2.15 0.2.15 0.2.15
xml *3.5.0 *3.6.1 *3.6.1 4.1.0

15
upgradable dependencies are locked (in pubspec.lock) to older versions.
To update these dependencies, use `pub upgrade`.

I got the suggestion regarding my current version and also the latest version available.

We can run pub upgrade to update these dependencies.


Flutter 1.17

The following changes are made in Flutter 1.17:-

  1. Google fonts
  2. Better performance
  3. Metal Support for ios
  4. New widgets / Updated Widgets
  5. Material Text Scale
  6. App size improvement
  7. Network tracking Tools
  8. Hot reload improved
  9. Default use of Android X
  10. Samsung keyboard issue solved
  11. Updated the scrolling and text input widget

Google Fonts

This package is fantastic it provides us google_fonts API.

It provides us 977 read to use fonts without storing in our assets folder and mapped in pubspec.

Required Package

google_fonts | Flutter Package
The google_fonts package for Flutter allows you to easily use any of the 977 fonts (and their variants) from…pub.dev

import GoogleFonts

import 'package:google_fonts/google_fonts.dart';

use google _fonts

Text(
'This is Google Fonts',
style: GoogleFonts.lato(),
),

use google _fonts with TextStyle

Text(
'This is Google Fonts',
style: GoogleFonts.lato(
textStyle: TextStyle(color: Colors.blue, letterSpacing: .5),
),
),

google_fonts Theme()

MaterialApp(
theme: ThemeData(
textTheme: GoogleFonts.latoTextTheme(
Theme.of(context).textTheme,
),
),
);

Better Performance

  1. Faster and clear animation
  2. smaller apps
  3. lower memory utilization
  4. 20 % to 40 % better navigation
  5. 40 % reduction in CPU/GPU
  6. Better scrolling with less Memory Usage

Metal Support for ios

  1. Provides direct access to the GPU
  2. Reduced app frame rendering time

New Widgets / Updated Widgets

  1. NavigationRail
  2. New DatePicker
  3. Better Text Selection menu

NavigationRail()

A material StatefulWidget that is meant to be displayed at the left or right of an app to navigate between a small number of views, typically between three and five.

Properties

NavigationRail class
A material widget that is meant to be displayed at the left or right of an app to navigate between a small number of…api.flutter.dev

Example

https://gist.github.com/anmolseth06/e71626ea5540857a1dd9e2e013b3149c#file-navigation_rail_example-dart

DatePicker(), NavigationRail() and New Text input mode

DatePicker has been updated according to the material design and also text input mode.

You can see the Material Design of DatePicker : –

Material Design
Build beautiful, usable products faster. Material Design is an adaptable system-backed by open-source code-that helps…material.io

Material Text Scale

Source: https://medium.com/flutter/announcing-flutter-1-17-4182d8af7f8e

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.

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


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 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 #Flutter. We truly enjoy seeing how you use Flutter to build beautiful, interactive web experiences!

Thank you for reading. 🌸

Related: Explore Advanced Dart Enum

Related: Explore Sealed Classes In Dart

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