Google search engine
Home Blog Page 37

Explore Lottie Animation In Flutter

0

Animations in a mobile application add intelligence to the UI just as some enhanced visualizations to it. Animations, when utilized effectively, can have a gigantic effect on how the user sees your application. Each mobile developer wishes to include animations in their application; however, they are unsuccessful in doing as such, because there is a ton of complexity and a ton of things a developer needs to learn before including animations.

Flutter has an awesome Animation library that permits you to make complex animations that can run continuously at 60 frames for each second without any problem.

In this article, we will Explore Lottie Animation In Flutter. We will also implement a demo of Lottie animation using the lottie package in your flutter applications.

lottie | Flutter Package
Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as json with…pub.dev

Table Of Contents::

Lottie Animation

Lottie Animation — Properties

Implementation

Code Implement

Code File

Conclusion



Lottie Animation

Lottie is a JSON-based animation file format. The Lottie animation files can be utilized in cross-platform applications as static assets.

Generally, all beginners have a similar inquiry; that is why we use Lottie Animation when flutter gives many animation widgets that are more simple to use than the Lottie animation movement.

Lottie is a widget that gives cool animation which makes the application more appealing; Lottie libraries and modules accessible with the expectation of complimentary Web, iOS, Android, Flutter, React Native, Xamarin, Native Script, Windows, Vue, Angular, QT, Skia, Framer X, Sketch for free.

Without much of a stretch, we can get the Lottie animation file from https://lottiefiles.com and can utilize it in our application.

LottieFiles – Free animation files built for Lottie
Loved by Designers & Engineers from Discover thousands of free animations for your products Most loved animators this…lottiefiles.com

Note: You will download Lottie animation files in Lottie json format only.

Then paste on your assets folder in your flutter project.

Lottie Animation — Properties

There are some properties of Lottie animation are:

  • Reverse: This property is used to reverse the motion in the animation.
  • Repeat: This property is used to keep repeating the animation. You will use false, then repeat animation will be stopped.
  • Animate: This property is used to animate the motion in the animation.

Implementation:

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:

lottie: ^latets version

Step 2: Import

import 'package:lottie/lottie.dart';

Step 3: Add Assets

Add assets to pubspec — yaml file.

We will add images in the assets folder.

assets:
- assets/

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

Step 5: Enable AndroidX

Add this to your gradle.properties file:

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

How to implement code in dart file :

You need to implement it in your code respectively:

Create a new dart file called lottie_page.dart inside the lib folder.

In Lottie files, you will add lottie json file in two types:

  • Asset
  • Network
  • Asset
Lottie.asset(
'assets/lottie_file.json',
repeat: false,
reverse: false,
animate: false,
),

Lottie files are a straightforward Flutter application with just one page. The screen has an app bar and a Center widget to put the animation on the screen. The Lottie.asset()add the JSON animation file and renders the animation.

  • Network
Lottie.network(
'https://assets8.lottiefiles.com/packages/lf20_HX0isy.json',
repeat: false,
reverse: false,
animate: false,
),

The Lottie.network() takes the URL of the JSON animation file and renders the animation. We will false repeat, reverse, and animate.

Code File

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';


class LottiePage extends StatefulWidget {
@override
_LottiePageState createState() => _LottiePageState();
}

class _LottiePageState extends State<LottiePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Flutter Lottie Animation Demo"),
automaticallyImplyLeading: false,
centerTitle: true,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Lottie.asset(
'assets/lottie_file.json',
repeat: true,
reverse: true,
animate: true,
),

Lottie.network(
'https://assets8.lottiefiles.com/packages/lf20_HX0isy.json',
repeat: true,
reverse: true,
animate: true,
),
],
),
),
);
}
}

You will see a full code on a GitHub, and this is a small demo program to use lottie animation; and the below video shows how lottie animation will work in your flutter applications.

Conclusion :

In the article, I have explained the basic architecture of Lottie Animation; you can modify this code according to your choice. This was a small introduction to Lottie Animation from my side and it’s working using Flutter.

I hope this blog will provide you with sufficient information in Trying up Lottie Animation in your flutter projects. This is a demo program to use lottie animation in a flutter and show how lottie animation will work in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter Lottie Animation Demo:

flutter-devs/flutter_lottie_animation_demo
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build…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 a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on FacebookGitHubTwitter, and LinkedIn for any flutter-related queries.

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

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


Responsive Flutter Layout With FittedBox Widget

0

Responsive application layout, its UI as per the size and shape of the screen or window. This is particularly essential when the equivalent application can run on an assortment of devices, from a watch, phone, tablet, to a PC or desktop computer. At the point when the client resizes the window on a PC or desktop or changes the direction of the phone or tablet, the application ought to react by adjusting the UI appropriately.

The idea of Responsive Design is tied in with utilizing one lot of code that reacts to different changes to the layout. Stages, for example, the iOS and local Android SDKs, handled this issue with “all-inclusive layouts.” The widespread layouts react to layout changes by utilizing imperatives and naturally resizing components.

In this blog, We will be going to explore the Responsive Flutter Layout With FittedBox Widget and show a demo of how to use a fitted box widget in your flutter applications.

Table Of Contents::

FittedBox

FittedBox — Usage

FittedBox — Implementation

FittedBox — Properties

Implementation

Code Implement

Code File

Conclusion



FittedBox

The FittedBox widget is a single child layout widget, which implies it can have just a single child assigned to it. In this model, the Row widget is added as a child to FittedBox widgets. The Row widget has two Conatiner as its children. Typically, the second child of Row widgets will overflow to the one side when it renders its children on a screen size, which isn’t adequate to oblige the entirety of its children. However, with FittedBox, this issue of a widget overflowing is solved. It scales and positions its child inside the parent widget.https://www.youtube.com/embed/T4Uehk3_wlY?feature=oembed

It makes a widget that scales and positions its child inside itself as indicated by Fit. FittedBox Widget is a basic Widget to help in making a snappy and neater approach to contain a child inside a parent. The fundamental purpose behind utilizing the FittedBox is to make the App UI look neater for dynamic children with shifting lengths.

FittedBox — Usage

  • The primary use is to create a simple Container that can fit any child inside it even if it scales during the app flow.
  • It gives a cleaner UI look to the application.
  • Helpful when Dynamic data is to be projected on the UI (like Images, Paragraphs).

FittedBox — Implementation

  • Make use of the FittedBox class.
  • Make sure that there is something to fit inside the Container/Card widget before using the FittedBox.
  • Primarily used inside ListViews in order to control dynamic Images and text; otherwise, you will use column also.

