Google search engine
Home Blog Page 28

Explore Flutter Gauge In Flutter Apps

Dart and Flutter are extraordinary for building high-performance UIs that render perfectly over a wide range of devices and structure factors. In the first place, you’ll need the essential information on Flutter, Git, and GitHub. If you don’t, as of now, have Flutter, get a copy of it for your OS from their install page.

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.

Install
Install Flutter and get started. Downloads available for Windows, macOS, Linux, and Chrome OS operating systems.flutter.dev

In this article, we will Explore Flutter Gauge In Flutter Apps. We will also implement a demo of the flutter gauge using the flutter_gauge package in your flutter applications.

flutter_gauge | Flutter Package
You should ensure that you add the following dependency in your Flutter project. dependencies: flutter_gauge: ^1.0.8…pub.dev

Table Of Contents::

Flutter Gauge

Implementation

Code Implement

Code File

Conclusion



Flutter Gauge

Flutter gauge is an information perception widget written in the dart to make a modern, interactive, and animated gauge check utilized to make excellent portable application UIs utilizing Flutter. There was an alternate style of gauge in a flutter.

Demo module ::

Implementation :

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:

flutter_gauge: ^latest version

Step 2: Import

import 'package:flutter_gauge/flutter_gauge.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 flutter_gauge_page.dart inside the lib folder.

In this flutter gauge, we will set the index at 40, handSize was 25, the number was endAndCenterAndStart starting with 0 and end with 100, secondsMarker was second and minute function. We will also set the circle color, but the default color was blue.

FlutterGauge(
handSize: 25,index: 40.0,
end: 100,number:
Number.endAndCenterAndStart,
circleColor: Color(0xFF47505F),
secondsMarker:
SecondsMarker.secondsAndMinute,
counterStyle: TextStyle(
color: Colors.black,fontSize: 20,
)
),

In this flutter gauge, we will set the index at 66, and the hand was short; the number is none; the second’s marker was also none. We will also set the circle color, but the default color was blue. We will false the decimal value and set counter alignment in the center.


In this flutter gauge, we will set the index at 70, handSize was 25, the number was endAndCenterAndStart starting with 0 and end with 100, secondsMarker was second and minute function, the hand was short. We will also set the circle color, but the default color was blue.

FlutterGauge(
handSize: 25,index: 70.0,end: 100,
number: Number.endAndCenterAndStart,
secondsMarker: SecondsMarker.secondsAndMinute,
hand: Hand.short,
circleColor: Color(0xFF59EA50),
counterStyle: TextStyle(color: Colors.black,
fontSize: 20,
)
),

In this flutter gauge, we will set the index at 100, handSize was 25, the number was endandStart starting with 0 and end with 500, secondsMarker was minute function, the hand was short. We will see the circle was false.


In this flutter gauge, we will set the index at 50, the width was 280, the number was all, secondsMarker was minute function, and the number was shown InAndOut outside. We will also set the circle color, but the default color was blue.

FlutterGauge(
index: 50,width:280,
counterStyle : TextStyle(color: Colors.black,
fontSize: 22,),
secondsMarker: SecondsMarker.secondsAndMinute,
number: Number.all,
numberInAndOut: NumberInAndOut.outside,
),

In this flutter gauge, we will set the index at 80, the width was 300, the number was all, secondsMarker was none, and the width Circle was 10. We will also set the circle color, but the default color was blue.

Code File

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


class FlutterGaugePage extends StatefulWidget {
@override
_FlutterGaugePageState createState() => _FlutterGaugePageState();
}

