Google search engine
Home Blog Page 37

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. 🌸

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.

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. 🌸

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. 🌸

Local Authentication in Flutter

Introduction

Hello, I welcome you all to my new post on Local Authentication in Flutter. In this post, we shall discuss how to implement the FingerPrint in your flutter app for local authentication. So let’s start with the context.


Table of content

  1. Local Authentication
  2. Required Plugin
  3. Checking for biometric availability
  4. Checking biometric type
  5. Authentication using biometric
  6. Designing a simple App

Local Authentication

Verifying the user locally i.e. without the use of a web server, using facelock or fingerprint can be termed as Local Authentication.

  1. biometric authentication on iOS
  2. fingerprint APIs on Android

Required Plugin

Fortunately, we have a plugin managed by the flutter team.

Just go to pub.dev and search for local_auth package.

Install the dependencies in your pubspec.yaml file.

dependencies:
local_auth: ^latets version

install the dependence

Useflutter_pub_get command to install the dependence.

import the package

import 'package:local_auth/local_auth.dart';

Checking for biometric availability

final LocalAuthentication auth = LocalAuthentication();
bool canCheckBiometrics = false;
try {
canCheckBiometrics = await auth.canCheckBiometrics;
} catch (e) {
print("error biome trics $e");
}

print("biometric is available: $canCheckBiometrics");

We are using the try and catch method for checking biometric and catching errors.

initializing LocalAuthentication

final LocalAuthentication auth = LocalAuthentication();

canCheckBiometrics

bool canCheckBiometrics = false;

We have made a bool variable canCheckBiometrics which is initially set to false.

We are using it to set/update the availability of biometric.

auth.canCheckBiometrics

Here canCheckBiometrics is a method of LocalAuthentication() object which returns a boolean value.


Checking biometric type

List<BiometricType> availableBiometrics;
try {
availableBiometrics = await auth.getAvailableBiometrics();
} catch (e) {
print("error enumerate biometrics $e");
}

print("following biometrics are available");
if (availableBiometrics.isNotEmpty) {
availableBiometrics.forEach((ab) {
print("Avalible Biomatrics: $ab");
});
} else {
print("no biometrics are available");
}

getAvailableBiometrics() method returns the list of available Biometrics.


Authentication using biometric

bool authenticated = false;
try {
authenticated = await auth.authenticateWithBiometrics(
localizedReason: 'Touch your finger on the sensor to login',
useErrorDialogs: true,
stickyAuth: false,
androidAuthStrings:
AndroidAuthMessages(signInTitle: "Login to HomePage"));
} catch (e) {
print("error using biometric auth: $e");
}
print("authenticated: $authenticated");

authenticateWithBiometrics() is a method that returns a dialog box to provide a message to the user to press the fingerprint sensor for authentication.

To read more about each method you can press Ctrl+B in that particular method.

Full method

void _checkBiometric() async {
final LocalAuthentication auth = LocalAuthentication();
bool canCheckBiometrics = false;
try {
canCheckBiometrics = await auth.canCheckBiometrics;
} catch (e) {
print("error biome trics $e");
}

print("biometric is available: $canCheckBiometrics");

List<BiometricType> availableBiometrics;
try {
availableBiometrics = await auth.getAvailableBiometrics();
} catch (e) {
print("error enumerate biometrics $e");
}

print("following biometrics are available");
if (availableBiometrics.isNotEmpty) {
availableBiometrics.forEach((ab) {
print("\ttech: $ab");
});
} else {
print("no biometrics are available");
}

bool authenticated = false;
try {
authenticated = await auth.authenticateWithBiometrics(
localizedReason: 'Touch your finger on the sensor to login',
useErrorDialogs: true,
stickyAuth: false,
androidAuthStrings:
AndroidAuthMessages(signInTitle: "Login to HomePage"));
} catch (e) {
print("error using biometric auth: $e");
}
setState(() {
isAuth = authenticated ? true : false;
});

print("authenticated: $authenticated");
}

Designing a simple App

Github link

anmolseth06/local_auth
A new Flutter application. This project is a starting point for a Flutter application. A few resources to get you…github.com