FittedBox — Properties

  • Primarily takes in two properties

— Fit

— Alignment

  • Important to also understand other Widgets like Container, Material, and playing around with the Child and Parent containers for better results.

Implementation:

Step 1: Add Assets

Add assets to pubspec — yaml file.

We will add images in the assets folder.

assets:
- assets/

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

Step 3: Enable AndriodX

Add this to your grade.properties file:

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

How to implement code in dart file :

You need to implement it in your code respectively:

Create a new dart file called fitted_box_page.dart inside the lib folder.

  • > Using without FittedBox
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Card(
color: Colors.white,
child: Row(
children: [
Container(
child: Text(
"Understand Without FittedBox",
style: TextStyle(fontSize: 20,color: Colors.black),
),
),
Container(
height: 200,
child:
Image.asset("assets/screen.png"),
),
],
),
),
],
),

Like we have seen, the example application looks underneath. The image is getting overflowed to the right, and the application can’t render it. Think about a circumstance where the information is going to come from a server. There will be very little control over what to render to the user and what not to render to the user. FittedBox widget ensures that the final data is being appropriately rendered to the user independent of how the data is. The child is compelled to fit inside the parent. We will perceive how the data can be Fit inside the Container in the rest of the areas underneath.

  • > Using with FittedBox

From the example above, the App looks appear as though it can’t handle the overflow of pixels. The Text widget we indicated is no place in the image. We will see what happens when the FittedBox widget is added to the application.

Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FittedBox(
child: Card(
color: Colors.white,
child: Row(
children: [
Container(
child: Text(
"Understand With FittedBox",
style: TextStyle(fontSize: 20,color: Colors.black),
),
),
Container(
height: 200,
child:
Image.asset("assets/screen.png"),
),
],
),
),
),
],
),

This is how the layout has been changed, and the application looks like,

Code File

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

class FittedBoxPage extends StatefulWidget {
@override
_FittedBoxPageState createState() => _FittedBoxPageState();
}

class _FittedBoxPageState extends State<FittedBoxPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("FittedBox Layout Widget Demo"),
centerTitle: true,
automaticallyImplyLeading: false,
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FittedBox(
child: Card(
color: Colors.white,
child: Row(
children: [
Container(
child: Text(
"Understand With FittedBox",
style: TextStyle(fontSize: 20,color: Colors.black),
),
),
Container(
height: 200,
child:
Image.asset("assets/screen.png"),
),
],
),
),
),
],
),
);

}
}

Conclusion :

In the article, I have explained the basic demo of the FittedBox Widget. You can modify this code according to your choice, and this was a small basic introduction of FittedBox from my side and its working using Flutter.

I hope this blog will provide you with sufficient information in Trying up Responsive Flutter Layout With FittedBox Widget in your flutter projects. FittedBox is principally helpful in handling dynamic data from the server. It ensures that the UI looks reliable and doesn’t give any spillages and break the UI flow. Make a point to try different things with the various values present before fixing on the last FittedBox property blend, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter FittedBox Widget Demo:

flutter-devs/flutter_fittedbox_widget_demo
A new Flutter application. This project is a starting point for a Flutter application. A few resources to get you…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 a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on FacebookGitHubTwitter, and LinkedIn for any flutter-related queries.

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

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


Bouncing Button Animation In Flutter

0

Animations assume a significant function in upgrading the general user experience of your application from the visual input, motion, and up to the animations you can actually envision!. Much the same as some other items coordinated into an application, animations must be a functional element instead of only a regular stylistic theme.

Utilizing the traditional frameworks, you would typically need to compose complex animation controllers and designs where you set the timings, tweens, and advances.

In this blog, We will be going to explore Bouncing Button Animation In Flutter and show a demo of how to make a bouncing button animation in your flutter applications.

Table Of Contents::

Flutter

Animation

Code Implementation

Code File

Conclusion



What is Flutter :

Flutter is Google’s UI toolkit that helps you build beautiful and natively combined applications for mobileweb, and desktop in a single codebase in record time.

Flutter — Beautiful native apps in record time
Paint your app to life in milliseconds with Stateful Hot Reload. Use a rich set of fully-customizable widgets to build…flutter.dev

What is Animation?

An animation comprises of estimation (of type T) along with status. The status demonstrates whether the animation is thoughtfully running from start to finish or from the end back to the start, despite the fact that the real estimation of the animation probably won’t change monotonically. Animations additionally let different items tune in for changes to either their worth or their status. These callbacks are called during the “animation” period of the pipeline, only before rebuilding widgets.

When it comes to creating a good user experience for your application, including all around made and liquid animations, are significant. They function as visual input for user activities and can likewise give the importance of connection and consolation.

Animating buttons are what this article is about; explicitly, we’ll manufacture a small bouncing animation that is set off when the user clicks a button.

Demo module::

Code Implementation :

Create a new dart file called bouncing_button.dart inside the lib folder.

On this page, we will create a container and a text. When the user taps the conatiner, then that bouncing animation will show it in your devices.

The button layout is based on a container with a text widget in its center. Let’s declare the _animatedButton() widget.

Widget  _animatedButton() {
return Container(
height: 70,
width: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100.0),
boxShadow: [
BoxShadow(
color: Color(0x80000000),
blurRadius: 12.0,
offset: Offset(0.0, 5.0),
),
],
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xff33ccff),
Color(0xffff99cc),
],
)),
child: Center(
child: Text(
'Press',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
color: Colors.black),
),
),
);
}

Let’s add animation

We should utilize the setState() and dispose() function and implement SingleTickerProviderStateMixin and characterize the main two properties, which we’ll have to make the animation.

It’s currently an ideal opportunity to initialize our _controller by overriding initState() and dispose of it by overriding the dispose function.

double _scale;
AnimationController _controller;
@override
void initState() {
_controller = AnimationController(
vsync: this,
duration: Duration(
milliseconds: 500,
),
lowerBound: 0.0,
upperBound: 0.1,
)..addListener(() {
setState(() {});
});
super.initState();
}

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

Next, we’re characterizing two functions, one for when the button is tapped down, and the other for when the button is released, the previous will advise our controller to go ahead, and the last to go backward.

At long last, in our build function, we set our scale variable and let a GestureDetector handle the top-down and tapUp properties and afterward scale utilizing the Transform Widget.

Code File :

import 'package:flutter/material.dart';

class BouncingButton extends StatefulWidget {
@override
_BouncingButtonState createState() => _BouncingButtonState();
}

