Google search engine
Home Blog Page 79

Explore AnimatedOpacity In Flutter

0

Eliminating a widget in Flutter is truly straightforward and simple. You simply need to revamp the tree without it. However, imagine a scenario where you need the widget to vanish yet at the same time occupy a space on the screen with the goal that it doesn’t disturb the remainder of the format. Well to settle this, you can attempt the AnimatedOpacity.

AnimatedOpacity class — widgets library — Dart API
API docs for the
AnimatedOpacity class from the widgets library, for the Dart programming language.api.flutter.dev

In this blog, we will Explore AnimatedOpacity In Flutter. We will see how to implement a demo program of the animated opacity with some properties and how to create it in your flutter applications.

Table Of Contents::

AnimatedOpacity

Properties

Code Implementation

Code File

Conclusion



AnimatedOpacity:

The AnimatedOpacity makes its child mostly transparent. This class colors its child into a middle buffer and afterward consolidates the child once again into the scene mostly transparent. For values of opacity other than 0.0 and 1.0, this class is moderately costly as it needs shading the child into a halfway support. For the value 0.0, the child is just not colored by any means. For the value 1.0, the child is colored without a moderate buffer.

Demo Module :

This demo video shows how to create animated opacity in a flutter. It shows how the animated opacity will work using the AnimatedOpacity class in your flutter applications. Basically, Opacity shows the disappear or presence of objects. In many situations, it can take a value from 1.0 to0.0 .1.0 methods full perceivability of the object and 0.0 means zero ability to see. Users can utilize any value in the middle of them for your ideal impact of opacity. It will be shown on your device.

Properties:

There ara some properties of AnimatedOpacity are:

  • key: This property is used to controls how one widget replaces another widget in the tree.
  • child: This property is the widget below this widget in the tree.
  • opacity: This property is used to the fraction to scale the child’s alpha value. An opacity of 1.0 is fully opaque. An opacity of 0.0 is fully transparent i.e., invisible. The opacity must not be null.
  • > curve: This property is a collection of common animation and used to adjust the rate of change of animation over time, allowing them to speed up and slow down, rather than moving at a constant rate.
  • > duration: This property represents a difference from one point in time to another. The duration may be “negative” if the difference is from a later time to an earlier.

Implementation:

Step 1: Add the assets

Add assets to pubspec — yaml file.

assets:
- assets/

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

How to implement code in dart file :

You need to implement it in your code respectively:

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

First, we will create two variables. The first one is _opacity is equal to zero and the second one is _width is 230.

var _opacity = 0.0;
var _width = 230.0;

In the body part, we will create a Container widget. Inside the container, we will add alignment was center, height from mediaquery, and add the variable of width. We will add decoration with a border-radius that is circular and add color. It’s a child, we will add a Row widget. In this widget, we will add an image and text.

Container(
alignment: Alignment.center,
height: MediaQuery.of(context).size.height *0.08,
width: _width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
color: Colors.cyan[400],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Image.asset("assets/devs.jpg",
scale: 10,
fit: BoxFit.contain,
),
Padding(
padding: const EdgeInsets.only(right:30.0),
child: Text(
'Flutter Devs',
style: TextStyle(color: Colors.white,
fontSize: 20.0)
,
),
),
],
),
),

Now let’s wrap the Row with an AnimatedOpacity widget and add the required properties to the widget.

In the AnimatedOpacity(), we will add duration for milliseconds. Users can choose seconds, microseconds, minutes, hours, and days for a long animation. We will add a curve that was bounceIn means an oscillating curve that first grows and then shrinks in magnitude. We will add variable _opacity on the opacity property.

AnimatedOpacity(
duration: Duration(milliseconds: 700),
curve: Curves.bounceIn,
opacity: _opacity,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Image.asset("assets/devs.jpg",
scale: 10,
fit: BoxFit.contain,
),
Padding(
padding: const EdgeInsets.only(right:30.0),
child: Text(
'Flutter Devs',
style: TextStyle(color: Colors.white,
fontSize: 20.0)
,
),
),
],
),
),

Now, we wrap the whole code to GestureDetector() method. In this method, we will add onTap. On onTap, we will add setState() function. In this function, if _opacity is already 0.0 then make it 1.0 otherwise, it should go reverse to 0.0 . Simple toggle operation.

GestureDetector(
onTap: () {
setState(() {
_opacity = _opacity == 0.0 ? 1 : 0.0;
});
},
),

When we run the application, we ought to get the screen’s output like the underneath screen capture.

Output

Code File:

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

class OpacityDemo extends StatefulWidget {
@override
OpacityDemoState createState() => OpacityDemoState();
}

class OpacityDemoState extends State<OpacityDemo> {

var _opacity = 0.0;
var _width = 230.0;


@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xffffffff),
appBar: AppBar(
backgroundColor: Colors.cyan[300],
title: Text("Flutter AnimatedOpacity Demo"),
automaticallyImplyLeading: false,
),
body: Center(
child: GestureDetector(
onTap: () {
setState(() {
_opacity = _opacity == 0.0 ? 1 : 0.0;
});
},
child: Container(
alignment: Alignment.center,
height: MediaQuery.of(context).size.height *0.08,
width: _width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
color: Colors.cyan[400],
),
child: AnimatedOpacity(
duration: Duration(milliseconds: 700),
curve: Curves.bounceIn,
opacity: _opacity,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Image.asset("assets/devs.jpg",
scale: 10,
fit: BoxFit.contain,
),
Padding(
padding: const EdgeInsets.only(right:30.0),
child: Text(
'Flutter Devs',
style: TextStyle(color: Colors.white,
fontSize: 20.0)
,
),
),
],
),
),
),
),
),
);
}
}

Conclusion:

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

I hope this blog will provide you with sufficient information in Trying up the AnimatedOpacity in your flutter projectsWe will show you what the AnimatedOpacity is?. Some AnimatedOpacity properties make a demo program for working AnimatedOpacity and show that when the user taps the container then, the text will be shown with the animated effect. It can take a value from 1.0 to0.0 .1.0 methods full perceivability of the object and 0.0 means zero ability to see. Users can utilize any value in the middle of them for your ideal impact of opacity using the AnimatedOpacity class 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 Animated Opacity Demo:

flutter-devs/flutter_animated_opacity_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: Explore AnimatedSize In Flutter

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


Custom Rolling Switch In Flutter

switch is a two-state UI component used to flip between ON (Checked) or OFF (Unchecked) states. Ordinarily, it is a button with a thumb slider where the user can haul back and forth to pick an alternative as ON or OFF. Its working is like the house power switches.

In this article, we will explore the Custom Rolling Switch In Flutter. We will implement a custom rolling switch demo program with attractive animation and some properties using the lite_rolling_switch package in your flutter applications.

lite_rolling_switch | Flutter Package
Full customizable rolling switch widget for flutter apps based on Pedro Massango’s ‘crazy switch widget…pub. dev

Table Of Contents::

Introduction

Properties

Implementation

Code Implement

Code File

Conclusion



Introduction:

In Flutter, a switch is a widget used to choose between two alternatives, either ON or OFF. It doesn’t keep up the actual state. To keep up the states, it will call the onChanged property. Assuming the worth return by this property is true, the switch is ON and false when it is OFF. At the point when this property is invalid, the switch widget is debilitated.

Custom Rolling Switch button with alluring animation made to permit you to modify colors, symbols, and other restorative substances. Deal with the widget states similarly you do with the traditional material’s switch widget.

Demo Module :

This demo video shows how to create a custom rolling switch in a flutter. It shows how the custom rolling switch will work using the lite_rolling_switch package in your flutter applications. It shows toggle interaction where the user presses the button then, the switch will be rolling to another side with animation effect and the icons and text will be changed when the switch is rolling. It will be shown on your device.