Hi, I am Anmol Gupta, a Flutter Developer, content writer, and now udemy instructor. I am a passionate application developer and curious learner and I love sharing my knowledge with others that’s why I decided to write on medium, and now I am expanding my capabilities by creating a demanding udemy course that will help Flutter Developer to learn advanced functionalities that will directly help you in landing high paying job or getting high paying clients internationally.

Who is this course for?

Want to build Flutter apps with native functionalities?

  1. Want to learn advanced Flutter functionality?
  2. Want to learn job-oriented and high-demand, high-paying flutter iOS and android functionality?

What does this course offer?

  1. Flutter Razorpay payment gateway integration: In this module, we shall learn about Razorpay payment gateway integration which will help us to process the payment of the purchases made by the user.
  2. Flutter Stripe payment gateway integration: In this module, we shall learn about Stripe payment gateway integration which will help us to process the payment of the purchases made by the user.
  3. FLUTTER SCAN AND GENERATE QR CODE: In this module, we shall learn how we can scan a QR code and generate the QR code in Flutter.
  4. FLUTTER FIREBASE EMAIL PASSWORD AUTHENTICATION: In this module, we will learn how we can perform authentication using an email password provider, we will also learn how we can verify the user’s email and reset the password.
  5. FLUTTER FIREBASE PHONE AUTHENTICATION: In this module, we will learn how we can perform authentication using a phone authentication provider, and we will see how we can send the OTP to the provided phone number and sign in using the phone credentials.
  6. FLUTTER FIREBASE GOOGLE AUTHENTICATION: In this module, we will learn how to perform authentication using the google authentication provider using firebase in flutter.

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

Thank you for reading. 🌸

Why Flutter is the Best Choice for Mobile Development?

0

Let’s go In through the Blog to Know all about Flutter and why it is the optimum choice of Framework to develop mobile applications in 2020!

With 2.87 million apps in Google Play Store and 2.2 Million apps available in Apple’s app store, It is amply clear that mobile app development has become an paramount need of the hour for businesses of all domains.

With the rapidly changing market and increasing competition, it has become daunting for all-level enterprises and startups to survive in the cut-throat competitive market without having mobile apps for their business.

iOS and Android are two of the main platforms when it comes to Mobile App Development. For application development, these platforms need different types of coding each. This situation of developing two different apps for different platforms came as a problem for both Clients and Mobile app development companies.

Cross-Platform Application Development is developing mobile applications in a way that the apps run on various platforms. In this type of development, apps are built using a single programming language. Which is faster and more effective from a business standpoint.

Some of the popular frameworks for cross-platform development, one could choose a few: Xamarin by Microsoft, React Native by Facebook, PhoneGap from Adobe, Ionic, Cordova, etc. Each of these frameworks comes with multiple features along with pros and cons.

Why Should entrepreneurs consider Cross-Platform Mobile Apps

Talking about mobile application development, Enterprise and Start-up owners generally chose from Native and Cross-Platform Development.

Where Native apps are the ones that are made especially for one platform either Android or iOS then there are Cross-platform Apps that are developed to run on both the platforms in one go.

There are a lot of benefits of developing a common app for both of the major platforms — Android & iOS –

  • Lower Development Time — Cross Platform application development makes the developer write and work on a single codebase and not to make two different versions of the application, results in saving a lot of time and effort and develops the app faster.
  • Lower Testing Time — Because of developing a single application, the Quality Analyst Experts have to test the performance of one app instead of testing two different platforms with numbers of devices and operating systems
  • Reduced Development Cost — With lower development time, efforts, and lesser time in testing the app, what comes is the Reduced App Development Cost as the time allocation of the development resources lowers.
  • Lower Publishing time- Since the development of your mobile application takes significantly less time compared to a native app development process, it makes the entrepreneurs publish the app faster to the market and get an early bird benefit.

Now, not wanting to be left out of the exploding mobile market and constant improvement in technology, Google gave birth to Flutter. Flutter, google’s latest cross-platform framework for developing android and iOS apps.

Flutter was released by Google in late 2018 and ever since it has been praised all over the world for its scalability and proficiency in cross-platform app development. Now, Let’s straight-up dive deeper into understanding Flutter, it’s pros and cons, and Why Flutter is a Big Deal today.