class _FlutterGaugePageState extends State<FlutterGaugePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: Text("Flutter Gauge Demo"),
automaticallyImplyLeading: false,
centerTitle: true,
),
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: Center(
child: FlutterGauge(
handSize: 25,index: 40.0,
end: 100,number:
Number.endAndCenterAndStart,
circleColor: Color(0xFF47505F),
secondsMarker:
SecondsMarker.secondsAndMinute,
counterStyle: TextStyle(
color: Colors.black,fontSize: 20,)
),
)
),
Expanded(
child: FlutterGauge(
secondsMarker: SecondsMarker.none,
hand: Hand.short, number: Number.none,
index: 66.0,circleColor: Color(0xFF9DC1DC),
counterStyle: TextStyle(color: Colors.black,
fontSize: 25
),
counterAlign: CounterAlign.center,
isDecimal: false
)),
],
),
Row(
children: <Widget>[
Expanded(
child: FlutterGauge(
handSize: 25,index: 70.0,end: 100,
number: Number.endAndCenterAndStart,
secondsMarker: SecondsMarker.secondsAndMinute
,hand: Hand.short,
circleColor: Color(0xFF59EA50),
counterStyle: TextStyle(color:
Colors.black,fontSize: 20,)
),
),
Expanded(
child: FlutterGauge(
handSize: 25,index: 100.0,end: 500,
number: Number.endAndStart,
secondsMarker: SecondsMarker.minutes,
isCircle: false,
counterStyle: TextStyle(color:
Colors.black,fontSize: 20,)
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: FlutterGauge(
index: 50,width:280,counterStyle : TextStyle
(color: Colors.black,fontSize: 22,),
secondsMarker: SecondsMarker.secondsAndMinute,
number: Number.all, numberInAndOut:
NumberInAndOut.outside,
),
),
],
),
FlutterGauge(
index: 80.0,width: 300,counterStyle
:TextStyle(color: Colors.black,fontSize: 22,),
circleColor: Color(0xFFFF4753),
widthCircle: 10,secondsMarker:
SecondsMarker.none,
number: Number.all
),
],
),
),
);
}
}

Conclusion :

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

I hope this blog will provide you with sufficient information in Trying up Flutter Gauge in your flutter projects. This demo program shows how to create a flutter gauge in a flutter and show how to flutter gauge 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 Gauge Demo:

flutter-devs/flutter_gauge_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.


Explore Hinge Animation In Flutter

0

Flutter makes it a lot simpler to deal with these animations. Likewise, there are numerous approaches to include animations in Flutter. You can go for packages which can be found in the dart pub, or you can utilize Animated Builder widgetwhere you can go for each detail of your animation.

For this post, I will utilize Animated Builder Widget. If you are uninformed of this, Animated Builder Widget allude to this archive here. You will presently require two additional widgets on the off chance that you need to implement animations utilizing this widget.

Animation Controller Widget — mainly characterizes the duration of the animation.

Animation Widget — mainly characterizes the type of animation and animation style

In straightforward terms, we utilize these two widgets to characterize and deal with our animations. Ensure you are trying these animations in a Stateful Widget. Additionally, remember to include SingleTickerProviderStateMixin in the class definition. This deals with our animation time.

In this article, we will Explore Hinge Animation In Flutter. We will also implement a demo of Hinge animation using the Animated Builder Widget in your flutter applications.

Table Of Contents::

Hinge Animation

Code Implement

Code File

Conclusion



Hinge Animation

An Element can turn over or cause to turn over with a sudden quick movement. We will Now, into more complex stuff. Here, I have combined multiple animations into one single animation. We call this an animation sequence. Take a good look at how to characterize this hinge animation.

Demo Module::

This video shows how to create a hinge animation in a flutter and show how to hinge animation will work in your flutter applications with sequence animation, and then they will be shown on your device.

How to implement code in dart file :

You need to implement it in your code respectively:

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

On this page, we will create a FloatingActionButton for playing animation and a text. When the user can tap the FloatingActionbutton, the text will contain an animation sequence, and then they will show hinge animation and show it in your devices.

The following code makes a tween for the _rotationAnimation property. It constructs a CurvedAnimation, determining a bounceInOut curve. See Curves for other accessible pre-characterized animation Curves.

_rotationAnimation = Tween(end: 0.15, begin: 0.0)
.animate(
CurvedAnimation(
parent: _controller,
curve: Interval(
0.0,
0.5,
curve: Curves.bounceInOut
),
),
);

Animation controller and Animation define an instance of the class AnimationController for the animation controller and three instances of the class Animation to handle animations (double to get a progressive value from 0 to 1).

AnimationController _controller;
Animation _rotationAnimation;
Animation<double> _slideAnimation;
Animation<double> _opacityAnimation;

Animation initializing override the initState method and define the parameters for the animation. For this situation, the duration is set to 2000 miliseconds.

@override
void initState() {
// TODO: implement initState
super.initState();
_controller = AnimationController(
vsync: this,
duration: Duration(milliseconds: 2000),
);

_rotationAnimation = Tween(end: 0.15, begin: 0.0)
.animate(
CurvedAnimation(
parent: _controller,
curve: Interval(
0.0,
0.5,
curve: Curves.bounceInOut
),
),
);

_slideAnimation = Tween(begin: 100.0, end: 600.0).animate(
CurvedAnimation(
parent: _controller,
curve: Interval(
0.5,
1.0,
curve: Curves.fastOutSlowIn)
,
),
);

_opacityAnimation = Tween(begin: 1.0, end: 0.0).animate(
CurvedAnimation(
parent: _controller,
curve: Interval(
0.5,
1.0,
curve: Curves.fastOutSlowIn),
),
);

}.