Properties:

There are some properties of LiteRollingSwitch are:

  • > onChanged: This property is called when the user toggles the switch on or off.
  • > value: This property is used to determines whether this switch is on or off.
  • > animationDuration: This property is used how long an animation should take to complete one cycle.
  • > colorOn: This property is used to show color when the switch is On.
  • > colorOff: This property is used to show color when the switch is Off.

Implementation:

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:
flutter:
sdk: flutter
lite_rolling_switch:

Step 2: Import

import 'package:lite_rolling_switch/lite_rolling_switch.dart';

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

How to implement code in dart file :

You need to implement it in your code respectively:

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

In the body part, we will add the Center() widget. Inside the widget, we will add a Column widget. In this widget, we will add the mainAxisAlignment was center. Inside, we will add text with style. We will add padding and on its child add LiteRollingSwitch() widget for custom.

Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Do you like Flutter?",style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold
),
),

Padding(
padding: EdgeInsets.only(top: 20),
child: LiteRollingSwitch(
value: true,
textOn: 'Yes',
textOff: 'No',
colorOn: Colors.cyan,
colorOff: Colors.red[400],
iconOn: Icons.check,
iconOff: Icons.power_settings_new,
animationDuration: Duration(milliseconds: 800),
onChanged: (bool state) {
print('turned ${(state) ? 'yes' : 'no'}');
},
),
)
],
),
),

Inside, we will add value was true means which determines whether this switch is on or offWe will add textOn was the string ‘Yes’ means when the switch is On then the text will be shown on the button and when textOff was the string ‘No’ means when the switch is Off then the text will be shown on the button. We will add colorOn means when the switch is On then the color will be shown on the button and when colorOff means when the switch is Off then the color will be shown on the button. We will add animationDuration means to delay the start of the animation and add onChanged means when the user toggles the switch on or off. When we run the application, we ought to get the screen’s output like the underneath screen capture.

Final Output

Code File:

import 'dart:ui';

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

class DemoScreen extends StatefulWidget {


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

class _DemoScreenState extends State<DemoScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.teal[50],
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.black,
title: Text('Flutter Custom Rolling Switch'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Do you like Flutter?",style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold
),
),

Padding(
padding: EdgeInsets.only(top: 20),
child: LiteRollingSwitch(
value: true,
textOn: 'Yes',
textOff: 'No',
colorOn: Colors.cyan,
colorOff: Colors.red[400],
iconOn: Icons.check,
iconOff: Icons.power_settings_new,
animationDuration: Duration(milliseconds: 800),
onChanged: (bool state) {
print('turned ${(state) ? 'yes' : 'no'}');
},
),
)
],
),
),
);
}
}

Conclusion:

In the article, I have explained the Custom Rolling Switch of the basic structure in a flutter; you can modify this code according to your choice. This was a small introduction to Custom Rolling Switch On User Interaction from my side, and it’s working using Flutter.

I hope this blog will provide you with sufficient information in Trying up the Custom Rolling Switch in your flutter projectsWe will show you what the introduction is?. Show some properties, make a demo program for working Custom Rolling Switch and show toggle interaction where the user presses the button then, the switch will be rolling to another side with animation effect and the icons and text will be changed when the switch is rolling using the lite_rolling_switch package 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 Custom Rolling Switch Demo:

flutter-devs/flutter_custom_rolling_switch_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: Custom Dialog In Flutter

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


SelectableText Widget In Flutter

0

At times you might need to make the Text content of your mobile selectable to utilize functionalities like a copy. On the off chance that you need to show text in Flutter, the normal route is by utilizing a Text widget. Be that as it may, it doesn’t permit the user to choose the text. If you need the user to have the option to select the text, you can utilize Flutter’s SelectableText widget.

In this blog, we will explore the SelectableText Widget In Flutter. We will see how to implement a demo program of the selectable text widget and show you how to utilize that widget to copy/select the text, making a text selectable is really simple in Flutter, you simply need to utilize the SelectableText widget in your flutter applications.

SelectableText class – material library – Dart API
A run of selectable text with a single style. The SelectableText widget displays a string of text with a single style…master-api. flutter.dev

Table Of Contents::

SelectableText Widget

Properties

Code Implement

Code File

Conclusion



SelectableText Widget:

The SelectableText widget shows a string of text with a solitary style. The string may break across various lines or may all be shown on a similar line contingent upon the design imperatives. To utilize SelectableText, there is just one required boundary which is the text to be shown was String.

SelectableText Widget in Flutter allows the user to Select/Copy the content on the UI. The typical Text Widget in Flutter won’t permit a copy/select element by double-tapping on the content, we can either select/copy the content. To take care of this issue, the Flutter discharge came out with the SelectableText Widget.

For more info on SelectableText Widget ,Watch this video By Flutter :

Below demo video shows how to create a selectable text in a flutter. It shows how the selectable text widget will work using the SelectableText Widget in your flutter applications. It shows two buttons on the center screen. When the user taps on these buttons, it will show allow the user to copy/select a feature by double-tapping on the text, we can either select/copy the text. It will be shown on your device.

Demo Module :


Properties:

There are some properties of the SelectableText widget are:

  • > data: This property is a significant property where the data to appear as a feature of the SelectableText must appear. The text to be shown.
  • > onTap: This property is utilized for the callback function that gets terminated at whatever point somebody taps on the Text of the SelectableText. Of course, the tapping opens the select all/copy choice. On the off chance that you need to perform different exercises, make a point to supersede them here.
  • > textSpan: This property is utilized as a component of the SelectableText.rich() widget. This allows you to pick the TextSpan which can hold various texts on the SelectableText widget.
  • > autofocus: This property is used whether it should focus itself if nothing else is already focused. Defaults to false.
  • > maxLines: This property is used for the maximum number of lines for the text to span, wrapping if necessary.
  • > toolbarOptions: This property is used to create a toolbar configuration with given options. All options default to false if they are not explicitly set.
  • > enableInteractiveSelection: This property is used to Whether to select text and show the copy/paste/cut menu when long-pressed. Defaults to 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_screen.dart inside the lib folder.

We will make two buttons on this home page screen, and each button will show SelectableText Widget, and we will show the deeply below detail. When we run the application, we ought to get the screen’s output like the underneath screen capture.

Home Screen

We will deeply define below are the two different uses of the SelectableText class and the resulting output.

SelectableText Basic:

In the body part, we will add the center widget. In this widget, we will add SelectableText() method. Inside this method, we will add text, toolbarOptions. In these options, when selection is active, it shows ‘Copy’ and ‘Select all’ options. You can utilize the toolbarOptions property to pass an instance of ToolbarOptions. The constructor of ToolbarOptions has all values are copied, cut, paste, and selectAll set to false by default. You need to set every option to true on the off chance that you need it to show up on the toolbar. Be that as it may, cut and paste will not be showed regardless of whether you set it to true.

Center(
child: SelectableText(
"Flutter Tutorial by Flutter Dev's.com",
style: TextStyle(color: Colors.blue,
fontWeight: FontWeight.bold,
fontSize: 45
),
textAlign: TextAlign.center,
onTap: () => print('Tapped'),
toolbarOptions: ToolbarOptions(copy: true, selectAll: true,),
showCursor: true,
cursorWidth: 2,
cursorColor: Colors.red,
cursorRadius: Radius.circular(5),

),
),

We will add the showCursor option true, cursor width, color, and radius. When we run the application, we ought to get the screen’s output like the underneath screen capture.

SelectableText Basic

SelectableText RichText:

In the body part, we will add the center widget. In this widget, we will add SelectableText.rich() method. In this method, that you need the content to have various formats, utilizing RichText is the normal methodology in Flutter. It’s likewise conceivable to have a selectable RichText by utilizing SelectableText.rich named constructor. It acknowledges an TextSpan as the first and the solitary required boundary rather than a String. Different boundaries, which are optional, are the same equivalent to the main constructor.

Center(
child: SelectableText.rich(
TextSpan(
children: <TextSpan>[
TextSpan(text: 'Flutter', style: TextStyle(color: Colors.blue)),
TextSpan(text: 'Devs', style: TextStyle(color: Colors.black)),
TextSpan(text: '.com', style: TextStyle(color: Colors.red)),
],
),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 48),
textAlign: TextAlign.center,
onTap: () => print('Tapped'),
toolbarOptions: ToolbarOptions(copy: true, selectAll: false),
showCursor: true,
cursorWidth: 2,
cursorColor: Colors.black,
cursorRadius: Radius.circular(5),
),
)

We will add toolbarOptons, which shows ‘Copy’ was true and ‘Select all’ was false options. When we run the application, we ought to get the screen’s output like the underneath screen capture.

SelectableText RichText

Code File:

import 'package:flutter/material.dart';
import 'package:flutter_selectabletext_widget/selectable_text_rich_screen.dart';
import 'package:flutter_selectabletext_widget/selectable_text_screen.dart';



class HomePageScreen extends StatefulWidget {
@override
_HomePageScreenState createState() => _HomePageScreenState();
}

class _HomePageScreenState extends State<HomePageScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blueGrey[100],
appBar: AppBar(
title: Text("Flutter SelectableText Widget Demo"),
automaticallyImplyLeading: false,
centerTitle: true,
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[

RaisedButton(
child: Text('Selectable Text',style: TextStyle(color: Colors.black),),
color: Colors.green[100],
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => SelectableTextScreen()));
},
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
padding: EdgeInsets.all(13),
),
SizedBox(height: 8,),
RaisedButton(
child: Text('Selectable Text Rich',style: TextStyle(color: Colors.black),),
color: Colors.green[100],
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => SelectableTextRichScreen()));
},
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
padding: EdgeInsets.all(13),

),
SizedBox(height: 8,),

],
),
)
), //center
);
}
}

Conclusion:

In the article, I have explained the basic structure of the SelectableText Widget in a flutter; you can modify this code according to your choice. This was a small introduction to SelectableText Widget On User Interaction from my side, and it’s working using Flutter.

I hope this blog will provide you with sufficient information in Trying up the SelectableText Widget in your flutter projects. We will show you what the SelectableText Widget is?, some properties using in SelectableText Widget, and make a demo program for working SelectableText Widget and show you how to use that widget to copy/select the text, making a text selectable is pretty easy in Flutter using the SelectableText Widget widget 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 SelectableText Widget Demo:

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


Explore FadeTransition Widget In Flutter

0

Flutter accompanies an amazing arrangement of animation widgets to add movement and embellishments to your flutter application. Be that as it may, imagine a scenario in which you need something truly basic. Perhaps something as straightforward as fading a widget. The Flutter SDK offers the FadeTransition widget for you. Flutter has an amazing animation engine for adding movement and impacts to your Flutter application. However, once in a while, you simply need to accomplish something simple — like fading in a widget. Flutter has a lot of transitions prepared to drop into your Flutter application.

In this blog, we will Explore FadeTransition Widget In Flutter. We will see how to implement a demo program of the fade transition widget and how to use FadeTransition widget in your flutter applications which can be used to animate the opacity of a widget.

FadeTransition class – widgets library – Dart API
API docs for the FadeTransition class from the widgets library, for the Dart programming language.api.flutter.dev

Table Of Contents::

FadeTransition Widget

Properties

Implementation

Code Implement

Code File

Conclusion



FadeTransition Widget:

FadeTransition allows you to blur a widget in and out by animating its opacity. In this way, you simply need to give the opacity boundary with animation and a child widget on which the animation must be performed. Yet, where does the animation come from? You initially need to make an AminationController set the duration and afterward make the animation giving the beginning and end opacity values.

For more info on FadeTransition Widget,Watch this video By Flutter :

Below demo video shows how to create a fading animation in a flutter. It shows how the fading animation will work using the FadeTransition widget in your flutter applications. It shows or hides a widget. The reverse fade transition animation was true. It depends on the duration of when the widget will show or hide. It will be shown on your device.

Demo Module :


Properties:

There are some properties of FadeTransitionwidget is:

  • >Key key: The widget’s key, used to control if it should be replaced.
  • >Animation<double> opacity : The animation that controls the fade transition of the child.
  • >bool alwaysIncludeSemantics : Whether the semantic information of the children is always included. Defaults to false.
  • >Widget child: The widget under this widget in the tree where the animation will be applied.

Implementation:

Step 1: Add the assets

Add assets to pubspec — yaml file.

assets:
- assets/

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

How to implement code in dart file :

You need to implement it in your code respectively:

Create a new dart file calledfade_transition_demo.dart inside the lib folder.

In the first place, you need to make your class extends State with TickerProviderStateMixin. That empowers you to pass this as the vsync the contention in the constructor of AnimationController.We will pass is an Animation<double> that characterizes the animation to be applied to the child widget. Making an Animation expects you to make an AnimationController.

AnimationController _controller;
Animation<double> _animation;

We will add initState() method. In this method, we will add a _controller is equal to the AnimationController(). Inside, we will add the duration of three seconds means is only used when going forward. Otherwise, it specifies the duration going in both directions. We will animation repeat in a bracket reverse is true. We will create the Animation instance, then add _animaton is equal to the CurvedAnimation(). Inside, we will add a parent for the animation controller. The parent arguments must not be null. We will add curve means to use in the forward direction. We will add CurvedAnimation with easeIn curve.

initState() {
super.initState();

_controller = AnimationController(
duration: const Duration(seconds: 3),
vsync: this,

)..repeat(reverse:true);
_animation = CurvedAnimation(
parent: _controller,
curve: Curves.easeIn
);
}

We will create a void dispose() method. In this method, we will be adding a code for disposing of the controller inside.

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

We will create a FadeTransition() method. In this method, we will add opacity means animation that controls the opacity of the child. We will add a column widget. In this widget, we will add text and images.

FadeTransition(
opacity: _animation,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Flutter Dev's",style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold),
),
Image.asset("assets/devs.jpg"),
],
),
),

When we run the application, we ought to get the screen’s output like the underneath screen capture.

Final Output

Code File:

import 'package:flutter/material.dart';

class FadeTransitionDemo extends StatefulWidget {
_FadeTransitionDemoState createState() => _FadeTransitionDemoState();
}

class _FadeTransitionDemoState extends State<FadeTransitionDemo>
with TickerProviderStateMixin {

AnimationController _controller;
Animation<double> _animation;

initState() {
super.initState();

_controller = AnimationController(
duration: const Duration(seconds: 3),
vsync: this,

)..repeat(reverse:true);
_animation = CurvedAnimation(
parent: _controller,
curve: Curves.easeIn
);
}

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

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xffffffff),
appBar: AppBar(
automaticallyImplyLeading: false,
title: Text( 'Flutter FadeTransition Widget Demo',),
),
body: Center(
child: FadeTransition(
opacity: _animation,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Flutter Dev's",style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold),
),
Image.asset("assets/devs.jpg"),
],
),
),
),
);
}
}

Conclusion:

In the article, I have explained the FadeTransition Widget basic structure in a flutter; you can modify this code according to your choice. This was a small introduction to FadeTransition Widget On User Interaction from my side, and it’s working using Flutter.

I hope this blog will provide you with sufficient information in Trying up the FadeTransition Widget in your flutter projectsWe will show you what the FadeTransition Widget is?. Some faadetransition widget properties, make a demo program for working FadeTransition Widget, and can create a fading animation to show or hide a widget. The reverse fade transition animation was true. It depends on the duration of when the widget will show or hide using the FadeTransition widget 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 Fade Transition Widget Demo:

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