What is Flutter ?

Flutter is an open-source UI Framework and software development kit intended to fasten and simplify the UI and app creation process. Flutter was launched with features that were missing in the previous Cross-Platform development frameworks. Flutter is Google’s open-source technology that enables the use of a single codebase for the creation of native Android and iOS apps. Rather than being a framework, it is a complete SDK (software development kit) that contains everything you require for cross-platform mobile app development.

Flutter is the only cross-platform framework that provides reactive views without requiring JavaScript Bridge. Google Developers have been rigorously working on this before making it generally usable. Here are things they worked on:

  • Support for app development on windows
  • Ability to support a greater number of Firebase APIs
  • Improved documentation
  • Internationalization
  • Supporting Chat, Ads and online videos
  • Tools for visual studio and android studio
  • Bug Fixes
  • Accessible to all types of developers.

Now that we clearly see the dominance of Flutter over every other Cross-Platform Framework, it is time to take a look at the reasons which will validate that Flutter is a striker in the market for entrepreneurs.

According to the GitHub’s OCTOVERSE report of 2019, Flutter is one of the fastest growing open source projects and it has climbed to the 2nd position.

Popular Apps Built With Flutter:

: Social Networking: KlasterMe, Pairing, Meeve
: Photo & Video: PostMuse
: Health & Fitness: Reflectly, Watermaniac
: Music & Entertainment: Hamilton, Topline, InKino, Music Tutor
: Sports: Top Goals, Dream 11
: Banking & Finance: Cryptomaniac Pro, Nubank
: Education: School Planner
: Shopping: HuYu, Xianyu
: Lifestyle: Pawfect Match
: Map & Navigation: Station La Moins Chère
: Business: Alibaba, AppTree, Google Ads
: Travel: Flydirekt
: Real Estate: Realtor.com, Emaar
: E-commerce: eBay

Why Should Startups Choose Flutter for their next big Idea?

Looking at the growing popularity of mobile apps pulls a few concerns for any app owner or a start-up:

  • With almost 3.5 billion smartphones and tabs being used all across the world in a burgeoning mobile technology market, how to launch the app with a limited budget?
  • Secondly, considering almost 300 million start-ups annually rolling out in the world, how to stand out in the crowd?

The simple answer to both the concerns is to develop your app using Cross-Platform Framework like Flutter. Moreover, flutter has been enormously popular with its impeccable User Experience with a sea full of flutter-based apps out there. One of the major use cases of Flutter is Google’s Adword app. A few other examples are Alibaba, a Chinese multinational E-commerce giant, Reflectly, Watermaniac, Tencent, Birch, and many more.

From an app owner’s perspective, developing an app in Flutter is Fast and cost-effective. There are a lot more advantages to Flutter app development.

Pros:

  • Faster App Development Process
  • Less Coding
  • Highly Reactive Framework
  • Accessible Native Features & SDKs
  • Perfect for MVP
  • Plugins Easy to Avail

What is FlutterDevs

FlutterDevs is a team of Tech Enthusiasts dedicated to making strikingly beautiful Flutter mobile applications. Profoundly committed to developing highly intriguing apps that strictly meet the business requirements and catering a wide spectrum of Design ideas.

At FlutterDevs , We have been working on the Flutter since its Alpha version which has definitely given us an edge over the others as we’ve been fondling with flutter from the very beginning. We have adopted a design first attitude which has always led to delivering the highest quality mobile applications.

We have not only been driving innovation when it comes to Flutter based applications but also committed to contribute, teach, and train the community of future developers. FlutterDevs believes in giving back to the tech community that’s why we have been adding:

  • 80+ Open Source Contribution on GitHub
  • 100 + Technical Blogs on Medium
  • Brainstorming every day with a strong 15k+ LinkedIn Followers
  • Regular meetups around the cities to learn and grow as a community
  • FlutterDevs Startup Incubator Programme is a platform being Initiated by FlutterDevs 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. know more about the programme :-

Why Should you Chose FlutterDevs ?