If it’s not too much trouble, note that when characterizing this animation, I have utilized three separateAnimation Widgets. I have utilized just a single Animation Controller for those three Widgets. I have passed various values for everyInterval Widget .That’s how you characterize a sequence of animations.

Now, let’s explore how to use this sequence animation.

AnimatedBuilder(
animation: _slideAnimation,
builder: (BuildContext context, Widget child) => Container(
width: 200,
height: 150,
padding: EdgeInsets.all(0),
margin: EdgeInsets.only(
left: 100,
top: _slideAnimation.value,
),
child: RotationTransition(
turns: _rotationAnimation,
child: Center(
child:
Text('Flutter Devs', style: TextStyle(
fontSize: 36,
fontWeight: FontWeight.bold,
color: Color.fromRGBO(
300,
150,
500,
_opacityAnimation.value)
),),
),
),
),
),

Now, we will add floating action button

In this button, we will add _controller.forward() on onPressed() method for animation foreward.

floatingActionButtonLocation:
FloatingActionButtonLocation.miniCenterFloat,

floatingActionButton:
FloatingActionButton(
child: Icon(Icons.play_arrow),
backgroundColor: Colors.green[300],
onPressed: (){
_controller.forward();
},
),

You will now run the code and show how Hinge Animation will work on your flutter applications.

Code File

import 'dart:math';

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



class HingeAnimation extends StatefulWidget {
@override
_HingeAnimationState createState() => _HingeAnimationState();

}

class _HingeAnimationState extends State<HingeAnimation> with SingleTickerProviderStateMixin{

AnimationController _controller;
Animation _rotationAnimation;
Animation<double> _slideAnimation;
Animation<double> _opacityAnimation;


@override
void initState() {
// TODO: implement initState
super.initState();
_controller = AnimationController(
vsync: this,
duration: Duration(milliseconds: 2000),
);

_rotationAnimation = Tween(end: 0.15, begin: 0.0)
.animate(
CurvedAnimation(
parent: _controller,
curve: Interval(
0.0,
0.5,
curve: Curves.bounceInOut
),
),
);

_slideAnimation = Tween(begin: 100.0, end: 600.0).animate(
CurvedAnimation(
parent: _controller,
curve: Interval(
0.5,
1.0,
curve: Curves.fastOutSlowIn)
,
),
);

_opacityAnimation = Tween(begin: 1.0, end: 0.0).animate(
CurvedAnimation(
parent: _controller,
curve: Interval(
0.5,
1.0,
curve: Curves.fastOutSlowIn),
),
);

}

@override
void dispose() {
// TODO: implement dispose
super.dispose();
_controller.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.green[300],
automaticallyImplyLeading: false,
title: Text("Flutter Hinge Animation Demo"),
centerTitle: true,
),

body: AnimatedBuilder(
animation: _slideAnimation,
builder: (BuildContext context, Widget child) => Container(
width: 200,
height: 150,
padding: EdgeInsets.all(0),
margin: EdgeInsets.only(
left: 100,
top: _slideAnimation.value,
),
child: RotationTransition(
turns: _rotationAnimation,
child: Center(
child:
Text('Flutter Devs', style: TextStyle(
fontSize: 36,
fontWeight: FontWeight.bold,
color: Color.fromRGBO(
300,
150,
500,
_opacityAnimation.value)
),),
),
),
),
),

floatingActionButtonLocation:
FloatingActionButtonLocation.miniCenterFloat,

floatingActionButton:
FloatingActionButton(
child: Icon(Icons.play_arrow),
backgroundColor: Colors.green[300],
onPressed: (){
_controller.forward();
},
),
);
}
}

Conclusion :

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

I hope this blog will provide you with sufficient information in Trying up Hinge Animation in your flutter projects. This is a demo program that shows how to create a hinge animation in a flutter and show how to hinge animation will work in your flutter applications with sequence animation, 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 Hinge Animation Demo:

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


Explore Lottie Animation In Flutter
Learn How To use Lottie Animation In You
Feel free to connect with us:
And read more articles from FlutterDevs.com.

From Our Parent Company Aeologic

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

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

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire 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.


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.


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.


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.


SMS Using Twilio In Flutter

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.

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.


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.


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.


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.