Related: Explore Animated Loader In Flutter

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


Send Emails in Flutter

0

This blog will explore the Send Emails in Flutter. We will learn how to execute a demo program. We will show how to send emails using the flutter_email_sender package in your Flutter applications.

For Send Emails:

flutter_email_sender | Flutter package
Allows to send emails from Flutter using native platform functionality.pub.dev

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


Table Of Contents::

Introduction

Implementation

Code Implement

Code File

Conclusion



Introduction:

In Flutter you can easily permit the user to send emails from your application. The methodology that will be discussed here, makes use of the accessible email clients from the user’s devices.

Thus, you don’t have to set up a Simple Mail Transfer Convention (SMTP) client. It allows sending emails from Flutter using a native platform. In Android, it opens the default mail application using intent. In iOS MFMailComposeViewController is used to compose an email.

The below demo video shows how to implement Send Emails in Flutter and how to send email will work using the flutter_email_sender package in your Flutter applications. It will be shown on your device.

Demo Module::


Implementation:

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:
flutter:
sdk: flutter
flutter_email_sender: ^6.0.3

Step 2: Import

import 'package:flutter_email_sender/flutter_email_sender.dart';

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

Step 4: We must also add the following intent to allow our application to send emails on Android. This can be done inside the android\app\src\main\AndroidManifest.xml file.

<queries>
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="mailto" />
</intent>
</queries>

How to implement code in dart file :

You need to implement it in your code respectively:

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

In main. dart file, we will create a HomePage class. In this class, we will add a floatingActionButton widget. In this widget, we will add backgroundColor was blueAccent, add an email icon with white color on its child method, and add the onPressed function. 

      floatingActionButton: FloatingActionButton(
backgroundColor: Colors.blueAccent,
child: const Icon(
Icons.mail_outline,
color: Colors.white,
),
onPressed: () async => FlutterEmailSender.send(
Email(
body: 'I would like to request more information.',
recipients: ['user@gmail.com'],
subject: 'Information request',
bcc: ['test@gmail.com'],
cc: ['support@gmail.com'],
),
).then(
(_) => ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
backgroundColor: Colors.blueAccent,
content: Text(
'The email has either been sent or you navigated back using the back button.',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 16),
),
),
),
),
),

In this function, we will add the FlutterEmailSender.send() method. In this method, we will add an Email function. Inside this function, we will add body, recipients, subject, bcc, and cc. Also, we will add SnackBar() for using navigated back or sent email.

When we run the application, we ought to get the screen’s output like the underneath screen capture.

Code File:

import 'package:flutter/material.dart';
import 'package:flutter_email_sende/splash_screen.dart';
import 'package:flutter_email_sender/flutter_email_sender.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: Splash(),
);
}
}

class HomePage extends StatelessWidget {
const HomePage({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Flutter Send Emails Demo'),
backgroundColor: Colors.cyan,
automaticallyImplyLeading: false,
centerTitle: true,
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(child: Image.asset("assets/logo.png",height: 100,))
],
),
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.blueAccent,
child: const Icon(
Icons.mail_outline,
color: Colors.white,
),
onPressed: () async => FlutterEmailSender.send(
Email(
body: 'I would like to request more information.',
recipients: ['user@gmail.com'],
subject: 'Information request',
bcc: ['test@gmail.com'],
cc: ['support@gmail.com'],
),
).then(
(_) => ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
backgroundColor: Colors.blueAccent,
content: Text(
'The email has either been sent or you navigated back using the back button.',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 16),
),
),
),
),
),
);
}
}

Conclusion:

In the article, I have explained the Send Emails in a flutter; you can modify this code according to your choice. This was a small introduction to Send Emails On User Interaction from my side, and it’s working using Flutter.

I hope this blog will provide you with sufficient information on Trying the Send Emails in your Flutter projects. We will show you what the Introduction is. Make a demo program for working on Send Emails Using the flutter_email_sender package 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.


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

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

Related: 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.


Abstract Factory Method Design Patterns For Dart & Flutter

0

Abstract Factory design pattern is one of the Creational designs. Abstract Factory design is practically like Factory Pattern and is considered as one more layer of reflection over factory design. Abstract Factory designs work around a super-factory facility that makes different factories.
Abstract factory design execution furnishes us with a system that permits us to make protests that follow a general pattern. So at runtime, the abstract factory is combined with any ideal substantial factory which can make objects of the selected type.

This article will explore the Abstract Factory Method Design Patterns For Flutter. We will perceive how to execute a demo program and we are going to learn about how we can use it in your flutter applications.

Table Of Contents ::

What Is Abstract Factory Method?

Advantages of Abstract Factory Pattern

Implementation

Conclusion



What Is Abstract Factory Method?

Characterize an interface or abstract class for making groups of related (or subordinate) objects yet without indicating their substantial sub-classes

That implies Abstract Factory lets a class returns a factory of classes. Thus, this is the explanation that Abstract Factory Pattern is one level higher than the Factory Pattern. This factory class returns various subclasses given the info given and the factory class utilizes an if-else or change proclamation to accomplish this.

From the get-go, it appears to be confounding yet when you see the execution, it’s truly simple to get a handle on and comprehend the minor distinction between Factory and Abstract Factory patterns.

An Abstract Factory Pattern is also known as Kit.

How about we see the GOFs portrayal of the Abstract Factory Pattern :

  • > AbstractFactory:- Proclaims an interface of interaction for tasks that make abstract product objects.
  • > ConcreteFactory:- Executes the operations pronounced in the Abstract Factory to make substantial product objects.
  • > Product:- Characterizes a product object to be made by comparing substantial factories and executes the AbstractProduct interface.
  • > Client:- Utilizes connection points proclaimed by AbstractFactory and AbstractProduct classes.

Abstract Factory gives connection points to making groups of related or subordinate objects without indicating their substantial classes.

Client programming makes a substantial execution of the abstract factory and afterward utilizes the nonexclusive connection points to make substantial items that are essential for the group of objects.

Advantages of Abstract Factory Pattern:

  • > Isolation of concrete classes: The Abstract Factory pattern assists you with controlling the classes of objects that an application makes. Since a factory exemplifies the obligation and the most common way of making product objects, it disconnects clients from execution classes.
  • > Exchanging Product Families quickly: The class of a substantial factory shows up just a single time in an application, that is where it’s launched. This makes it simple to change the substantial factory an application utilizes. It can utilize different product setups just by changing the substantial factory.
  • > Promoting consistency among products: When product objects in a family are intended to cooperate, an application genuinely should utilize objects from just a single family at a time.

Implementation:

Lets create an abstract class Color.

abstract class Color
{
void paint();
}

Presently make substantial classes executing a similar class Shape.

class RedColor implements Color {
@override
void paint() {
print("RedColor");
}
}class BlueColor implements Color {
@override
void paint() {
print("BlueColor");
}
}class Yellow implements Color {
@override
void paint() {
print("Yellow");
}
}class Black implements Color {
@override
void paint() {
print("Black");
}
}

Now create an Abstract class to get factories for Color Objects.

abstract class AbstractFactory
{
Color getColor(String colorType);
}

Presently make Factory classes extending out AbstractFactory to create an object of the substantial class based of given data.

class ColorFactory extends AbstractFactory
{
@Override
Color getColor(String colorType)
{
if (colorType == "YELLOW") {
return new Yellow();
} else if (colorType == "BLACK") {
return new Black();
}
return null;
}
}
class RedColorFactory extends AbstractFactory
{
@Override
Color getColor(String colorType)
{
if (colorType == "YELLOW") {
return new RedYellow();
} else if (colorType == "BLACK") {
return new RedBlack();
}
return null;
}
}