At FlutterDevs, we focus on challenging our limits of user-centered design by creating evident mobile solutions.Despite our code doing all the heavy lifting, we have always known that our mighty stats can narrate our story to you beforehand. Let’s jump to it:

  • Ranked 21 globally, for the most innovative flutter developers by GitHub.
  • 40+ Readymade themes.
  • 10+ years of mobility experience.
  • 30+ Projects Delivered

FlutterDevs at a Glance!

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

Augmented Reality in Flutter

Introduction

AR core in flutter is a beautiful plugin that provides us API to implement Argumented reality in flutter application. This is one of the emerging new technologies in the market. With this plugin, we shall discuss the various features provided by this plugin the flutter, so let’s start.


Table of content

  1. Enable ARCore
  2. Installing plugin
  3. Classes provided by the plugin
  4. Making a Sphere
  5. Making a Cylinder
  6. Making a Cube
  7. GitHub Link

Enable ARCore

To enable ARCore functionality in Android Studio you need to perform the following steps:-

  1. Add AR Required or AR Optional entries to the manifest

AR Required

You need to include the following entries in your AndroidManifest.xml file:-

<uses-permission android:name="android.permission.CAMERA" />
<uses-sdk android:minSdkVersion="24" />
<uses-feature android:name="android.hardware.camera.ar" />
<application …>
<meta-data android:name="com.google.ar.core" android:value="required" />
</application>

AR Optional

<uses-permission android:name="android.permission.CAMERA" />
<uses-sdk android:minSdkVersion="14" />
<application>
<meta-data android:name="com.google.ar.core" android:value="optional" />
</application>

The difference between the AR Optional and AR Required is that AR Required app requires an ARCore Supported Devices that had Goole Play Services for AR installed in it. In AR Required apps the play store automatically stores the Goole Play Services for AR.

While in AR Optional apps can be installed and run on the devices that don’t support ARCore and also play store will not install the Goole Play Services for AR automatically.

2. Modify build.gradle

Please make sure in your projects build.gradle file includes the following code.