class _BouncingButtonState extends State<BouncingButton> with SingleTickerProviderStateMixin {
double _scale;
AnimationController _controller;
@override
void initState() {
_controller = AnimationController(
vsync: this,
duration: Duration(
milliseconds: 500,
),
lowerBound: 0.0,
upperBound: 0.1,
)..addListener(() {
setState(() {});
});
super.initState();
}

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

@override
Widget build(BuildContext context) {
_scale = 1 - _controller.value;
return Scaffold(
appBar: AppBar(
title: Text("Flutter Bouncing Button Animation Demo"),
centerTitle: true,
automaticallyImplyLeading: false,
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('Press the Below Button',style: TextStyle(color: Colors.grey[400],fontSize: 20.0),),
SizedBox(
height: 20.0,
),
Center(
child: GestureDetector(
onTapDown: _tapDown,
onTapUp: _tapUp,
child: Transform.scale(
scale: _scale,
child: _animatedButton(),
),
),
),
],

),
);
}

Widget _animatedButton() {
return Container(
height: 70,
width: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100.0),
boxShadow: [
BoxShadow(
color: Color(0x80000000),
blurRadius: 12.0,
offset: Offset(0.0, 5.0),
),
],
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xff33ccff),
Color(0xffff99cc),
],
)),
child: Center(
child: Text(
'Press',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
color: Colors.black),
),
),
);
}

void _tapDown(TapDownDetails details) {
_controller.forward();
}

void _tapUp(TapUpDetails details) {
_controller.reverse();
}
}

Conclusion :

In the article, I have explained the basic architecture of Bouncing Button Animation; you can modify this code according to your choice, and this was a small introduction of Bouncing Button AnimationIn Flutter from my side and its working using Flutter.

I hope this blog will provide you with sufficient information in Trying up Bouncing Button Animation In Flutter in your flutter projects. This is a demo example of Bouncing Button Animation in a flutter, and how to animation will work when taps the button. So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter Bouncing Button Animation Demo:

flutter-devs/flutter_bouncing_button_animation_demo
A new Flutter application. This project is a starting point for a Flutter application. A few resources to get you…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 a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on FacebookGitHubTwitter, and LinkedIn for any flutter-related queries.

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

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


How to use Twilio SMS in Flutter 2026

0

Google has confined admittance to just those applications that have been set as the client’s default applications for settling on decisions or sending messages. The sole aim behind delivering this update was to ensure the frequently heedless client who approaches allowing consents for each application without cautious contemplations. Once truly, clients infrequently renounce these authorizations, which accordingly, gives numerous applications full admittance to the client’s SMS and call log history regardless of whether they no longer need access.

In this article, we will explore Sms Using Twilio In Flutter. We will also implement a demo the sends SMS feature using the twilio_flutter package in your flutter applications.

twilio_flutter | Flutter Package
Add this to your package’s pubspec.yaml file: dependencies: twilio_flutter: ^0.0.5 You can install packages from the…pub.dev

Table Of Contents::

Twilio

Setup

Implementation

Code Implement

Code File

Conclusion



Twilio:

Twilio is a cloud communications platform as a service (PaaS) that permits designers to automatically settle on and get telephone calls, send and get instant received messages, and perform other correspondence capacities utilizing its web administration service APIs.

Associate with clients wherever they need to cooperate with you and back within a single powerful platform.

Demo module::

This demo video shows how Twilio will work and send SMS from Twilio’s number to the receiver number on the user device.

Twilio Setup:

  1. First, you will create a Twilio account.

2. After login, you will go to the dashboard and activate your trial/Twilio number.

NOTE : You get a $15 USD balance in your trial account after signing up.

Implementation:

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:

twilio_flutter: ^latest version

Step 2: Import

import 'package:twilio_flutter/twilio_flutter.dart';

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

Step 4: Enable AndriodX

Add this to your gradle.properties file:

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

How to implement code in dart file :

You need to implement it in your code respectively:

Create a new dart file called my_home_screen.dart inside the lib folder.

On this page, we will create a floating action button and a text. When the user presses the button, then that automatically SMS will send the user a registered number with the text and show it in your devices.

We will create a instance of TwilioFlutter

TwilioFlutter twilioFlutter;

We will be to login/sign up an account in Twilio and change to Trial mode. We will be furnished with a Trial/Twilio number. Our Flutter application is connected with the Twilio account utilizing the accountSidauthToken, and the twiloNumber gave by Twilio.

Presently, we should set up the association in the initState() strategy for your widget or before starting the process.

@override
void initState() {
twilioFlutter = TwilioFlutter(
accountSid: 'AC5cec67816163f35176eb994e4aa48c39',
authToken: '*******************************',
twilioNumber: '+1**********');

super.initState();
}

In this sendSms() method, we will add sending detail like toNumber and messageBody. Users can add any number in send detail and write any message user will want to show on your device.

void sendSms() async {
twilioFlutter.sendSMS(
toNumber: ' *********',
messageBody: 'Hii everyone this is a demo of\nflutter twilio sms.');
}

When the user taps on the floating action button, then SMS will send the receiver number.

Code File:

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

class MyHomeScreen extends StatefulWidget {
MyHomeScreen({Key key, this.title}) : super(key: key);
final String title;

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

class _MyHomeScreenState extends State<MyHomeScreen> {
TwilioFlutter twilioFlutter;

@override
void initState() {
twilioFlutter = TwilioFlutter(
accountSid: '*************************',
authToken: '**************************',
twilioNumber: '+1***********');

super.initState();
}
void sendSms() async {
twilioFlutter.sendSMS(
toNumber: ' ************', messageBody: 'Hii everyone this is a demo of\nflutter twilio sms.');
}

void getSms() async {
var data = await twilioFlutter.getSmsList();
print(data);

await twilioFlutter.getSMS('***************************');
}

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
automaticallyImplyLeading: false,
title: Text(widget.title),
centerTitle: true,
),
body: Center(
child: Text(
'Press the button to send SMS.',
style: TextStyle(
color: Colors.black,
fontSize: 16
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: sendSms,
tooltip: 'Send Sms',
child: Icon(Icons.send),
),
);
}
}

Conclusion :

In the article, I have explained the basic architecture of Twilio; you can modify this code according to your choice, and this was a small introduction of Sms Using Twilio In Flutter from my side and its working using Flutter.

I hope this blog will provide you with sufficient information in Trying up Sms Using Twilio In Flutter in your flutter projects. This is a demo example of Sms Using Twilio in a flutter and how to send an SMS through the twilio_flutter package. So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter Twilio Sms Demo:

flutter-devs/flutter_twilio_sms_demo
A new Flutter application. This project is a starting point for a Flutter application. A few resources to get you…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 a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on FacebookGitHubTwitter, and LinkedIn for any flutter-related queries.

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


ber 4, 2023.

Related: Using SharedPreferences in Flutter

Frequently Asked Questions

How can I send an SMS using Twilio in a Flutter application?

Integrate the Twilio SDK into your Flutter project, obtain a Twilio account SID and Auth Token, and use the `twilio_sdk` package to compose and send messages.

What are the necessary dependencies for using Twilio in a Flutter app?

To use Twilio with Flutter, you need to include the `twilio_sdk` (version ^1.0.0) and `http` packages in your project’s dependencies.

How do I set up my Twilio account for sending SMS messages through a Flutter app?

First, obtain a Twilio account SID and Auth Token. Then, initialize the `Twilio` class with these credentials to configure the connection between your Flutter app and the Twilio REST API.

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

OCR In Flutter

Flutter is an open-source UI system for making high-level local interfaces on Android and iOS. The initial arrival of Flutter alpha by Google occurred in May 2017. Flutter applications can be written in the Dart programming language. Google reported the Flutter Beta variant in February at the Mobile World Congress 2018.

Dart imparts highlight to numerous different languages like Kotlin and Swift, and it tends to be effectively transpiled into JavaScript code. Flutter is open-source and allowed to utilize. It can work with your current code. Flutter takes into consideration a responsive and definitive style programming it takes after React Native. There is no compelling reason to utilize an extension in a Flutter to improve generally speaking overall performance and startup time. By using Dart, it will consequently accomplish Ahead-of-Time compilation (AOT).

In this article, we will explore OCR In Flutter. We will also implement a demo the OCR using the flutter_mobile_vision package in your flutter applications.

flutter_mobile_vision | Flutter Package
Add this to your package’s pubspec.yaml file: dependencies: flutter_mobile_vision: ^0.1.4+1 You can install packages…pub.dev

Table Of Contents::

OCR

Implementation

Code Implement

Code File

Conclusion



OCR :

OCR represents Optical Character Recognition. It is a cycle of transformation of composed pictures, printed text into the machine-encoded text, which implies it will give us a text from images that contain the text.

Let’s explore how FineReader OCR recognizes text. First, the program analyzes the structure of the document picture. It separates the page into components, for example, blocks of texts, tables, pictures, and so on. The lines are isolated into words and then — into characters. When the characters have been singled out, the program contrasts them and a lot of example pictures. It propels various speculations about what this character is. Base on these theories, the program examines various variations of breaking of lines into words and words into characters. In the wake of handling an enormous number of such probabilistic theories, the program at long last takes the choice, giving you the recognized text.

Demo Module ::

This video shows how OCR will work and recognizes text from the image and tap on this text on a rectangular box, and then they will be shown on your device.

Implementation :

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:

flutter_mobile_vision: ^letset version

Step 2: Import

import 'package:flutter_mobile_vision/flutter_mobile_vision.dart';

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

Step 4: For Andriod

Add features, permisssion, and activity in the main/Androidmanifest.xml file.

<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<activity android:name="io.github.edufolly.fluttermobilevision.ocr.OcrCaptureActivity" />

Step 5: Enable AndriodX

Add this to your gradle.properties file:

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

How to implement code in dart file :

You need to implement it in your code respectively:

Create a new dart file called ocr_page.dart inside the lib folder.

On this page, we will create a button for scanning and a hint text. When the user can scan the image and recognizes the text, then the user taps on this text on a rectangular box, and then they will replace the text and show it in your devices.

We will create a string _text and int _ocrCamera

int _ocrCamera = FlutterMobileVision.CAMERA_BACK;
String _text = "TEXT";

We will create a Raised button

Center(
child: RaisedButton(
onPressed: _read,
child: Text('Scanning',
style: TextStyle(fontSize: 16),
),
),
),

In this button, onPressed() method, we will call _read() function, and the text was called scanning.

Let’s declare the _read() function

Future<Null> _read() async {
List<OcrText> texts = [];
try {
texts = await FlutterMobileVision.read(
camera: _ocrCamera,
waitTap: true,
);

setState(() {
_text = texts[0].value;
});
} on Exception {
texts.add( OcrText('Failed to recognize text'));
}
}

You will compose this code on an open camera and take capture text. You will get the text just when you tap on a rectangular box that contains text inside, and afterward, the content will show your screen.

Code File :

import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobile_vision/flutter_mobile_vision.dart';

class OCRPage extends StatefulWidget {
@override
_OCRPageState createState() => _OCRPageState();
}

class _OCRPageState extends State<OCRPage> {

int _ocrCamera = FlutterMobileVision.CAMERA_BACK;
String _text = "TEXT";

@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
backgroundColor: Colors.white70,
appBar: AppBar(
automaticallyImplyLeading: false,
title: Text('OCR In Flutter'),
centerTitle: true,
),
body: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(_text,style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold),
),
Center(
child: RaisedButton(
onPressed: _read,
child: Text('Scanning',
style: TextStyle(fontSize: 16),
),
),
),
],
),
),
),
);
}

Future<Null> _read() async {
List<OcrText> texts = [];
try {
texts = await FlutterMobileVision.read(
camera: _ocrCamera,
waitTap: true,
);

setState(() {
_text = texts[0].value;
});
} on Exception {
texts.add( OcrText('Failed to recognize text'));
}
}
}

Conclusion :

In the article, I have explained the basic demo of OCR; you can modify this code according to your choice, and this was a small introduction of OCR from my side and its working using Flutter.

I hope this blog will provide you with sufficient information in Trying up OCR in Flutter in your flutter projects. This is a demo example of OCR in a flutter and how to recognizes text from images, and also, they will recognize text from different items like a page, table, structure, etc., So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter OCR Demo:

flutter-devs/flutter_ocr_demo
A new Flutter application. This project is a starting point for a Flutter application. A few resources to get you…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 a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on FacebookGitHubTwitter, and LinkedIn for any flutter-related queries.

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

Related: SMS Using Twilio In Flutter

Related: Using SharedPreferences in Flutter

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


Screen Orientation In Flutter

0

Mobile applications need to help a vast extent of device sizes, pixel densities, and orientations. Applications ought to have the alternative to scale well, handle orientation changes, and suffer data through all these. Flutter enables you to pick the best way to deal with handle these challenges instead of merely giving one particular explicit solution.