Presently make a Factory generator/maker class to get factories plants by passing data like Color.

class FactoryProducer
{
static AbstractFactory getFactory(bool red)
{
if (red) {
return new RedColorFactory();
} else {
return new ColorFactory();
}
}
}

Utilize the FactoryProducer to set AbstractFactory up to get factories of substantial classes by passing data like sort.

class AbstractFactoryPatternDemo
{
static void main()
{

AbstractFactory colorFactory = FactoryProducer.getFactory(false);

Color color1 = colorFactory.getColor("YELLOW");
color1.paint(); //Prints "Yellow"
Color color2 = colorFactory.getColor("BLACK");
color2.paint(); //Prints "Black"
AbstractFactory colorFactory1 = FactoryProducer.getFactory(true);
Color color3 = colorFactory1.getColor("YELLOW");
color3.paint(); //Prints "RedYellow"
Color color4 = colorFactory1.getColor("BLACK");
color4.paint(); //Prints "RedBlack"

}
}

Conclusion:

In the article, I have explained the basic structure of Abstract Factory Design Patterns For Dart and Flutter; you can modify this code according to your choice.

I hope this blog will provide you with sufficient information on Trying up the Abstract Factory Method Design Patterns For Dart and Flutter in your projectsSo 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.


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

Backdrop Filter Widget In Flutter

0

Sometimes you need to apply a blurry impact on your application. How might you make such an impact in case you’re utilizing Flutter?. A widget called BackdropFilter is appropriate for that reason. BackdropFilter is a widget that applies a filter to the current painted substance and afterward paints its child widget. Flutter will apply the filter to all spaces inside its parent widget’s clip. That implies if there’s no clip, the filter will be applied to the whole screen.

In this blog, we will explore the Backdrop Filter Widget In Flutter. We will see how to implement a demo program of the backdrop filter widget and show you how to use that widget for creating a blur effect, in your flutter applications.

BackdropFilter class – widgets library – Dart API
A widget that applies a filter to the existing painted content and then paints the child. The filter will be applied to all…api. flutter.dev

Table Of Contents::

Backdrop Filter Widget

Properties

Implementation

Code Implement

Code File

Conclusion



Backdrop Filter Widget:

Flutter Backdrop Filter Widget is utilizing to making blurring impacts on pictures, Containers, and every one of the widgets. Backdrop Filter widget is utilized with a mix of ImageFilter class. It applies a filter on the current widget and makes the blur impact underneath the current widget. As far as anyone knows we have an image widget so we put the image widget first at that point put the Backdrop Filter widget as its child.

For more info on Backdrop Filter Widget ,Watch this video By Flutter :

Below demo video shows how to create a blur effect in a flutter. It shows how the blur effect will work using the BackdropFilter widget in your flutter applications. It shows three buttons on the center screen. When the user taps on these buttons, it will show the blur effect. All three buttons different working blur effects. It will be shown on your device.

Demo Module :


Properties:

The list of properties of backdrop filter you can pass to the constructor.

  • Key key: The widget key, used to control if it should be replaced.
  • ImageFilter filter *: The image filter to apply to the existing painted content before painting the child.
  • Widget child: The widget below this widget in the tree.

Implementation:

Step 1: Add the assets

Add assets to pubspec — yaml file.

assets:
- assets/

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

How to implement code in dart file :

You need to implement it in your code respectively:

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

We will make three buttons on this home page screen, and each button will show Backdrop Filter, and we will show the deeply below detail. When we run the application, we ought to get the screen’s output like the underneath screen capture.

Home Screen

We will deeply define all buttons

Image Blur:

First, we will import it from dart:ui.

import 'dart:ui';

We will make a blur impact that will be applied to the whole space of the parent widget. As BackdropFilter applies the filter to the current painted substance, for the most part, we need to utilize the Stack widget for the execution. The widget where the filter will be applied should be set before the filter.

Stack(
fit: StackFit.expand,
children: <Widget>[
Image.asset("assets/devs.jpg",fit: BoxFit.contain,),
Positioned.fill(
child: Center(
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 10.0,
sigmaY: 10.0,
),
child: Container(
color: Colors.black.withOpacity(0.2),

),
),
),
),
],
),

Since the filter should cover the whole space of its parent, we need to wrap the BackdropFilter widget as the child of Positioned.fill. You are needed to pass an ImageFilter. For this situation, the most appropriate filter can be made utilizing ImageFilter.blursigmaX and sigmaY control the deviation standard dependent on the filter on the x-axis and y-axis individually. Both have a default estimation of 0, which implies no impact is applied. To apply the filter on the x-axis, change the estimation of sigmaX to a positive number. For the y-axis, utilize the sigmaY property. The child of BackdropFilter can be a Container whose shading opacity is under 1, with 0 is a typical worth. When we run the application, we ought to get the screen’s output like the underneath screen capture.

Image Blur

Text Blur:

This Blur example is how to make the filter applied to a specific space of the picture. Rather than Positioned. fill, utilize the default constructor of the Positioned widget by which you can set the separation from the top, left, bottom, and right. In any case, that is adequately not. As I’ve composed above, Flutter will apply the filter to all spaces inside its parent widget’s clip. Accordingly, to apply the channel on a specific territory, you need to wrap them BackdropFilter as the child of any Clip widget, like ClipRect, ClipRRect, ClipOval, ClipPath, or CustomClipper.

Stack(
fit: StackFit.expand,
children: <Widget>[
Image.asset("assets/devs.jpg",fit: BoxFit.contain,),
Positioned(
top: 250,
left: 0,
right: 0,
child: Center(
child: ClipRRect(
borderRadius: BorderRadius.circular(24),
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 10.0,
sigmaY: 10.0,
),
child: Container(
padding: EdgeInsets.all(24),
color: Colors.white.withOpacity(0.5),
child: Text(
"Flutter Dev's",
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
),
),
),
),
],
),

We will add text on a container with the color opacity and the border-radius will be circular due to ClipRRect(). When we run the application, we ought to get the screen’s output like the underneath screen capture.

Text Blur

Image & Text Blur:

In this blur effect, all things will be the same. We will add Stack(), inside we will add a Positioned widget with top, left, and right. We will apply BackdropFilter() and its child property we will add a container with the same text and color with opacity. We will remove ClipRRect. All widgets will be blurred.

Stack(
fit: StackFit.expand,
children: <Widget>[
Image.asset("assets/devs.jpg",fit: BoxFit.contain,),
Positioned(
top: 250,
left: 0,
right: 0,
child: Center(
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 10.0,
sigmaY: 10.0,
),
child: Container(
padding: EdgeInsets.all(24),
color: Colors.white.withOpacity(0.5),
child: Text(
"Flutter Dev's",
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
),
),
),
],
),

When we run the application, we ought to get the screen’s output like the underneath screen capture.

Image & Text Blur

Code File:

import 'package:flutter/material.dart';
import 'package:flutter_backdrop_filter_widget/image_blur.dart';
import 'package:flutter_backdrop_filter_widget/image_text_blur.dart';
import 'package:flutter_backdrop_filter_widget/text_blur.dart';


class HomePageScreen extends StatefulWidget {
@override
_HomePageScreenState createState() => _HomePageScreenState();
}

class _HomePageScreenState extends State<HomePageScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xffFFFFFF),
appBar: AppBar(
title: Text("Flutter BackdropFilter Widget Demo"),
automaticallyImplyLeading: false,
centerTitle: true,
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[

RaisedButton(
child: Text('Image Blur',style: TextStyle(color: Colors.black),),
color: Colors.cyan[100],
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => ImageBlur()));
},
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
padding: EdgeInsets.all(13),
),
SizedBox(height: 8,),
RaisedButton(
child: Text('Text Blur',style: TextStyle(color: Colors.black),),
color: Colors.cyan[100],
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => TextBlur()));
},
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
padding: EdgeInsets.all(13),

),
SizedBox(height: 8,),