allprojects {
repositories {
google()

Add the following dependencies inside your app-level build.gradle file

dependencies {
implementation 'com.google.ar:core:1.16.0'
}

3. Sceneform plugin in your app-level build.gradle file

android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
dependencies {
implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.8.0'
implementation 'com.google.ar.sceneform:core:1.8.0'
}

4. Enable android X

Add the following code into your gradle.properties

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

Installing Package

arcore_flutter_plugin | Flutter Package
Thanks to Oleksandr Leuschenko for inspiration and his precious code: arkit_flutter_plugin I wrote 2 articles for setup…pub.dev

This is the plugin that I am using for my project.

Update the dependencies in your pubspec.yaml file.


Classes provided by the plugin

There are a total of 13 classes provided by this plugin until May 2020.

  1. ArCoreView
  2. ArCoreController
  3. ArCoreFaceView
  4. ArCoreFaceContrller
  5. ArCoreSphere
  6. ArCoreCylinder
  7. ArCoreCube
  8. ArCoreNode
  9. ArCoeMaterial
  10. ArCoreHitTestResult
  11. ArCoreRotatingNode
  12. ArCorePlane
  13. ArCoreReferenceNode

ArCoreView

This class returns the view type. There are two types of views in it.

  1. AUGMENTEDFACE
  2. STANDARDVIEW

There are 4 properties in it:-

  1. onArCoreViewCreated
  2. enableTapRecoginzer
  3. enableUpdateListener
  4. type

onArCoreViewCreated

This property takes a ArCoreController. We shall discuss about ArCoreController in our later section.

enableTapRecoginzer

Initially, set to false. It is used as an argument by the MethodChannel.

enableUpdateListener

Initially, set to false. It is used as an argument by the MethodChannel.

type

It is a view type, it is either AUGMENTEDFACE, STANDARDVIEW. It is set to STANDARDVIEW by default.

ArCoreController

This controller used to add a ArNode using addArCoreNode function, add a ArCoreNode with ancher using a addArCoreNodeWithAncher function and also remove node using removeNode function.

ArCoreFaceView

It is a stateful widget that returns a ArCoreAndroidView. It has two properties enableAugmentedFaces, onArCoreViewCreated.

Initially, enableAugmentedFaces is set to false.

onArCoreViewCreated takes a function with ArCoreController argument.

ArCoreFaceController

It used dispose and loadMesh method to control the FaceView.

ArCoreSphere

It is ArCoreShape, takes a radius and ArCoreMaterial.

ArCoreCylender

It is ArCoreShape, takes a radius, height, and ArCoreMaterial.

ArCoreCube

It is ArCoreShape, takes a size i.e. Vector3 and ArCoreMaterial.

ArCoreNode

This widget is used to provide the position, shape, scale, rotation, name.

ArCoreMaterial

It is used to describe the outlook of the virtual object created by the user.

It has color,textureBytes, metallic, roughness, reflection.

ArCoreRotatingNode

It is an ArCoreNode with a degreesPerSecond property which is a double value.

ArCorePlane

It takes the x, y coordinate of the plane, ArCorePose, and ArCorePlaneType.

There are three types of plane:-

  1. HORIZONTAL_UPWARD_FACING
  2. HORIZONTAL_DOWNWARD_FACING
  3. VERTICAL

ArCoreReferenceNode

It is ArCoreNode, it has all the properties that the ArCoreNode has also it has objectUrl and object3DFileName.

objectUrl

URL of glft object for remote rendering.

object3DFileName

Filename of sfb object in assets folder.


Making a Sphere

void _addSphere(ArCoreController controller) {
final material = ArCoreMaterial(
color: Color.fromARGB(120, 66, 134, 244),
);
final sphere = ArCoreSphere(
materials: [material],
radius: 0.1,
);
final node = ArCoreNode(
shape: sphere,
position: vector.Vector3(0, 0, -1.5),
);
controller.addArCoreNode(node);
}

Making a Cylinder

void _addCylinder(ArCoreController controller) {
final material = ArCoreMaterial(
color: Colors.red,
reflectance: 1.0,
);
final cylinder = ArCoreCylinder(
materials: [material],
radius: 0.5,
height: 0.3,
);
final node = ArCoreNode(
shape: cylinder,
position: vector.Vector3(0.0, -0.5, -2.0),
);
controller.addArCoreNode(node);
}

Making a Cube

void _addCube(ArCoreController controller) {
final material = ArCoreMaterial(
color: Color.fromARGB(120, 66, 134, 244),
metallic: 1.0,
);
final cube = ArCoreCube(
materials: [material],
size: vector.Vector3(0.5, 0.5, 0.5),
);
final node = ArCoreNode(
shape: cube,
position: vector.Vector3(-0.5, 0.5, -3.5),
);

controller.addArCoreNode(node);
}

main.dart file

https://gist.github.com/anmolseth06/5f2d4708d907b1327d0756f482027e47#file-main-dart


GitHub Link :

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


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. 🌸

Flutter Text To Speech

Target Audience: Beginner

Plugin: Text-To-Speech Flutter plugin: flutter_tts

This flutter_tts plugin used to interact with native functionality. Under the hood, it uses TextToSpeech for Android, and AVSpeechSynthesizer for IOS platform. In this, we are exploring the methods of flutter_tts plugin. To check what we can achieve by this plugin.

Features

Android, iOS, & Web

  • [x] speak
  • [x] stop
  • [x] get languages
  • [x] set language
  • [x] set speech rate
  • [x] set speech volume
  • [x] set speech pitch
  • [x] is language available

Let’s start by installing it.pubspec.yaml dependencies

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

As it is mentioned by officials

Change the minimum Android SDK version to 21 (or higher) in your android/app/build.gradle file.

minSdkVersion 21

There are three handlers (setStartHandler ,setCompletionHandler,setErrorHandler) which are responsible for changing the state of play, stop and for the error handler. We have to initialize these handlers at first before using its state (TtsState)

flutterTts = FlutterTts();
flutterTts.setStartHandler(() {
setState(() {
print("playing");
ttsState = TtsState.playing;
});
});
flutterTts.setCompletionHandler(() {
setState(() {
print("Complete");
ttsState = TtsState.stopped;
});
});
flutterTts.setErrorHandler((msg) {
setState(() {
print("error: $msg");
ttsState = TtsState.stopped;
});
});

To play

Our input is in our speak method. if the input is valid then we change the state to TtsState.playing

var result = await flutterTts.speak("I am a flutter developer");
if (result == 1) setState(() => ttsState = TtsState.playing);

To Stop

var result = await flutterTts.stop();
if (result == 1) setState(() => ttsState = TtsState.stopped);

Language change

flutterTts.setLanguage("en-Us");

you can get the list of languages it’s currently supported

languages = await flutterTts.getLanguages;

Setting Voice

_flutterTts.setVoice("en-us-x-sfg#male_1-local" )

You Can Check Language Availability

await flutterTts.isLanguageAvailable("en-US");

You can change the volume, pitch rate

await flutterTts.setVolume(volume);
await flutterTts.setSpeechRate(rate);
await flutterTts.setPitch(pitch);

Link for repository:

flutter-devs/text-To-speech-demo
A new Flutter text to speech application. This project is a starting point for a Flutter application. A few resources…github.com

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

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


Flutter Speech Recognition

Target Audience: Beginner

Plugin: speech_recognition

A flutter plugin to use the speech recognition on iOS and Android

Adding Permission

Android :

<uses-permission android:name="android.permission.RECORD_AUDIO" />

iOS

Add Info.plist :

  • Privacy — Microphone Usage Description
  • Privacy — Speech Recognition Usage Description
<key>NSMicrophoneUsageDescription</key>
<string>This application needs to access your microphone</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>This application needs the speech recognition permission</string>

Defining Variables :

_isAvailable : tell the platform is Android or ios is available to interact with it or not

_isListening: tell us whether or not the app is currently listening to the microphone

resultText: in this, we set our final text that comes from our speech

 SpeechRecognition _speechRecognition;
bool _isAvailable = false;
bool _isListening = false;
String resultText = "";

Initialize it

First, we need to initialize some bunch of different callback for the speech recognition object to work everything properly

setAvailabilityHandler: which let us know about availability and here we update our _isAvailable variable.

setRecognitionStartedHandler: It starts executed when we start the speech recognition service. when its start working we set our _isListening true.

setRecognitionResultHandler: This is our main through this callBack we get out text from our speech recognition service. And here we set our resultText

setRecognitionCompleteHandler: It starts executed when we end with our speech recognition service. when its end up we set our _isListening false.

_speechRecognition = SpeechRecognition();

_speechRecognition.setAvailabilityHandler(
(bool result) => setState(() => _isAvailable = result),
);

_speechRecognition.setRecognitionStartedHandler(
() => setState(() => _isListening = true),
);

_speechRecognition.setRecognitionResultHandler(
(String speech) => setState(() => resultText = speech),
);

_speechRecognition.setRecognitionCompleteHandler(
() => setState(() => _isListening = false),
);

_speechRecognition.activate().then(
(result) => setState(() => _isAvailable = result),
);

Listening Speech Recognition Service

if (_isListening)
_speechRecognition.stop().then(
(result) => setState(() => _isListening = result),
);

OnStop

if (_isListening)
_speechRecognition.stop().then(
(result) => setState(() => _isListening = result),
);

OnCanceling

if (_isListening)
_speechRecognition.cancel().then(
(result) => setState(() {
_isListening = result;
resultText = "";
}),
);

Don’t forget to give permission

Link for repository

flutter-devs/speech-Recognition-demo
speech_recognition plugin exploring This project is a starting point for a Flutter application. A few resources to get…github.com

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

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


Exploring WebViews in Flutter

0

Many Times We are in Need to develop apps where in we can display web pages without needing to open up your device’s Browser , another thing might be that you have Implemented some functionality in your website that do not needs to be developed in your mobile app — WebViews may come in Handy at that place.

How many times have your applications asked you this thing ?

CHOOSE YOUR BROWSER

Annoying isn’t it ?

Here’s the solution to this ! Using Flutter you can now incorporate WebViews into your Flutter app to make all of this functionality possible.

WebViews does all the hard lifting for you. Imagine if you were having a secure payment setup already implemented on your website and you want to implement that functionality in your app. Now instead of re implementing the whole setup & logic for mobile application you can give your user an experience of using your website in your application using WebViews. And the best part is, you need not use some browser app to open that webpage. In this way , you can end up saving your time.


Table of Content

Adding Dependency

Webview

Webview Controller

Resources


Create a new flutter app

:: Open your IDE — Select new flutter project . Enter project name and then click Finish .This will install the sdk (if needed) and will create a new project.

Adding Dependency

To use webview_flutter , include the following dependency in your pubspec.yaml

dependencies:
webview_flutter: ^latest version

Check out the latest version of webview_flutter & additional setup required for iOS over here .

WebView

Instead of having full screen view controller we will use a widget WebViewwhich allow us to create a widget that will let us see the full web view in our app. It is just like any other widget in flutter (we will discuss this briefly further).

WebView(key: _key,
javascriptMode: JavascriptMode.unrestricted,
initialUrl: _url)
  • Key: If you have multiple webviews in your app , you might need to use keys which will be illustrated further.
  • javasriptMode : Whether Javascript execution is enabled. By default javascriptMode is disabled.
  • initialUrl : is the URL we want to display

WebView Controller

Finding out interesting bits and controlling your WebView is all done through webViewController. When WebView is fully built it returns a controller through a callback. The controller allows you to programmatically modify the WebView or access properties like the current URL being displayed

WebViewController _controller;
WebView(
initialUrl: 'https://flutter.io',
onWebViewCreated: (WebViewController webViewController) {
_controller = webViewController;
},
);
An exploring app written in Flutter using WebViews. You can email , like the pages for later viewing.

We will build a web exploring app for Payment Gateway , News , Wikipedia and Youtube. Each button will be a webview. In this app we would just test it for multiple webviews so that you can better understand the concept of Keys

You can find the complete code for this app at this Github Repository.

Webview app for News

Similary , other webviews like Payment Gateway , Youtube & Wikipedia work in the same manner. So let us now dive into the code !!

URL Button Push

Whenever the button for Webview is clicked , it passes the URL to the webViewContainer which contains all the webviews.

void _handleURLButtonPress(BuildContext context, String url) {
Navigator.push(context,
MaterialPageRoute(builder: (context) => WebViewContainer(url)));
}
}

webViewContainer will display your required URL inside our app. Hurray !!

https://gist.github.com/Anirudhk07/163ec51bc45aac01d722a21adcf48f95#file-gistfile1-txt

Are Webviews Widgets ?

Absolutely!

Remember ? I mentioned that webView in our app is just like any other Widget. Let me explain you this with an example.

Wikipedia Webview inludes features such as Add to Favorites & Email Link for later Viewing

In Webview you can layer other widgets on the top of them. WebView is just like any other widget in Flutter and can be composed with other widgets layering on top of it. The favorite button is just a regular FloatingActionButton that is hovering on top of the WebView, complete with the shadow effect you would expect with the button. Also, when the drop down menu from the app bar is open, it partially covers the WebView just like with any other widget underneath the menu.


Now let us go through some more interesting features —

Keys

We have multiple webviews in our app —

All the screens of app including multiple webviews

If you have multiple webviews in your app you might have to use keys. Keys are those optional parameters in just about every widget’s constructor in the flutter code base, if you have multiple stateful widgets of the same type that are added, removed, or reordered you might want to supply that key parameter. So with a collection of web view that you are adding or removing you can add a local key parameter, if you are doing something more complicated that uses the same webviews across two views we should use a global key so that flutter knows that the two webviews are actually same and doesn’t try to render the second.

For more details on how to use Keys go through the code or this video.


That’s all folks! You can now incorporate webviews to your own application.

Conclusion

Webviews provide a much easier way to render your web pages into your app. Using webviews you can ensure secured payment & secured redirecting. Now you don’t have to worry about those annoying pop-ups !

Happy Fluttering !!

Resources :

flutter-devs/Webview-Flutter
A Flutter plugin that provides a WebView widget on Android and iOS. – flutter-devs/Webview-Fluttergithub.com

webview_flutter | Flutter Package
A Flutter plugin that provides a WebView widget. On iOS the WebView widget is backed by a WKWebView; On Android the…pub.dartlang.org


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