In this article, we will explore Screen Orientation In Flutter. We will also implement a demo program on how to handle screen orientation in your flutter applications.

Table Of Contents::

Screen Orientation

Orientation Builder

Portrait mode

Landscape Mode

Code File

Conclusion



Screen Orientation :

Any is an orientation that implies the screen can be bolted to any of the portrait and landscape. The default screen orientation is the arrangement of orientations to which the screen is locked when there is no current orientation lock.

There are two types of screen orientation are:

  • Portrait
  • Landscape

Demo Module::

This video showed a portrait mode and landscape mode of our screen.

Orientation Builder :

It Creates an orientation builder. The builder() argument must not be invalid.

The orientation class gives us the landscape modeportrait mode. We can utilize these perspectives to check the device orientation, and afterward, we can change the application screen to see as follows.

body: OrientationBuilder(
builder: (context, orientation){
if(orientation == Orientation.portrait){
return portraitMode();
}else{
return landscapeMode();
}
},
),

The OrientationBuilder has a builder function to build our format. The builder() work is considered when the orientation changes. The potential values being Orientation.portrait or Orientation.landscape.

In this example, we check if the screen is in a portrait view and construct a portrait mode if that is the case, else we construct a landscape mode for the screen.

_portraitMode() and _landscapeMode() are techniques I’ve written to make the particular formats.

We can likewise check the orientation anytime in the code (inside or outside the OrientationBuilder), utilizing.

MediaQuery.of(context).orientation

Note: For that time when we’re lazy and/or the only portrait will do, use

SystemChrome.setPreferredOrientations(DeviceOrientation.portraitUp);

Portrait Mode :

At the point when an application is showing in portrait orientation, there is substantially more tallness accessible. This makes it easy to vertically list the entirety of our widgets as there is sufficient space for the entirety of this.

In this portrait mode, we will use the return stack(). In this function, we will add a text and image of the flutter devs logo on a center.

Widget _portraitMode(){
return Stack(
fit: StackFit.expand,
children: <Widget>[
new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Portrait Mode",
style: TextStyle(fontSize: 20,
fontWeight: FontWeight.bold),
),
SizedBox(height: 30,),
new Image.asset(
'assets/devs.jpg',
height: 200,
width: 200,
),
],
),
],
);
}

The portrait layout was achieved by using a single column arrangement. You’ll also notice we gave the logo and text in a center.

Landscape Mode :

At the point when an application is showing in landscape orientation, there is substantially less tallness accessible. This makes it difficult to vertically list the entirety of our widgets as there is sufficiently not space for the entirety of this.

In this landscape mode, we will use the return stack(). In this function, we will add a text and image of the aeologic technology logo on a center.

Widget _landscapeMode(){
return Stack(
fit: StackFit.expand,
children: <Widget>[
new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Landscape Mode",
style: TextStyle(fontSize: 20,
fontWeight: FontWeight.bold),
),
SizedBox(height: 30,),
new Image.asset('assets/powered_by.png',
height: 50.0,
fit: BoxFit.cover,
)

],
),
],
);
}

The landscape layout was achieved by using a single column arrangement. We will add a logo of our company and a text in a center.

When you run the code, the output will come in a portrait way. You will be on auto-rotate mode on your devices for view landscape mode.

Code File

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

class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {


Widget _portraitMode(){
return Stack(
fit: StackFit.expand,
children: <Widget>[
new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Portrait Mode",
style: TextStyle(fontSize: 20,
fontWeight: FontWeight.bold),
),
SizedBox(height: 30,),
new Image.asset(
'assets/devs.jpg',
height: 200,
width: 200,
),
],
),
],
);
}


Widget _landscapeMode(){
return Stack(
fit: StackFit.expand,
children: <Widget>[
new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Landscape Mode",
style: TextStyle(fontSize: 20,
fontWeight: FontWeight.bold),
),
SizedBox(height: 30,),
new Image.asset('assets/powered_by.png',
height: 50.0,
fit: BoxFit.cover,
)

],
),
],
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Screen Orientation In Flutter"),
centerTitle: true,
),
body: OrientationBuilder(
builder: (context, orientation){
if(orientation == Orientation.portrait){
return _portraitMode();
}else{
return _landscapeMode();
}
},
),
);
}
}

Conclusion :

In the article, I have explained the basic demo of Screen Orientation. You can modify this code according to your choice, and this was a small basic introduction of Screen Orientation from my side and its working using Flutter.

I hope this blog will provide you with sufficient information in Trying up Screen Orientation in Flutter in your flutter projects. This is a demo example show two ways of screen Orientation. The first one is portrait mode, and the others were landscape mode, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter Screen Orientation Demo:

flutter-devs/flutter_screen_orientation_demo
A new Flutter application. This project is a starting point for a Flutter application. A few resources to get you…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 a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on FacebookGitHubTwitter, and LinkedIn for any flutter-related queries.

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

Related: SMS Using Twilio In Flutter

Related: Using SharedPreferences in Flutter

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


Sharing Files In Flutter

Flutter is an incredible new technology for cross-platform development beyond question. By and large, you will pull off standard highlights. Eventually, it would help if you had some platform-specific functionality. That is when Platform Channels prove to be useful.

In this article, we will explore Sharing Files In Flutter. We will also implement a demo the sharing files feature using the share package in your flutter applications.

Table Of Contents :

Flutter

Sharing Files

Implementation

Code Implement

Code File

Conclusion



Flutter :

Flutter is Google’s UI toolkit that helps you build beautiful and natively combined applications for mobileweb, and desktop in a single codebase in record time.

  • To begin with, you’ll need the necessary information on Flutter, Git, and GitHub. If you are new to flutter, you can get started by reading the official documentation on flutter.dev

Flutter — Beautiful native apps in record time
Flutter is Google’s UI toolkit for crafting beautiful, natively compiled applications for mobile, web, and desktop from…flutter.dev

Sharing Files :

We will be capturing the current screen and sharing that screenshot on a single tap, and other we will convert the image URL to an image file and share it with a single tap.

We’ll use a modified version of the share package for sharing files. And about the already available packages, we have few issues with these packages like we cannot share a File which we call from a network.

Demo module ::

On this screen, we will create two buttons in your app, which will call the above two logics and do our work.

Implementation :

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:

path_provider: ^1.6.11
http: ^0.12.0+4
google_fonts: ^1.1.0

Step 2: Add Assets :

Add assets to pubspec — yaml file.

We will add images in the assets folder

assets:
- assets/

Step 3: Import