RaisedButton(
child: Text('Image & Text Blur',style: TextStyle(color: Colors.black),),
color: Colors.cyan[100],
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => ImageTextBlur()));
},
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
padding: EdgeInsets.all(13),


),
SizedBox(height: 8,),

],
),
)
), //center
);
}
}

Conclusion:

In the article, I have explained the basic structure of the Backdrop Filter Widget in a flutter; you can modify this code according to your choice. This was a small introduction to Backdrop Filter Widget On User Interaction from my side, and it’s working using Flutter.

I hope this blog will provide you with sufficient information in Trying up the Backdrop Filter Widget in your flutter projects. We will show you what the Backdrop Filter Widget is?, some properties using in Backdrop Filter, and make a demo program for working Backdrop Filter Widget and show you how to use that widget for creating a blur effect using the BackdropFilter widget 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 Backdrop Filter Widget Demo:

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


Animated Circular Menu In Flutter

Animation is a complex methodology in any mobile application. Despite its intricacy, Animation improves the user experience to another level and gives rich user communication. Because of its lavishness, animation turns into an integral part of present-day mobile applications. The Flutter system perceives the significance of Animation and gives a basic and natural structure to build up a wide type of animations.

In this blog, we will explore the Animated Circular Menu In Flutter. We will see how to implement a demo program of the animated circular menu and show a beautiful animation with a colorful icon using the
circular_menu package in your flutter applications.

circular_menu | Flutter Package
A simple animated circular menu for Flutter, Adjustable radius, colors, alignment, animation curve, and animation…pub. dev

Table Of Contents::

Introducton

Parameters

Implementation

Code Implement

Code File

Conclusion



Introduction:

An animated circular menu for Flutter application, Adjustable radius, delightful colors, alignment, animation curve, and animation duration. Below demo video shows how to create an animated circular menu in a flutter. It shows how the animated circular menu will work using the circular_menu package in your flutter applications. It shows when the user taps a button, then animations will occur with beautiful icons, and all icons open in circular form with animation effect. It will be shown on your device.

Demo Module :


Parameters:

There are some parameters of circular menu are:

  • > items: This parameter is used to must not be null, and it must contain two elements at least.
  • > key: This parameter is used as the global key to controlling animation anywhere in the code.
  • > backgroundWidget: This parameter is used to widget holds actual page content.
  • > startingAngleInRadian: This parameter is used to starting the angle in a clockwise radian.
  • > endingAngleInRadian: This parameter is used to ending the angle in clockwise radian.
  • > animationDuration: This parameter is used how long an animation should take to complete one cycle.

Implementation:

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:
flutter:
sdk: flutter
circular_menu:

Step 2: Import

import 'package:circular_menu/circular_menu.dart';

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

How to implement code in dart file :

You need to implement it in your code respectively:

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

First, we will create a String variable called _coloName and a Color variable called _color.

String _colorName ;
Color _color ;

In the body part, we will add CircularMenu() widget. In this widget, we will add an alignment to the center. We will add backgroundWidget, which means show the content. In this widget, we will add a Column widget. We will add RichText() ‘Press the menu button’ and wrap it to the center inside the widget.

CircularMenu(
alignment: Alignment.center,
backgroundWidget: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Center(
child: Padding(
padding: const EdgeInsets.all(100.0),
child: RichText(
text: TextSpan(
style: TextStyle(color: Colors.black, fontSize: 20,fontWeight: FontWeight.bold),
children: <TextSpan>[
TextSpan(text: 'Press the menu button'),
],
),
),
),
),
],
),
curve: Curves.bounceOut,
reverseCurve: Curves.bounceInOut,
toggleButtonColor: Colors.cyan[400],
items: [CircularMenuItem(..),
CircularMenuItem(..)
],
),

We will add a curve when the user taps the menu button, and then the animation curve is forwarding. We will add a bounceOut curve. We will add a reverseCurve means when the user taps the menu button again and the animation curve in reverse. We will add a bounceInOut curve. We will add a toggle button color. We will add items that deeply define the below code. When we run the application, we ought to get the screen’s output like the underneath screen capture.

Main Screen

We will deeply define items:

We will create a five CircularMenuItem(). Inside items, we will add icons, colors, and onTap() function. In this function, we will add a setState() method. This method will see variable _color equal to the colors and _colorname equal to text.

items: [
CircularMenuItem(
icon: Icons.home,
color: Colors.brown,
onTap: () {
setState(() {
_color = Colors.brown;
_colorName = 'Brown';
});
}),
CircularMenuItem(
icon: Icons.search,
color: Colors.green,
onTap: () {
setState(() {
_color = Colors.green;
_colorName = 'Green';
});
}),
CircularMenuItem(
icon: Icons.settings,
color: Colors.red,
onTap: () {
setState(() {
_color = Colors.red;
_colorName = 'red';
});
}),
CircularMenuItem(
icon: Icons.chat,
color: Colors.orange,
onTap: () {
setState(() {
_color = Colors.orange;
_colorName = 'orange';
});
}),
CircularMenuItem(
icon: Icons.notifications,
color: Colors.purple,
onTap: () {
setState(() {
_color = Colors.purple;
_colorName = 'purple';
});
})
],

When we pressed the menu toggle button then, the button open circular animation form. Then button menu icon change to the close icon. When we run the application, we ought to get the screen’s output like the underneath screen capture.

Final Output

Code File:

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

class CircularMenuDemo extends StatefulWidget {
@override
_CircularMenuDemoState createState() => _CircularMenuDemoState();
}

class _CircularMenuDemoState extends State<CircularMenuDemo> {
String _colorName ;
Color _color ;

@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.grey[100],
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.cyan[200],
title: Text('Flutter Animated Circular Menu Demo'),
),
body: CircularMenu(
alignment: Alignment.center,
backgroundWidget: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Center(
child: Padding(
padding: const EdgeInsets.all(100.0),
child: RichText(
text: TextSpan(
style: TextStyle(color: Colors.black, fontSize: 20,fontWeight: FontWeight.bold),
children: <TextSpan>[
TextSpan(text: 'Press the menu button'),
],
),
),
),
),
],
),
curve: Curves.bounceOut,
reverseCurve: Curves.bounceInOut,
toggleButtonColor: Colors.cyan[400],
items: [
CircularMenuItem(
icon: Icons.home,
color: Colors.brown,
onTap: () {
setState(() {
_color = Colors.brown;
_colorName = 'Brown';
});
}),
CircularMenuItem(
icon: Icons.search,
color: Colors.green,
onTap: () {
setState(() {
_color = Colors.green;
_colorName = 'Green';
});
}),
CircularMenuItem(
icon: Icons.settings,
color: Colors.red,
onTap: () {
setState(() {
_color = Colors.red;
_colorName = 'red';
});
}),
CircularMenuItem(
icon: Icons.chat,
color: Colors.orange,
onTap: () {
setState(() {
_color = Colors.orange;
_colorName = 'orange';
});
}),
CircularMenuItem(
icon: Icons.notifications,
color: Colors.purple,
onTap: () {
setState(() {
_color = Colors.purple;
_colorName = 'purple';
});
})
],
),
),
);
}
}

Conclusion:

In the article, I have explained the Animated Circular Menu of the basic structure in a flutter; you can modify this code according to your choice. This was a small introduction to Animated Circular Menu On User Interaction from my side, and it’s working using Flutter.