import 'package:http/http.dart';
import 'package:path_provider/path_provider.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:share/share.dart';
import 'dart:async';
import 'dart:io';
import 'dart:typed_data';
import 'dart:ui' as ui;

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

Step 5: We will now create a static Global key.

static GlobalKey _globalKey = GlobalKey();

Step 6: Enable AndriodX

Add this to your gradle. properties file:

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

How to implement code in dart file :

You need to implement it in your code respectively:

Create a new dart file called home_page.dart inside the lib folder.

On this home page, we will create two buttons for sharing files. The first one is Share Screenshot and the others one is URL FIle Share.

Let’s declare the Share ScreenShot function:

Future<Null> shareScreenshot() async {
setState(() {
button1 = true;
});
try {
RenderRepaintBoundary boundary =
_globalKey.currentContext.findRenderObject();
if (boundary.debugNeedsPaint) {
Timer(Duration(seconds: 1), () => shareScreenshot());
return null;
}
ui.Image image = await boundary.toImage();
final directory = (await getExternalStorageDirectory()).path;
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData.buffer.asUint8List();
File imgFile = new File('$directory/screenshot.png');
imgFile.writeAsBytes(pngBytes);
final RenderBox box = context.findRenderObject();
Share.shareFile(File('$directory/screenshot.png'),
subject: 'Share ScreenShot',
text: 'Hello, check your share files!',
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size
);
} on PlatformException catch (e) {
print("Exception while taking screenshot:" + e.toString());
}
setState(() {
button1 = false;
});
}

We will catch the current screen, save it as an image file in the device, and afterward Share that file by giving its directory path. You have to wrap your Scaffold widget with RepaintBoundary as a parent and give a key to it since it makes a different presentation list for its child.

  • We have to get the storage location path to save the image, for that we are utilizing the path_provider bundle.
  • At that point, we are changing over the image into a byte exhibit and giving an arrangement of the image(in our case, we have .png). What’s more, later, we are converting over the above bytes into Uint8List, and afterward composing it in the imgFile.

If you are unable to take a screenshot you can add the below code in the method.

if (boundary.debugNeedsPaint) {
Timer(Duration(seconds: 1), () => shareScreenshot());
return null;
}

We are currently sharing the imgFile utilizing Share.shareFile by giving the area of storage. This component can be utilized to share reports, information, or charts as screen capture.

Let’s declare the URL FIle Share function:

Future<Null> urlFileShare() async {
setState(() {
button2 = true;
});
final RenderBox box = context.findRenderObject();
if (Platform.isAndroid) {
var url = 'https://i.ytimg.com/vi/fq4N0hgOWzU/maxresdefault.jpg';
var response = await get(url);
final documentDirectory = (await getExternalStorageDirectory()).path;
File imgFile = new File('$documentDirectory/flutter.png');
imgFile.writeAsBytesSync(response.bodyBytes);

Share.shareFile(File('$documentDirectory/flutter.png'),
subject: 'URL File Share',
text: 'Hello, check your share files!',
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
} else {
Share.share('Hello, check your share files!',
subject: 'URL File Share',
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
}
setState(() {
button2 = false;
});
}

In this method, we will get and convert the image from a URL to an image file, save it in the device, and then share it as we did it earlier. Also, in this method, the Http package is required.

  • In this method, we have an image URL, and we are utilizing the getting strategy to store it in a variable, and afterward continuing with similar steps as in the past.
  • We are composing response.bodyBytes as bytes.
  • We are offering the file to the Share.shareFile().

This element can be utilized to share images from an API call, such as sharing an individual item picture with a share button/symbol.

Code File:

https://gist.github.com/ShaiqAhmedkhan/4f727653cd08221749becbdd01403aa3#file-homepage-dart

Conclusion :

In the article, I have explained the basic demo of Sharing Files. You can modify this code according to your choice, and this was a small basic introduction of Sharing Files from my side and its working using Flutter.

I hope this blog will provide you with sufficient information in Trying up Sharing Files in Flutter in your flutter projects. This is a demo example show two ways to share your file. The first one is sharing the current screenshot, and others convert the image URL to an image file and then share, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter Sharing Files Demo:

flutter-devs/flutter_sharing_files_demo
A new Flutter application. This project is a starting point for a Flutter application. A few resources to get you…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 a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on FacebookGitHubTwitter, and LinkedIn for any flutter-related queries.

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

Related: SMS Using Twilio In Flutter

Related: Using SharedPreferences in Flutter

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


Keys In Flutter

0

Understand the job of a key in Flutter’s delivering mechanism through the genuine case, to use the reasonable Key at an appropriate time and spot. Stay Flutter You presumably realize how to refresh the interface see: by modifying.StateDe trigger WidgetThe operations to rebuild, trigger and update areFlutterFramework. Be that as it may, sometimes regardless of whether it’s modified.StateFlutterThe frame doesn’t seem to trigger either.WidgetReconstruction.

In this article, we will explore Keys In Flutter. We (when, where, which) will disclose how to use a reasonable key at a reasonable time and place in your flutter applications.

Table Of Contents:

When should I use it key

Where to set the key

Which type of key used

Conclusion



When should I use it Key

The key boundary can be found on basically every widget constructor, yet their use is less normal. Keys preserve state when widgets move around in your widget tree.https://www.youtube.com/embed/kn0EOS-ZiIc?feature=oembed

In the stateless version of the application, I have two stateless Tiles, each with a randomly generated color, in a Row and a StatefulWidget called Positionedkey to store the position of these tiles. At the point when I tap the FloatingActionButton down at the base, it appropriately swaps their position on the list.

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

class PositionedKey extends StatefulWidget {
@override
State<StatefulWidget> createState() => PositionedKeyState();
}

class PositionedKeyState extends State<PositionedKey> {
List<Widget> tiles;

@override
void initState() {
super.initState();
tiles = [
StatelessColorful(),
StatelessColorful(),
];
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: tiles))),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.sentiment_very_satisfied), onPressed: swapTiles));
}

Update when the button is clickedPositionedkeyStateStored intiles:

We will create a StatelessWidget class called name StatelessColorful()

class StatelessColorful extends StatelessWidget {
final Color color = UniqueColorGenaretor.getColor();

StatelessColorful({Key key}) : super(key: key);

@override
Widget build(BuildContext context) => buildColorful(color);
}

In any case, in the event that we make those Colorful stateful instead of stateless and store the color in the state, when I press the button, it would seem that nothing is going on.

We will useStatefulWidget(StatefulColorful) dochild(tiles):

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

@override
State<StatefulWidget> createState() => StatefulColorfulState();
}