I hope this blog will provide you with sufficient information in Trying up the Animated Circular Menu in your flutter projectsWe will show you what the introduction is?. Some circular menu parameters, make a demo program for working Animated Circular Menu and show when the user taps a button the animations will occur with beautiful icons. All icons open in circular form with an animation effect. When we pressed the menu toggle button, the button menu icon changed to the close icon using the circular_menu package 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 Animated Circular Menu Demo:

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


Explore IndexedStack Widget In Flutter

0

Widgets are settled with one another to construct the application. It implies your application’s base is itself a widget, and right down is a widget moreover. For instance, a widget can show something, characterize configuration, deal with communication, etc. At whatever point you will code for building anything in Flutter, it will be inside a widget.

The focal reason for existing is to construct the application out of widgets. It portrays how your application view should look like with their present setup and state. When you modified the code, the widget rebuilt its depiction by computing the contrast between the past and current widget to decide the negligible changes for rendering in the UI of the application.

In Flutter, nearly everything is a widget — even layout models are widgets. The pictures, symbols, and text you find in a Flutter application are on the widgets. In any case, things you don’t see are additionally widgets, like the rows, columns, and grids that arrange, oblige and align the obvious widgets.

In this article, we will Explore IndexedStack Widget In Flutter. We will implement an indexedstack widget demo program and create a custom navigation bar in your flutter applications.

IndexedStack class – widgets library – Dart API
API docs for the IndexedStack class from the widgets library, for the Dart programming language.api.flutter.dev

Table Of Contents::

IndexedStack Widget

Properties

Code Implementation

Code File

Conclusion



IndexedStack Widget:

An IndexedStack is a stack where only one component is shown at one time by its index. A Stack that shows a solitary child from a list of children. The showed child is the one with the given index. The stack is consistently just about as large as the biggest child. On the off chance that the value is null, nothing is shown.

For more info on IndexedStack Widget ,Watch this video By Flutter :

Below demo video shows how to create a custom navigation bar in a flutter. It shows how the custom navigation bar will work using the IndexedStack widget in your flutter applications. It shows three buttons on the bottom screen. When the user taps on these buttons, it will show the data. It will be shown on your device.

Demo Module :


Properties:

There are some properties of IndexedStack Widget:

  • > index: These properties are used to the index of the child to show.
  • > children: These properties are used to the List<Widget>. The widgets below this widget in the tree.
  • > alignment: These properties are used to align the non-positioned and partially-positioned children in the stack.
  • > sizing: These properties are used to size the non-positioned children in the stack.
  • > textDirection: These properties are used to the text direction with which to resolve alignment.

Implementation:

Step 1: Add the assets

Add assets to pubspec — yaml file.

assets:
- assets/

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

How to implement code in dart file :

You need to implement it in your code respectively:

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

We will create an integer index that is zero.

int index = 0;

In the body, we will add a column widget. In the Column widget, we will create two widgets are_stackedContainers() and _navigationButtons(). We will deeply define the below code.

Column(
children: <Widget>[
_stackedContainers(),
_navigationButtons()
],
),

We will deeply define _stackedContainers() widget:

In this widget, we will return an Expanded widget. Inside, we will add IndexedStack() widget. In this widget, we will add an index that means the index of the child to show. Add the children widget, inside add three containers. In these containers, we will add three images with the wrap of the center widget.

Widget _stackedContainers() {
return Expanded(
child: IndexedStack(
index: index,
children: <Widget>[
Container(
child: Center(
child: Image.asset("assets/images/flutter.png",)
)
),
Container(
child: Center(
child: Image.asset("assets/images/powered_by.png",)
)
),
Container(
child: Center(
child: Image.asset("assets/images/devs.jpg",)
)
),
],
),
);
}

We will deeply define _navigationButtons() widget:

In this widget, we will return a row widget. Inside, we will add three FlatButton(). For all three buttons, we will add text, color, and onPressed method. In this method, we will add setState() and add the different index.

Widget _navigationButtons() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
FlatButton(
color:Colors.pink[300],
child: Text('Flutter', style: TextStyle(fontSize: 16.0,color: Colors.white),),
onPressed: () {
setState(() {
index = 0;
});
},
),
FlatButton(
color:Colors.pink[300],
child: Text('Aeologic', style: TextStyle(fontSize: 16.0,color: Colors.white),),
onPressed: () {
setState(() {
index = 1;
});
},
),
FlatButton(
color:Colors.pink[300],
child: Text('Flutter Devs', style: TextStyle(fontSize: 16.0,color: Colors.white),),
onPressed: () {
setState(() {
index = 2;
});
},
),
],
);
}

When we run the application, we ought to get the screen’s output like the underneath screen capture.

Final Output

Code File:

import 'package:flutter/material.dart';

class CustomNavigationBarDemo extends StatefulWidget {


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

class _CustomNavigationBarDemoState extends State<CustomNavigationBarDemo> {

int index = 0;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.pink[300],
title: Text('Flutter Indexed Stack Demo'),
),
body: Padding(
child: Column(
children: <Widget>[
_stackedContainers(),
_navigationButtons()
],
),
padding: EdgeInsets.all(5.0),
),
);
}

Widget _stackedContainers() {
return Expanded(
child: IndexedStack(
index: index,
children: <Widget>[
Container(
child: Center(
child: Image.asset("assets/images/flutter.png",)
)
),
Container(
child: Center(
child: Image.asset("assets/images/powered_by.png",)
)
),
Container(
child: Center(
child: Image.asset("assets/images/devs.jpg",)
)
),
],
),
);
}

Widget _navigationButtons() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
FlatButton(
color:Colors.pink[300],
child: Text('Flutter', style: TextStyle(fontSize: 16.0,color: Colors.white),),
onPressed: () {
setState(() {
index = 0;
});
},
),
FlatButton(
color:Colors.pink[300],
child: Text('Aeologic', style: TextStyle(fontSize: 16.0,color: Colors.white),),
onPressed: () {
setState(() {
index = 1;
});
},
),
FlatButton(
color:Colors.pink[300],
child: Text('Flutter Devs', style: TextStyle(fontSize: 16.0,color: Colors.white),),
onPressed: () {
setState(() {
index = 2;
});
},
),
],
);
}
}

Conclusion:

In the article, I have explained the IndexedStack Widget basic structure in a flutter; you can modify this code according to your choice. This was a small introduction to IndexedStack Widget On User Interaction from my side, and it’s working using Flutter.

I hope this blog will provide you with sufficient information in Trying up the IndexedStack Widget in your flutter projectsWe will show you what the IndexedStack Widget is?. Some indexedstack widget properties, make a demo program for working IndexedStack Widget, and create a custom navigation bar. It shows three buttons on the bottom screen. The user taps on these buttons will show the data using the IndexedStack widget 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 Indexed Stack Demo:

flutter-devs/flutter_indexed_stack_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: Explore Polygon Clipper In Flutter

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


Drag And Drop GridView In Flutter

Drag and drop is typical mobile application interaction. As the user long presses (at times called touch and hold) on a widget, another widget shows up underneath the user’s finger, and the user drags the widget to a last area and deliveries it. On multitouch devices, various drags can happen simultaneously because there can be numerous pointers in contact with the devices without a moment’s delay. To restrict the number of concurrent drags, utilize the maxSimultaneousDrags property. The default is to permit a limitless number of concurrent drags.

In this article, we will explore the Drag And Drop GridView In Flutter. We will implement a drag-and-drop grid view demo program and creating a reorder of the GridViewItems simple by Drag And Drop using the drag_and_drop_gridview package in your flutter applications.

drag_and_drop_gridview | Flutter Package
Drag And Drop GridView extends the functionality of the GridView widget in Flutter and gives you the freedom of…pub.dev

Table Of Contents::

Introduction

Implementation

Code Implement

Code File

Conclusion