class StatefulColorfulState extends State<StatefulColorful> {
Color color;

@override
void initState() {
super.initState();
color = UniqueColorGenaretor.getColor();
}

@override
Widget build(BuildContext context) => buildColorful(color);
}

Then, we will modify the external containerPositionedkeyintiles:

We will run the code, but, it doesn’t seem to work. Now, forStatefulColorfulPass aKeyParticipants:

void initState() {
super.initState();
tiles = [
StatefulColorfulTile(key: UniqueKey()),
StatefulColorfulTile(key: UniqueKey()),
];
}

At that point, run code again, they will successfully swap the colors. So since the component tree is refreshed accurately, the swapped color blocks will, in the long run, be displayed.

When executing swap now, the stateful widget control in the component number will analyze the sort as well as the type.keyEqual or not. Possibly type andkeyThe corresponding widget must be discovered when every one of the coordinates. Accordingly, after the widget tree is traded, the correspondence between the child control and the first control of the component tree is disrupted, so the Flutter will modify the component tree until the controls correspond effectively.

Where to set the Key

Ordinarily, it should be set in the high-level widget of the current widget tree.

StatefulColorfulIn the example, add one for each color blockPaddingAt the same timekeyOr in the same place:

In the wake of tapping the button, you can see that the color of the two-color blocks will change randomly; however, my desire is that the two fixed colors will exchange with one another.

Which type of key used

KeyThe purpose is to specify an interesting character for every widget and what to useKeyIt depends on the specific use scenario.

  • Value Key:- For instance, in aToDoList application, eachToDoThe text of a thing is constant and extraordinary. In this case, it is suitable for useValueKey, and value is text.
  • Object Key:- Suppose that each sub widget stores a more complex combination of data, such as an address book application for user information. Any single field, such as name or birthday, maybe the same as another entry, but each data combination is unique. Under these circumstances,ObjectKeyThe most suitable.
  • Unique Key:- If there are numerous widgets with the same incentive in the assortment, or on the off chance that you need to ensure that every widget is not the same as different widgets, you can use theUniqueKey. We used it in our example.UniqueKeyBecause we didn’t store some other constant information on our color block, and we didn’t have the foggiest idea what color was until we assembled the widget.

Not inKeyThe irregular number is used. On the off chance that you set it like that, another irregular number will be produced each time you manufacture a widget, and the component tree won’t be refreshed consistently with the widget tree.

  • GlobalKeys:- Global keys has two uses.
  1. They permit widgets to change their parents anyplace in the application without losing state, or they can be used to access data about another widget in a totally unique part of the widget tree.
  2. In the second case, you might need to check the password; however, you would prefer not to share the status data with different widgets in the tree, and you can use theGlobalKey<FromState>Hold a formFormOfState.

Truth be told, global keys resemble a global variable. There are other better ways to accomplish the job of global keys, such as an inherited widget, Redux, or block pattern.

Conclusion:

In the article, I have explained the basic structure of Keys In Flutter you can modify this code according to your choice, and this was a small basic introduction of Keys In Flutter from my side and its working using Flutter.

I hope this blog will provide you with sufficient information in Trying up Keys in Flutter in your flutter projectsAt the point when you need to keep the state of the widget tree, use theKey. For instance, while adjusting a widget collection of the same sort, such as in a list. Where willKeySet at the top of the widget tree to demonstrate exceptional identity. Which select various types ofKey. So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.


From Our Parent Company Aeologic

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

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

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

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

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


mber 4, 2023.

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.

Reorderable ListView In Flutter

0

Flutter is notable for its similarity among other mobile development stages that why it is one of the most promptly developing stages, and the primary purpose for it is the Flutter has thought of each feature and functionality which is required to build up a completely fledged application.

In this article, I will explore Reorderable ListView in Flutter and how to reorder a listview thing. By utilizing the ReorderableListView widget, you can rearrange the item inside a ListView in your flutter applications. You have to see that in the wake of moving and dropping the item.

Table Of Contents:

Reorderable ListView

Code Implementation

Code File

Conclusion



Reorderable ListView

The reorderable List is one whose items are draggable, and the user can rearrange/modify the object.

This class is fitting for sees with few numbers of the children’s fact that developing the List requires accomplishing work for each child that might be shown in the list view see rather than merely those children that are noticeable.

Code Implementation

Create a new dart file called reorderable_view_page.dart inside the lib folder.

First, we will create a list in which we have the data. So, we will create a list of string and let me give it a name called item and after giving the name item. I will create an array; basically, it is a list, not an array.

List<String> item = ["Clients","Designer","Developer","Director",
"Employee", "Manager", "Worker","Owner"];

Note that all children of the ReorderableListView widget must have a key since the key is expected to distinguish items after their position is changed in the List. This is the means by which your ReorderableListView widget resembles.

ReorderableListView(
children: <Widget>[
for(final items in widget.item)
Card(
color: Colors.blueGrey,
key: ValueKey(items),
elevation: 2,
child: ListTile(
title: Text(items),
leading: Icon(Icons.work,color: Colors.black,),
),
),
],
onReorder: reorderData,

),

In ReorderableListView, we will add a card, and in the card, we will add key and List Tile. In List Tile, we will add a title and leading icon. On Reorder parameter is compulsory. It will be called when the list child is moved to a new position.

Let we will create a rorder function and give it a name called reorderData.

void reorderData(int oldindex, int newindex){
setState(() {
if(newindex>oldindex){
newindex-=1;
}
final items =widget.item.removeAt(oldindex);
widget.item.insert(newindex, items);
});
}

This function will add two parameters, first old index and the second one is the new index. In this function, we will add final items is equal to item dot remove at the old index place. Then, when the item is excluded from that index placed, it should be inserted the point where you want to index that is it should be inserted at the new index place. So, item dot inserts (new index, items) and then run the code, and the output will be shown on your devices. We have to write the logic in the setState() method to reflect the changes.

Now we add an icon on the app bar for sorting purposes. It will rearrange your list is increasing to decreasing the alphabet.

actions: <Widget>[
IconButton(icon: Icon(Icons.sort_by_alpha),
tooltip:"Sort",
onPressed: sorting
),
],

Let we will create a sorting function.

void sorting(){
setState(() {
widget.item.sort();
});
}

In this function, we will add item dot short for rearranging the data.

We will tap on the AZ icon then all data will be rearranged due to the sort method. On this screen, you will see a list and icon on a card.

Code File

https://gist.github.com/ShaiqAhmedkhan/3ce7736b6f40a9de09c545449c5f6597#file-reorderable_view_page-dart