Introduction:

Drag And Drop GridView extends the usefulness of the GridView widget in Flutter and gives you the opportunity of making a reorder of the GridViewItems straightforward by Drag And Drop. It is too simple to execute and excellent to utilize.

Demo Module :

This demo video shows how to create a drag-and-drop grid view in a flutter. It shows how the drag-and-drop grid view will work using the drag_and_drop_gridview package in your flutter applications. It shows drag-and-drop interaction where the user long presses on a choice of item and then drags it to the picture using the drag and drop technique. Something like a grid view with drag and drop can change the position both horizontally and vertically. It will be shown on your device.

Implementation:

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:
flutter:
sdk: flutter
drag_and_drop_gridview:

Step 2: Import

import 'package:drag_and_drop_gridview/devdrag.dart';

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

How to implement code in dart file :

You need to implement it in your code respectively:

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

We will create a list of strings of an image and define it on a staggered _imageUrls.

List<String> _imageUrls = [
'https://cdn.pixabay.com/photo/2020/12/15/16/25/clock-5834193__340.jpg',
'https://cdn.pixabay.com/photo/2020/09/18/19/31/laptop-5582775_960_720.jpg',
'https://media.istockphoto.com/photos/woman-kayaking-in-fjord-in-norway-picture-id1059380230?b=1&k=6&m=1059380230&s=170667a&w=0&h=kA_A_XrhZJjw2bo5jIJ7089-VktFK0h0I4OWDqaac0c=',
'https://cdn.pixabay.com/photo/2019/11/05/00/53/cellular-4602489_960_720.jpg',
'https://cdn.pixabay.com/photo/2017/02/12/10/29/christmas-2059698_960_720.jpg',
'https://cdn.pixabay.com/photo/2020/01/29/17/09/snowboard-4803050_960_720.jpg',
'https://cdn.pixabay.com/photo/2020/02/06/20/01/university-library-4825366_960_720.jpg',
'https://cdn.pixabay.com/photo/2020/11/22/17/28/cat-5767334_960_720.jpg',
'https://cdn.pixabay.com/photo/2020/12/13/16/22/snow-5828736_960_720.jpg',
'https://cdn.pixabay.com/photo/2020/12/09/09/27/women-5816861_960_720.jpg',
"https://images.pexels.com/photos/1144687/pexels-photo-1144687.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260",
"https://images.pexels.com/photos/2589010/pexels-photo-2589010.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"
];

We will create an integer variable set equal to zero, add scrollController and add double od width and height.

int variableSet = 0;
ScrollController? _scrollController;
double? width;
double? height;

In the body part, we will add DragAndDropGridView(). Inside, we will add a controller and gridDelegate. The gridDelegate argument must not be null. Add SliverGridDelegateWithFixedCrossAxisCount() means creates a delegate that makes grid layouts with a fixed number of tiles in the cross axis.

DragAndDropGridView(
controller: _scrollController,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 3 / 4.5,
),
),

In DragAndDropGridView(), we will add itemBuilder that it will be called only with indices greater than or equal to zero and less than `itemCount.` LayoutBuilder(), set height, and width. We will return GridTile(), add an image dot network. Also, add itemCount.

itemBuilder: (context, index) => Card(
elevation: 2,
child: LayoutBuilder(
builder: (context, constrains) {
if (variableSet == 0) {
height = constrains.maxHeight;
width = constrains.maxWidth;
variableSet++;
}
return GridTile(
child: Image.network(
_imageUrls[index],
fit: BoxFit.cover,
height: height,
width: width,
),
);
},
),
),
itemCount: _imageUrls.length,

We will add onWillAccept means this function allows you to validate if you want to accept the change in the order of the gridViewItems. If you always want to accept the change, return true.

onWillAccept: (oldIndex, newIndex) {
if (_imageUrls[newIndex] == "something") {
return false;
}
return true;
},

We will add onReorder means this function deals with changing the index of the newly arranged gridItems. Add final temp is equal to the _imageUrls[oldIndex], _imageUrls[oldIndex] is equal to the _imageUrls[newIndex], and _imageUrls[newIndex] is equal to the temp.

onReorder: (oldIndex, newIndex) {
final temp = _imageUrls[oldIndex];
_imageUrls[oldIndex] = _imageUrls[newIndex];
_imageUrls[newIndex] = temp;

setState(() {});
},

When we run the application, we ought to get the screen’s output like the underneath screen capture.

Final Output

Code File:

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

void main() {
runApp(MyApp());
}

class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
List<String> _imageUrls = [
'https://cdn.pixabay.com/photo/2020/12/15/16/25/clock-5834193__340.jpg',
'https://cdn.pixabay.com/photo/2020/09/18/19/31/laptop-5582775_960_720.jpg',
'https://media.istockphoto.com/photos/woman-kayaking-in-fjord-in-norway-picture-id1059380230?b=1&k=6&m=1059380230&s=170667a&w=0&h=kA_A_XrhZJjw2bo5jIJ7089-VktFK0h0I4OWDqaac0c=',
'https://cdn.pixabay.com/photo/2019/11/05/00/53/cellular-4602489_960_720.jpg',
'https://cdn.pixabay.com/photo/2017/02/12/10/29/christmas-2059698_960_720.jpg',
'https://cdn.pixabay.com/photo/2020/01/29/17/09/snowboard-4803050_960_720.jpg',
'https://cdn.pixabay.com/photo/2020/02/06/20/01/university-library-4825366_960_720.jpg',
'https://cdn.pixabay.com/photo/2020/11/22/17/28/cat-5767334_960_720.jpg',
'https://cdn.pixabay.com/photo/2020/12/13/16/22/snow-5828736_960_720.jpg',
'https://cdn.pixabay.com/photo/2020/12/09/09/27/women-5816861_960_720.jpg',
"https://images.pexels.com/photos/1144687/pexels-photo-1144687.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260",
"https://images.pexels.com/photos/2589010/pexels-photo-2589010.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260"
];

int variableSet = 0;
ScrollController? _scrollController;
double? width;
double? height;

@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.blueGrey[100],
appBar: AppBar(
backgroundColor: Colors.black,
title: Text('Flutter Drag And Drop GridView'),
),
body: Center(
child: DragAndDropGridView(
controller: _scrollController,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 3 / 4.5,
),
padding: EdgeInsets.all(20),
itemBuilder: (context, index) => Card(
elevation: 2,
child: LayoutBuilder(
builder: (context, constrains) {
if (variableSet == 0) {
height = constrains.maxHeight;
width = constrains.maxWidth;
variableSet++;
}
return GridTile(
child: Image.network(
_imageUrls[index],
fit: BoxFit.cover,
height: height,
width: width,
),
);
},
),
),
itemCount: _imageUrls.length,
onWillAccept: (oldIndex, newIndex) {
if (_imageUrls[newIndex] == "something") {
return false;
}
return true;
},
onReorder: (oldIndex, newIndex) {
final temp = _imageUrls[oldIndex];
_imageUrls[oldIndex] = _imageUrls[newIndex];
_imageUrls[newIndex] = temp;

setState(() {});
},
),
),
),
);
}
}

Conclusion:

In the article, I have explained the Drag And Drop GridView of the basic structure in a flutter; you can modify this code according to your choice. This was a small introduction to Drag And Drop GridView On User Interaction from my side, and it’s working using Flutter.

I hope this blog will provide you with sufficient information in Trying up the Drag And Drop GridView in your flutter projectsWe will show you what the Introduction is?. Make a demo program for working Drag And Drop GridView, and show drag-and-drop interaction where the user long presses on a choice of item and then drags that item to the picture using the drag and drop technique. Something like a grid view with drag and drop can change the position both horizontally and vertically using the drag_and_drop_gridview package 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.


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.