You will see a full code on a GitHub, and this is a small demo example of ReorderableListView in a flutter, and this below video shows how ReorderableListView will work and how to drag and drop the item.

Conclusion:

In the article, I have explained the basic demo of ReorderableListView you can modify this code according to your choice, and this was a small basic introduction of ReorderableListView from my side and its working using Flutter.

I hope this blog will provide you with sufficient information in Trying up Reorderable ListView in Flutter in your flutter projects. This is a demo example that will integrate ReorderableListView in a flutter and show dragging and dropping the items, and also used a sort method for rearranging the items in a list on the increase to decrease way, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter Reorderable ListView Demo:

flutter-devs/flutter_reorderable_listview_demo
A new Flutter application. This project is a starting point for a Flutter application. A few resources to get you…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 a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on FacebookGitHubTwitter, and LinkedIn for any flutter-related queries.

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


Custom Dialog In Flutter

0

I have been trying different things with Flutter for some time, and I staggered a lot of times, making custom widgets from designs for applications. Even though Flutter is staggeringly simple to make UI parts, you need to experience a lot of trial procedures to get what we need.

In this blog, We will be going to explore Custom Dialog In Flutter and show a demo of how to make a custom dialog in your flutter applications.

Contents:

Custom Dialog

Code Implementation

Code File

Conclusion



Custom Dialog

A dialog resembles a popup window to give a few alternatives to users(options like acknowledging/decay). Basic Alert Dialog won’t be helpful for each necessity. On the off chance that you need to execute further developed custom Dialog, you can utilize the Dialog widget for that. Rather than the AlertDialog, in here, we return the Dialog widget. The showDialog technique will continue as before.

Code Implementation :

Create a new dart file called dialog.dart inside the lib folder.

In this screen, we will create a button for opening a dialog and button named called it Custom Dialog.

Container(
child: Center(
child: RaisedButton(
onPressed: (){},
child: Text("Custom Dialog"),

),
),
),

Create a new dart file called constants.dart inside the lib folder.

It is just a class to store the few constants, as shown down here.

import 'package:flutter/material.dart';

class Constants{
Constants._();
static const double padding =20;
static const double avatarRadius =45;
}

Create a new dart file called custom_dialog_box.dart inside the lib folder.

In this screen, we will use CircularAvatar for the image at the top, Text for Title and Descriptions, and FlatButton for button.

Let’s declare the CustomDialogBox class.

return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(Constants.padding),
),
elevation: 0,
backgroundColor: Colors.transparent,
child: contentBox(context),
);

We are setting all the properties of dialog and title to contentBox(), which contains all our significant widgets.

Dialog, as a matter of course, accompanies its background color and elevation. Since we won’t use it, we are setting backgroundColor to Colors.transparent and elevation to 0.

contentBox(context){
return Stack(
children: <Widget>[
Container(),// bottom part
Positioned(),// top part
],
);
}

The Stack shows the keep last element on the top. We have circular toward the end to overlap on the card. How about we dive profound into every one of the children.

Container(
padding: EdgeInsets.only(left: Constants.padding,top: Constants.avatarRadius
+ Constants.padding, right: Constants.padding,bottom: Constants.padding
),
margin: EdgeInsets.only(top: Constants.avatarRadius),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Colors.white,
borderRadius: BorderRadius.circular(Constants.padding),
boxShadow: [
BoxShadow(color: Colors.black,offset: Offset(0,10),
blurRadius: 10
),
]
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(widget.title,style: TextStyle(fontSize: 22,fontWeight: FontWeight.w600),),
SizedBox(height: 15,),
Text(widget.descriptions,style: TextStyle(fontSize: 14),textAlign: TextAlign.center,),
SizedBox(height: 22,),
Align(
alignment: Alignment.bottomRight,
child: FlatButton(
onPressed: (){
Navigator.of(context).pop();
},
child: Text(widget.text,style: TextStyle(fontSize: 18),)),
),
],
),
),

We are utilizing a Container and BoxDecoration for making the card, and since the half of circular avatar ought to be on the card, we include padding and margin as needs are with the characteristic Constants.avatarRadiusand Constants.paddding. We will include the title, descriptions, and text of a button.

Positioned(
left: Constants.padding,
right: Constants.padding,
child: CircleAvatar(
backgroundColor: Colors.transparent,
radius: Constants.avatarRadius,
child: ClipRRect(),
),

We will use Positioned widget as a child in Stack to wrap the CircularAvatar. Also the left and right attributes are set to the same values to place in the center of the Stack. We will add background color, radius, and use ClippRRect() for the image.

ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(Constants.avatarRadius)),
child: Image.asset("assets/model.jpeg")
),

We will use ClippRRect()for the image circular border.

Now, then add CustomDialogBox in dialog.dart the lib folder.

import 'package:custom_dialog_flutter_demo/custom_dialog_box.dart';
import 'package:flutter/material.dart';

class Dialogs extends StatefulWidget {
@override
_DialogsState createState() => _DialogsState();
}

class _DialogsState extends State<Dialogs> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Custom Dialog In Flutter"),
centerTitle: true,
automaticallyImplyLeading: false,
),
body: Container(
child: Center(
child: RaisedButton(
onPressed: (){
showDialog(context: context,
builder: (BuildContext context){
return CustomDialogBox(
title: "Custom Dialog Demo",
descriptions: "Hii all this is a custom dialog in flutter and you will be use in your flutter applications",
text: "Yes",
);
}
);
},
child: Text("Custom Dialog"),

),
),
),
);
}
}

In the onPressed() the method you will call showDialog and return CustomDialogBox when the button then the custom dialog will pop up.

Code File

https://gist.github.com/ShaiqAhmedkhan/78bec9a4145881662c50848f08a12ffe#file-custom_dialog_box-dart

You will see a full code on a GitHub, and this is a small demo example of Custom Dialog in a flutter; and this below video shows how Custom Dialog will work and pop up show.

Conclusion:

In the article, I have explained the basic demo of Custom Dialog you can modify this code according to your choice, and this was a small introduction of Custom Dialog from my side and its working using Flutter.

I hope this blog will provide you with sufficient information in Trying up Custom Dialog in Flutter in your flutter projects. This is a demo example that will integrate Custom Dialog in a flutter and show pop up, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter Custom Dialog Demo:

flutter-devs/flutter_custom_dialog_demo
A new Flutter application. This project is a starting point for a Flutter application. A few resources to get you…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 a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on FacebookGitHubTwitter, and LinkedIn for any flutter-related queries.

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

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