Google search engine
Home Blog Page 27

Frosted Glass Effect In Flutter

0

The frosted glass effect is a cool UI idea in the flutter that makes our UI look more alluring. It is fundamentally a blurred-out overlay with decreased opacity, to recognize or lessen a specific view. This component truly looks great however it influences the application’s performance.

In this blog, we will explore the Frosted Glass Effect In Flutter. We will execute a demo program in-depth to look at creating a Frosted Glass look in Flutter that you can use for Cards and other UI Components in your flutter applications.

Table Of Contents::

Frosted Glass Effect:

Code Implement

Code File

Conclusion



Frosted Glass Effect:

The Frosted Glass effect is a somewhat normal impact utilized in iOS and Android applications. The principal thought of adding frosted glass effect in the use of showing the view which needs to focus on a clean environment while obscuring the other content to make that less engaged.

Flutter gives the simple inbuild widget to make a Frosted glass impact in your and this will work both in iOS and Android very well. BackdropFilter widget in Flutter can use to blur the picture, container, and numerous different widgets also.

Demo Module :

This demo video shows how to create a Frosted glass effect in a flutter. It shows how to Frosted glass effect will work using BackdropFilter widget in your flutter applications. It shows the card with background transparent and other text will be shown on this card. It 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 main.dart inside the lib folder.

In the body, we will add a Container widget. In this widget, we will add height, width with double infinity and add color. It’s child property, we will add Stack() widget. Inside, we will add the Colum with the mainAxisAlignment was center. We will add two Container widgets with height and width. We will add LinearGradient() on both containers. The first one, begin: Alignment.topRight, end: Alignment.bottomLeft, and margin: EdgeInsets.only(left: 200). The second one, begin: Alignment.topRight, end: Alignment.bottomLeft, and )margin: EdgeInsets.only(right: 270).

Container(
height: double.infinity,
width: double.infinity,
color: Colors.black,
child: Stack(
children: [
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 200,
height: 200,
margin: EdgeInsets.only(left: 200),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.pink.shade700,
Colors.orange.shade500
],
begin: Alignment.topRight,
end: Alignment.bottomLeft,
),
borderRadius: BorderRadius.circular(100)),
),
Container(
width: 100,
height: 100,
margin: EdgeInsets.only(right: 270),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.pink.shade700,
Colors.orange.shade500
],
begin: Alignment.topRight,
end: Alignment.bottomLeft,
),
borderRadius: BorderRadius.circular(100)),
)
],
),
),
frostedGlassEffectDemo(context),
],
),
),

We will add frostedGlassEffectDemo(context) widget. We will deeply define below the code. When we run the application, we ought to get the screen’s output like the underneath screen capture.

Output

Now we will deeply define frostedGlassEffectDemo(context) widget:

In this widget, we will return a Center widget. Inside, we will add ClipRRect() method. In this method, we will add borderRadius: BorderRadius.circular(20), and add Conatiner.

return Center(
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: Container(
//////////
),
),

Now, Inside the Container widget. We will add Stack() widget. In this widget, we will add BackdropFilter() and Container(). In BackdropFilter, we will add a filter: ImageFilter.blur, and bracket we will add sigmaX: 7, sigmaY: 7. It’s child property, we will add a Container with height and width.

Container(
child:
Stack(
children: [
BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 7,
sigmaY: 7,
),
child: Container(
height: 220,
width: 360,
),
),
Container(
height: 230,
width: 360,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.25),
)
],
border: Border.all(
color: Colors.white.withOpacity(0.2), width: 1.0),
gradient: LinearGradient(
colors: [
Colors.white.withOpacity(0.5),
Colors.white.withOpacity(0.2)
],
stops: [0.0, 1.0],
),
borderRadius: BorderRadius.circular(20)),
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
children: [
SizedBox(
height: 10,
),
SizedBox(
width: 270,
child: Text(
"Debit Card",
style: TextStyle(
color: Colors.white.withOpacity(0.6),
fontWeight: FontWeight.bold,
fontSize: 22),
)),
SizedBox(
height: 70,
),
Text(
"7622 4574 3688 3640 ",
style: TextStyle(
fontSize: 23, color: Colors.white.withOpacity(0.4)),
),
SizedBox(
width: 275,
child: Row(
children: [
Text(
"6372",
style: TextStyle(
color: Colors.white.withOpacity(0.5),
fontSize: 12),
),
SizedBox(
width: 100,
),
Text(
"VALID \n THRU",
style: TextStyle(
fontSize: 6,
color: Colors.white.withOpacity(0.5),
fontWeight: FontWeight.bold),
),
Text(
" 09/25",
style: TextStyle(
fontSize: 14,
color: Colors.white.withOpacity(0.5)),
),
],
),
),
SizedBox(
height: 10,
),
SizedBox(
width: 275,
child: Text(
"FLUTTER DEVS",
style: TextStyle(
color: Colors.white.withOpacity(0.6),
fontWeight: FontWeight.bold),
))
],
),
),
),
]),
),

Container widget, we will add LinearGradient(). It’s child property, we will add the Column widget. In this widget, we will add a text “Debit Card”, with color: Colors.white.withOpacity(0.6), fontWeight: FontWeight.bold. Alsowe will add much more text with different font sizes, colors, and fontWeight. 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/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:frostedcard/splash.dart';

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

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Splash(),
);
}
}

class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.white12,
title: Text("Flutter Forested Glass Effect Demo"),
),
body: Container(
height: double.infinity,
width: double.infinity,
color: Colors.black,
child: Stack(
children: [
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 200,
height: 200,
margin: EdgeInsets.only(left: 200),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.pink.shade700,
Colors.orange.shade500
],
begin: Alignment.topRight,
end: Alignment.bottomLeft,
),
borderRadius: BorderRadius.circular(100)),
),
Container(
width: 100,
height: 100,
margin: EdgeInsets.only(right: 270),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.pink.shade700,
Colors.orange.shade500
],
begin: Alignment.topRight,
end: Alignment.bottomLeft,
),
borderRadius: BorderRadius.circular(100)),
)
],
),
),
frostedGlassEffectDemo(context),
],
),
),
);
}
}

Widget frostedGlassEffectDemo(BuildContext context) {
return Center(
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: Container(
child:
Stack(
children: [
BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 7,
sigmaY: 7,
),
child: Container(
height: 220,
width: 360,
),
),
Container(
height: 230,
width: 360,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.25),
)
],
border: Border.all(
color: Colors.white.withOpacity(0.2), width: 1.0),
gradient: LinearGradient(
colors: [
Colors.white.withOpacity(0.5),
Colors.white.withOpacity(0.2)
],
stops: [0.0, 1.0],
),
borderRadius: BorderRadius.circular(20)),
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
children: [
SizedBox(
height: 10,
),
SizedBox(
width: 270,
child: Text(
"Debit Card",
style: TextStyle(
color: Colors.white.withOpacity(0.6),
fontWeight: FontWeight.bold,
fontSize: 22),
)),
SizedBox(
height: 70,
),
Text(
"7622 4574 3688 3640 ",
style: TextStyle(
fontSize: 23, color: Colors.white.withOpacity(0.4)),
),
SizedBox(
width: 275,
child: Row(
children: [
Text(
"6372",
style: TextStyle(
color: Colors.white.withOpacity(0.5),
fontSize: 12),
),
SizedBox(
width: 100,
),
Text(
"VALID \n THRU",
style: TextStyle(
fontSize: 6,
color: Colors.white.withOpacity(0.5),
fontWeight: FontWeight.bold),
),
Text(
" 09/25",
style: TextStyle(
fontSize: 14,
color: Colors.white.withOpacity(0.5)),
),
],
),
),
SizedBox(
height: 10,
),
SizedBox(
width: 275,
child: Text(
"FLUTTER DEVS",
style: TextStyle(
color: Colors.white.withOpacity(0.6),
fontWeight: FontWeight.bold),
))
],
),
),
),
]),
),
),
);
}

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the Frosted Glass Effect in your flutter projects. We will show you what the Frosted Glass Effect is?. Make a demo program for working Frosted Glass Effect using BackdropFilter, container, and many more Widgets 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.


Explore AbsorbPointer In Flutter

0

These days applications use touch input from clients/users. Consider the possibility that you need to disable the touch in a specific region or other words, you need to make the touch pointer has no impact. In Flutter, you can utilize IgnorePointer or AbsorbPointer.

AbsorbPointer is a sort of control that precludes client input, for example, button click, the input of input box, scrolling of ListView, and so on you might say that setting the onPressed() of a button to invalid can likewise be acknowledged, indeed, however, AbsorbPointer can give bound together control of numerous parts without expecting you to set every part independently.

In this blog, we will be Explore AbsorbPointer In Flutter. We will execute a demo program of the AbsorbPointer and shows you how to use AbsorbPointer it in your flutter applications.

AbsorbPointer class – widgets library – Dart API
The following sample has an AbsorbPointer widget wrapping the button on top of the stack, which absorbs pointer-events…api. flutter.dev

Table Of Contents::

AbsorbPointer

Constructor

Properties

Code Implement

Code File

Conclusion



AbsorbPointer:

AbsorbPointer is a built-in widget in flutter which absorbs pointer, all in all, it forestalls its subtree from being clicked, tapped, scrolled, hauled, and react to hover. In flutter, most widgets currently accompany an alternative to impair them. Yet, assuming we need to disable an entire widget tree or even a full screen without a moment’s delay, we can do it with the assistance of the AbsorbPointer widget. IgnorePointer is likewise a comparable widget in a flutter, which additionally prevents its children from being clicked.

To get a more understanding through the help of video , Please watch:

Demo Module :

The below demo video shows how to use AbsorbPointer in a flutter. It shows how AbsorbPointer will work in your flutter applications. It tells you the best way to utilize it and shows when the user true the switch of AbsorbPointer, then button and textfield not working or touch pointer has no effect. It will be shown on your device.

Constructor:

To utilize AbsorbPointer, you need to call the constructor underneath:

const AbsorbPointer({
Key? key,
this.absorbing = true,
Widget? child,
this.ignoringSemantics,
})

When the user wraps the whole UI with AbsorbPointer then the user can control user interaction to UI by toggling the absorbing property of it.

Properties :

There are some properties of AbsorbPointer are:

  • > key: This property is used to control if it should be replaced.
  • > child: This property is used to define widgets under the current Widget in a tree. It has only one Child. To allocate multiple children users can use Column WidgetRow Widget, Or Stack Widget, and can wrap it in children.
  • > absorbing: This property is used to define whether this widget absorbs during hit testing. The default value is set to true. If the absorbing value is true, and click inside the widget will be absorbed. If you don’t pass the absorbing parameter, it will use the default value (true) which causes any pointer inside the widget will be absorbed.
  • > ignoringSemantics: This property is used to define whether the semantics of this widget is ignored when compiling the semantics tree.

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.

First, we will create a bool variable _absorbing is equal to false.

bool _absorbing = false;

In the body, first, we will not add AbsorbPointer. Then, we will create Column() widget. In this widget, we will add an ElevatedButton(). Inside the button, we will add style, text ‘Press the button’ and onPressed() method. Inside the method, we will add Scaffold.of(context).showSnackBar(). Inside SnackBar, we will add content, backgroundColor. Also, we will add TextField().

Column(
children: <Widget>[
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.cyan[300],
),
child: Text('Press the button'),
onPressed: () {
Scaffold.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.teal[300],
content: Text('Button is pressed'),
),
);
},
),
TextField(),
],
),

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

Without AbsorbPointer

Then, we will add AbsorbPointer(). We will add variable absorbing means whether this widget absorbs during hit testing and add _absorbing. Column widget wrap to it AbsorbPointer().

AbsorbPointer(
absorbing: _absorbing,
child: Column(
children: <Widget>[
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.cyan[300],
),
child: Text('Press the button'),
onPressed: () {
Scaffold.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.teal[300],
content: Text('Button is pressed'),
),
);
},
),
TextField(),
],
),
),

We will add the Row() widget. In this widget, we will add the mainAxisAlignment was center. We will add the text ’Absorb Pointer?’ and Switch() method. In this method, we will add value, onChanged. In onChanged, we will add setState() method. In this method, we will add _absorbing is equal to value.

Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('Absorb Pointer?'),
Switch(
activeColor: Colors.cyan[300],
value: _absorbing,
onChanged: (bool value) {
setState(() {
_absorbing = value;
});
},
),
],
),

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

Output

Code File:

import 'package:flutter/material.dart';
import 'package:flutter_absorb_pointer_demo/splash_screen.dart';

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

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Splash(),
);
}
}

class MyHomePage extends StatefulWidget {

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

class _MyHomePageState extends State<MyHomePage> {
bool _absorbing = false;


@override
Widget build(BuildContext context) {

return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.cyan[300],
title: Text("Flutter Absorb Pointer Demo"),
),
body: Builder(
builder: (context) => Center(
child: Padding(
padding: EdgeInsets.all(15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
AbsorbPointer(
absorbing: _absorbing,
child: Column(
children: <Widget>[
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.cyan[300],
),
child: Text('Press the button'),
onPressed: () {
Scaffold.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.teal[300],
content: Text('Button is pressed'),
),
);
},
),
TextField(),
],
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('Absorb Pointer?'),
Switch(
activeColor: Colors.cyan[300],
value: _absorbing,
onChanged: (bool value) {
setState(() {
_absorbing = value;
});
},
),
],
),
],
),
),
),
),
);
}
}

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the AbsorbPointer in your flutter projects. We will show you what the AbsorbPointer is?. Show constructor and properties of the AbsorbPointer. Make a demo program for working AbsorbPointer. In this blog, we have examined the AbsorbPointer of the flutter app. I hope this blog will help you in the comprehension of the AbsorbPointer in a better way. So please try it.

❤ ❤ Thanks for reading this article ❤❤

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

Clap 👏 If this article helps you.


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 Exception Handling In Flutter

Related: Explore Dart String Interpolation

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


Concurrency In Dart

0

Concurrency is the execution of a few guidance groupings simultaneously. It includes performing more than one task all the while. Dart utilizes Isolates as an apparatus for doing works in equal. The dartisolate package is Dart’s answer for taking single-threaded Dart code and permitting the application to utilize the equipment accessible.

Isolates, as the name recommends, are disengaged units of running code. The best way to send information between them passing messages, similar to how you pass messages between the client and the server. An isolate assists the program with exploiting multicore microprocessors out of the case.

In this article, we will explore the Concurrency In Dart. Simultaneous programs might be executed in equal, contingent upon your machine (single-core / multi-core).


What is Concurrency?:

The Dart concurrency permits us to run various programs or different parts of a program at the same time. It executes a few guidelines simultaneously. Dart gives the Isolates as an instrument for doing works for equality. The simultaneousness makes the program exceptionally compelling and throughput by using the unused abilities of fundamental operating systems and machine equipment.

Concurrency in straightforward terms implies the application is making progress in more than each undertaking in turn. In a typical application or program, each line of code s executed successively, consistently. Yet, programs that utilization concurrency can run two functions all the while.

On the off chance that you attempt concurrency in a single-core system, your CPU will simply utilize a scheduling algorithm and switch between the undertakings, so basically in single-core CPU errands will make progress at the same time yet there will be no two tasks executing simultaneously.

How to achieve concurrency?:

In Dart, we can accomplish concurrency by utilizing the Isolates. Here we will comprehend its concise presentation. Dart isolate is a form of thread. Yet, there is a key contrast between the normal execution of “Thread” or “Isolates”. The isolate works contrastingly in contrast with Thread. The isolates are autonomous workers that don’t share memory however rather interconnect by ignoring messages channels. Since isolates total their assignment by passing messages in this way it needs an approach to serialize a message

Isolate.spawn(testing,'message_to_pass');

An isolate assists the program with exploiting multicore microprocessors out of the case. It’s impossible to share a variable among isolates the best way to impart between isolates is utilizing message passing.

Let’s understand this with an examples :

import 'dart:isolate';
void testing(var msg){
print('execution from testing ... the message is :${msg}');
}
void main(){
Isolate.spawn(testing,'Hello!!');
Isolate.spawn(testing,'How are you!!');
Isolate.spawn(testing,'Where are you!!');

print('execution from main1');
print('execution from main2');
print('execution from main3');
}

When we run the application, we ought to get the screen’s output like the underneath screen Output:

execution from main1
execution from main2
execution from main3
execution from testing ... the message is :How are you!!
execution from testing ... the message is :Hello!!
execution from testing ... the message is :Where are you!!

Note: Your output may differ.

Here and there assuming you have an extremely complex function running on Isolate, that function may not be executed totally.

import 'dart:isolate';

void testingFunction(var msg) {
for (int i = 0; i < 7; i++) {
print(msg + "$i");
}
}

void main() async {
Isolate.spawn(testingFunction, "Function");

print("Execution Main 1");
print("Execution Main 2");
print("Execution Main 3");
}

Here I have a for loop running on Isolate, however, my for loop runs just for 4 iterations, that is because that when my for loop is iterating, the main function arrives at its last line of execution. So the program kills with the running isolate function.

When we run the application, we ought to get the screen’s output like the underneath screen Output:

Execution Main 1
Execution Main 2
Execution Main 3
Function 0
Function 1
Function 2
Function 3

Assuming you need your isolate function to run completely then you can utilize Asynchronous programming: futuresasyncawait.

import 'dart:isolate';

Future<void> testingFunction(var msg) async {
for (int i = 0; i < 7; i++) {
print(msg + "$i");
}
}

void main() async {
await Isolate.spawn(testingFunction, "Function"); // Isolate Function

print("Execution Main 1");
print("Execution Main 2");
print("Execution Main 3");
}

When we run the application, we ought to get the screen’s output like the underneath screen Output:

Execution Main 1
Execution Main 2
Execution Main 3
Function 0
Function 1
Function 2
Function 3
Function 4
Function 5
Function 6

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the Concurrency In Dart in your flutter projects. We will show you what Concurrency is?. Make demo examples for working Concurrency In Dart. In this blog, we have examined the Concurrency In Dart. I hope this blog will help you in the comprehension of Concurrency In Dart in a better way. So please try it.

❤ ❤ Thanks for reading this article ❤❤

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

Clap 👏 If this article helps you.


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: Metadata Annotations in Dart

Related: Sum Of a List Of Numbers In Dart

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

CupertinoPageRoute In Flutter

0

The Route class is a high-level abstraction through the route include. In any case, we won’t utilize it straightforwardly, as we have seen that a screen is a route in Flutter. Various stages might require screen changes to act unexpectedly. In Flutter, there are elective executions in a stage versatile way. This task is finished with MaterialPageRoute and CupertinoPageRoute, which adjust to Android and iOS separately.

In this article, we will explore the CupertinoPageRoute In Flutter. We will execute a demo program of the CupertinoPageRoute and how to utilize it in your flutter applications

CupertinoPageRoute class – Cupertino library – Dart API
A modal route that replaces the entire screen with an iOS transition. The page slides in from the right and exits in…api. flutter.dev

Table Of Contents::

CupertinoPageRoute

Constructor

Properties

Code Implement

Code File

Conclusion



CupertinoPageRoute:

A modal route that replaces the whole screen with an iOS change. The page slides in from the right and exits backward. The page likewise moves to one side in parallax when another page enters to cover it.

The page slides in from the base and exits backward with no parallax impact for fullscreen dialogs. As a matter of course, when a modal route is supplanted by another, the previous route stays in memory. To free every one of the resources when this isn’t required, set maintainState to false.

Demo Module :

This demo video shows how to use CupertinoPageRoute in a flutter. It shows how CupertinoPageRoute will work in your flutter applications. It tells you how to rote one page to another page using CupertinoPageRoute. It will be shown on your device.

Constructor:

To utilize CupertinoPageRoute, you need to call the constructor underneath:

CupertinoPageRoute({
required this.builder,
this.title,
RouteSettings? settings,
this.maintainState = true,
bool fullscreenDialog = false,
})

In the Above Constructor, all attributes marked with @required must not be empty.

Properties:

There are some properties of CupertinoPageRoute are:

  • > builder: This property is used to builds the primary contents of the route.
  • > title: This property is used to title string for this route.
  • > maintainState: This property is used to whether the route should remain in memory when it is inactive.
  • > debugLabel: This property is used to a short description of this route useful for debugging.

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 class HomePage. Inside the class, we will add Column() widget. In his widget, we will add mainAxisAlignment and crossAxisAlignment was center. In children property, we will add an image and ElevatedButton(). Inside the button, we will add ElevatedButton.styleFrom(). Inside, we will add textStyle, minimumSize, and primary. We will add the onPressed() method. In this method, we will add Navigator.of(context).push(SecondPage.route()). We will define below SecondPage(). Also, we will add the text “Home Page”.

Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset("assets/logo.png",width: 300,),
SizedBox(height: 70,),
ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: TextStyle(fontSize: 20),
minimumSize: Size.fromHeight(40),
primary: Colors.teal,
),
onPressed: () => Navigator.of(context).push(SecondPage.route()),
child: Text("Home Page")
),
],
),

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

Home Page

In main. dart file, we will create a class SecondPage. Inside, we will add static dynamic route Route<dynamic> routeWe will return CupertinoPageRoute(). Inside, we will add builder means builds the primary contents of the route. In bracket, we will add BuildContext context and return SecondPage().

class SecondPage extends StatelessWidget {
static Route<dynamic> route() {
return CupertinoPageRoute(
builder: (BuildContext context) {
return SecondPage();
},
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.teal,
title: Text("Second Page"),
),
body: Container(
child: Center(
child: Text("Welcome to Flutter Dev's", style: TextStyle(fontSize: 30),),
),
),
);
}
}

In the body, we will add Container(). Inside, we will add the text ”Welcome to Flutter Dev’s” and wrap it to its Center(). When we run the application, we ought to get the screen’s output like the underneath screen capture.

Second Page

Code File:

import 'package:flutter/cupertino.dart' show CupertinoPageRoute;
import 'package:flutter/material.dart';
import 'package:flutter_cupertino_page_route/splash_screen.dart';

void main() {
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: Splash(),
),
);
}

class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.teal,
automaticallyImplyLeading: false,
title: Text("Flutter CupertinoPageRoute Demo"),
),
body: Container(
child: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset("assets/logo.png",width: 300,),
SizedBox(height: 70,),
ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: TextStyle(fontSize: 20),
minimumSize: Size.fromHeight(40),
primary: Colors.teal,
),
onPressed: () => Navigator.of(context).push(SecondPage.route()),
child: Text("Home Page")
),
],
),
),

),
),
);
}
}

class SecondPage extends StatelessWidget {
static Route<dynamic> route() {
return CupertinoPageRoute(
builder: (BuildContext context) {
return SecondPage();
},
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.teal,
title: Text("Second Page"),
),
body: Container(
child: Center(
child: Text("Welcome to Flutter Dev's", style: TextStyle(fontSize: 30),),
),
),
);
}
}

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the CupertinoPageRoute in your flutter projects. We will show you what the CupertinoPageRoute is?. Show constructor and properties of the CupertinoPageRoute. Make a demo program for working CupertinoPageRoute. In this blog, we have examined the CupertinoPageRoute of the flutter app. I hope this blog will help you in the comprehension of the CupertinoPageRoute in a better way. So please try it.

❤ ❤ Thanks for reading this article ❤❤

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

Clap 👏 If this article helps you.


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: Handling Navigation Stacks

Related: Flutter Deep Links – A unique way!

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


App Lifecycle In Flutter

0

Knowing the basics of Flutter is the most significant and commendable speculation you can do while learning Flutter. You ought to consistently know how the application lifecycle is created, rendered, updated, and destroyed as it will assist you with understanding your code!. Similarly, as with each structure out there, Flutter likewise has a lifecycle related to each application.

We will likewise explore how to observe orientation change in our application. At last, we will perceive how to reuse the lifecycle rationale so all the lifecycle strategies are accessible across our application.

In this blog, we will explore the App Lifecycle In Flutter. We will likewise explore the distinctive application lifecycle strategies accessible in flutter and use them in your flutter applications.



Lifecycle of Flutter App:

The lifecycle of the Flutter App is the show of how the application will change its State. It helps in understanding the idea driving the smooth progression of our applications. Everything in Flutter is a Widget, so before thinking about Lifecycle, we should think about Widgets in Flutter.

Flutter has majorly two types of widgets:

  • Stateless Widgets
  • Stateful Widgets

Before thinking about the Lifecycle, we need to comprehend the distinction between the two widgets.

Stateless Widgets:

Stateless Widgets are those widgets that don’t need to deal with the State as they don’t change powerfully at runtime. It becomes permanent like on variables, buttons, symbols, and so forth, or any express that can’t be changed on the application to recover information. Returns a widget by overwriting the build method. We use it when the UI depends on the data inside the actual item.

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container();
}
}

Stateful Widgets:

Stateful Widgets are those widgets that hold the State and the UI being portrayed can change progressively at runtime. It is a changeable widget, so it is attracted numerous times during its lifetime.

We utilize this when the user progressively updates the application screen. This is the most significant of the multitude of widgets, as it has state widgets, everybody realizes that something has been updated on our screen.

import 'package:flutter/material.dart';

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

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

class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return Container();
}
}

Thus, as we are examining the LifeCycle of Flutter, we will focus on ‘Stateful Widgets’ as they need to deal with the State.

Diagram For Lifecycle Of Flutter App

Stages Of App Lifecycle:

The life cycle depends on the state and how it changes. A stateful widget has a state so we can clarify the life cycle of flutter dependent on it. Stage of the life cycle:

  • createState()
  • initState()
  • didChangeDependencies()
  • build()
  • didUpdateWidget()
  • setState()
  • deactivate()
  • dispose()

Let deeply explain on Stage of the life cycle:

> createState()

This method is called when we create another Stateful Widget. It is an obligatory strategy. The createState() returns a case of a State-related with it.

class HomeScreen extends StatefulWidget {

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

@override
HomeScreenState<StatefulWidget> createState() => HomeScreen();
}

> initState()

This is the strategy that is considered when the Widget is made interestingly and it is called precisely once for each State object. If we characterize or add some code in the initState() method this code will execute first even before the widgets are being built.

This method needs to call super.initState() which essentially calls the initState of the parent widget (Stateful widget). Here you can initialize your variables, objects, streams, AnimationController, and so on.

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

didChangeDependencies()

This method is called following the initState() method whenever the widget initially is constructed. You can incorporate not many functionalities like API calls dependent on parent data changes, variable re-initializations, and so forth.

@override
void didChangeDependencies() {

}

build()

This strategy is the main method as the rendering of all the widgets relies upon it. It is called each time when we need to render the UI Widgets on the screen.

At whatever point you need to update your UI or on the other hand on the off chance that you click hot-reload, the Flutter structure modifies the build() strategy!. Assuming you need to expressly revamp the UI if any information is transformed, you can utilize setState() which teaches the framework to again run the form method!

@override
Widget build(BuildContext context) {
return Scaffold()
}

didUpdateWidget()

This strategy is utilized when there is some adjustment of the configuration by the Parent widget. It is essentially called each time we hot reload the application for survey the updates made to the widget

If the parent widget changes its properties or designs, and the parent needs to modify the child widget, with a similar Runtime Type, then, at that point, didUpdateWidget is triggered. This withdraws to the old widget and buys into the arrangement changes of the new widget!.

@protected
void didUpdateWidget(Home oldWidget) {
super.didUpdateWidget(oldWidget);
}

setState()

The setState() method illuminates the framework that the internal state of this item has changed in a manner that may affect the UI which makes the structure plan a build for this State of the object.

It is an error to call this method after the system calls dispose(). This inside state could conceivably influence the UI apparent to the user and subsequently, it becomes important to rebuild the UI.

void function(){
setState(() {});
}

deactivate()

This method is considered when the State is removed out from the tree, however, this strategy can be additionally be re-embedded into the tree in another part.

This strategy is considered when the widget is as of now not joined to the Widget Tree yet it very well may be appended in a later stage. The best illustration of this is the point at which you use Navigator. push to move to the following screen, deactivate is called because the client can move back to the past screen and the widget will again be added to the tree!.

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

dispose()

This strategy is essentially something contrary to the initState() method and is likewise important. It is considered when the object and its State should be eliminated from the Widget Tree forever and won’t ever assemble again.

Here you can unsubscribe streams, cancel timers, dispose animations controllers, close documents, and so on. At the end of the day, you can deliver every one of the assets in this strategy. Presently, later on, if the Widget is again added to Widget Tree, the whole lifecycle will again be followed!.

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

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the App Lifecycle in your flutter projects. We will show you what the Lifecycle of the Flutter App is?. In this blog, we have examined the lifecycle of the flutter app. I hope this blog will help you in the comprehension of the Lifecycle in a superior way. So please try it.

❤ ❤ Thanks for reading this article ❤❤

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

Clap 👏 If this article helps you.


From Our Parent Company Aeologic

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

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

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

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

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

Related: SMS Using Twilio In Flutter

Related: Using SharedPreferences in Flutter

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


Explore AnimatedBuilder Widget In Flutter

0

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 AnimatedBuilder Widget In Flutter. We will also implement a demo program of AnimatedBuilder Widget and how to use it in your flutter applications.

Table Of Contents::

What is AnimatedBuilder Widget?

Constructor

Properties

Code Implement

Code File

Conclusion



What is AnimatedBuilder Widget?:

AnimatedBuilder Widget is a universally useful widget for building animations. AnimatedBuilder Widget is helpful for more complex widgets that wish to incorporate animation as a component of a larger build function. To utilize AnimatedBuilder, just develop the widget and pass it a builder function.

AnimatedBuilder, a widget that utilizes a builder callback to reconstruct at whatever point a given Listenable triggers its notifications. This widget is regularly utilized with Animation subclasses, henceforth its name, however, is in no way restricted to animations, as it very well may be utilized with any Listenable. It is a subclass of AnimatedWidget, which can be utilized to make widgets that are driven from a Listenable.

To get a more understanding through the help of video , Please watch:

Constructor:

To utilize AnimatedBuilder, you need to call the constructor underneath:

AnimatedBuilder({
Key? key,
required Listenable animation,
required this.builder,
this.child,
})

There are two-argument fields marked with required must not be empty.

Properties:

  • > Key: This property is used to represent how one widget should replace another widget in a tree.
  • > builder: This property is used to call whenever animation changes its value.
  • > animation: This property is utilized to animation is an item that keeps a list of listeners. The listeners are regularly used to notify clients that the item has been updated.
  • > child: This property is utilized as the widget to pass to the builder. On the off chance that a builder callback’s return esteem contains a subtree that doesn’t rely upon the animation, it’s more proficient to assemble that subtree once as opposed to revamping it on each animation tick. If the pre-constructed subtree is passed as the child boundary, the AnimatedBuilder will pass it back to the builder function so it tends to be used in the build. Utilizing this pre-assembled child is altogether discretionary, however can further develop execution essentially sometimes and is, thusly, a decent practice.

There are two variants of this interface:

  • > ValueListenable, an interface that augments the Listenable interface with the concept of current value.
  • > Animation, an interface that augments the ValueListenable interface to add the concept of direction forward or reverse direction.

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 Stateful widget and the respective State class has to use SingleTickerProviderStateMixin.

class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
with SingleTickerProviderStateMixin {
}

To make the progress, we need to make a case of AnimationController and inside the StatefulWidget.

AnimationController _controller;

In initState() method, we will add _controller ie equal to the AnimationController(). Inside AnimationController, we will add duration will be 8seconds. Also, we will add vsyn, value, and repeat.

@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(seconds: 8),
vsync: this,
)..repeat();
}

In the body, we will add AnimatedBuilder() widget. In this widget, we will add an animation means an object that maintains a list of listeners. We will add _controller variable. It’s child property, we will add a Container widget. Inside the widget, we will add height, widget, and an image.

AnimatedBuilder(
animation: _controller,
child: Container(
width: 300.0,
height: 200.0,
child: Image.asset("assets/logo.png"),
),
builder: (BuildContext context, Widget child) {
return Transform.rotate(
angle: _controller.value * 2.2 * math.pi,
child: child,
);
},
),

In AnimatedBuilder() widget, we will also add builder means call whenever animation changes its value. We will pass two parameters in the bracket that was BuildContext contextWidget child. We will return a Transform.rotate() widget. In this widget, we will add angle means that give the rotation clockwise. We will add _controller.value * 2.2 * math.pi. Also, add a child. When we run the application, we ought to get the screen’s output like the underneath screen video.

Code Files:

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

import 'package:flutter_animated_builder_demo/splash_screen.dart';

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

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Splash(),
);
}
}

class AnimatedBuilderDemo extends StatefulWidget {
@override
_AnimatedBuilderDemoState createState() => _AnimatedBuilderDemoState();
}

class _AnimatedBuilderDemoState extends State<AnimatedBuilderDemo>
with SingleTickerProviderStateMixin {

AnimationController _controller;

@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(seconds: 8),
vsync: this,
)..repeat();
}

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

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.cyan,
automaticallyImplyLeading: false,
title: Text("Flutter AnimatedBuilder Widget Demo"),
),
body: Center(
child: AnimatedBuilder(
animation: _controller,
child: Container(
width: 300.0,
height: 200.0,
child: Image.asset("assets/logo.png"),
),
builder: (BuildContext context, Widget child) {
return Transform.rotate(
angle: _controller.value * 2.2 * math.pi,
child: child,
);
},
),
),
);
}
}

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the AnimatedBuilder Widget in your flutter projects. We will show you what the AnimatedBuilder Widget is?. Show a constructor and properties of the AnimatedBuilder Widget. Make a demo program for working AnimatedBuilder 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.


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: Using AnimatedPositioned Widget In Flutter

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


Show/Hide Widget In Flutter

0

It has a visible property that oversees whether the child is remembered for the widget subtree or not. At the point when it is set to false, the replacement child for the most part a zero-sized box has incorporated all things being equal.

In this blog, we will explore the Show/Hide Widget In Flutter. We will see how to implement a demo program and we will see how we can change the visibility of widgets and how to show or hide widgets in Flutter using Visibility Widget in your flutter applications.

Visibility class – widgets library – Dart API
Whether to show or hide a child. By default, the visible property controls whether the child is included in the subtree…api. flutter.dev

Table Of Contents::

Introduction

Constructor

Properties

Code Implement

Code File

Conclusion



Introduction:

Here and there, you might need to make a widget possibly displayed in specific conditions and hidden if the condition doesn’t meet. In Flutter, it tends to be done effectively utilizing Visibility a widget.

The widget you need to show or hide must be the child of Visibility widget. In the constructor, pass visibility alternative whose value is a boolean and is put away as the state. Then, at that point, update the value to show or hide the child.

Demo Module :


Constructor:

To utilize Visibility, you need to call the constructor underneath:

const Visibility({
Key? key,
required this.child,
this.replacement = const SizedBox.shrink(),
this.visible = true,
this.maintainState = false,
this.maintainAnimation = false,
this.maintainSize = false,
this.maintainSemantics = false,
this.maintainInteractivity = false,
})

There is one contention you need to pass, child . child is the show or hide, as controlled by visible.

Properties:

There are some properties of Visibility are:

  • > child: This property is used to the widget that will be shown or hidden depending on visibility value.
  • > maintainAnimation: This property is used to whether to maintain the child‘s animations if it becomes not visible. Default is false.
  • > visible: This property is used to control whether the child is shown or not. Default is true.
  • > replacement: This property is used to the widget that will be shown if the child is not visible. Default is SizedBox.shrink.
  • > maintainState: This property is used whether to maintain the child‘s state if it becomes not visible. Default is false.
  • > maintainInteractivity: This property is used whether to allow the widget to be interactive when hidden. Default is false.
  • > maintainSemantics: This property is used whether to maintain the semantics for the widget when it is hidden. Default is false.
  • > maintainSize: This property is used whether to maintain space for where the widget would have been. Default is false.

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.

First, we will create a bool variable that was bool _isVisible is equal to true.

bool _isVisible = true;

We will create a showToast() method. In this method, we will add setState() function. We will add _isVisible is equal to !_isVisible.

void showToast() {
setState(() {
_isVisible = !_isVisible;
});
}

In the body, we will add the Visibility() widget. In this widget, we will add visible which means control whether the child is shown or not. We will add variable _isVisible. It’s child property, we will add an image with height and BoxFit.contain.

Visibility(
visible: _isVisible,
child: Image.asset("assets/logo.png",
height: 300,
fit: BoxFit.contain,
),
),

We will also add Text and ElevatedButton(). In this button, we will add style, onPressed, and text. We will add showToast on the onPressed method.

Text("FlutterDevs is a protruding flutter app development company with an extensive "
"in-house team of 30+ seasoned professionals who know exactly what you need "
"to strengthen your business across various dimensions. With more than 10+ years "
"of experience in mobile applications, we know your needs very well."
,style: TextStyle(fontSize: 20)
),
SizedBox(height: 35,),
ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: TextStyle(fontSize: 20),
minimumSize: Size.fromHeight(50),
),
onPressed: showToast,
child: Text("Show/Hide")
),

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

Output

Code File:

import 'package:flutter/material.dart';
import 'package:flutter_visibility_widget_demo/splash_screen.dart';

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

class MyApp extends StatelessWidget {

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

class ShowHideDemo extends StatefulWidget {
@override
_ShowHideDemoState createState() {
return _ShowHideDemoState();
}
}

class _ShowHideDemoState extends State {
bool _isVisible = true;

void showToast() {
setState(() {
_isVisible = !_isVisible;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.cyan,
title: Text('Flutter Show/Hide Widget Demo'),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Visibility(
visible: _isVisible,
child: Image.asset("assets/logo.png",
height: 300,
fit: BoxFit.contain,
),
),
Text("FlutterDevs is a protruding flutter app development company with an extensive "
"in-house team of 30+ seasoned professionals who know exactly what you need "
"to strengthen your business across various dimensions. With more than 10+ years "
"of experience in mobile applications, we know your needs very well."
,style: TextStyle(fontSize: 20)
),
SizedBox(height: 35,),
ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: TextStyle(fontSize: 20),
minimumSize: Size.fromHeight(50),
),
onPressed: showToast,
child: Text("Show/Hide")
),
],
),
),
);
}
}

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the Show/Hide Widget in your flutter projects. We will show you what the Introduction is?. Show a constructor and properties of the Show/Hide Widget. Make a demo program for working Show/Hide Widget using Visibility 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.


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 IntrinsicWidth In Flutter

0

At whatever point you will code for building anything in Flutter, it will be inside a widget. The focal design is to construct the application out of widgets. It depicts how your application view should look with their present configuration and state. At the point when you made any modification in the code, the widget modifies its portrayal by working out the contrast between the past and current widget to decide the insignificant changes for delivering in the UI of the application.

In this blog, we will be Explore IntrinsicWidth In Flutter. We will see how to implement an IntrinsicWidth demo program and show how to use it in your flutter applications.

IntrinsicWidth class – widgets library – Dart API
A widget that sizes its child to the child’s maximum intrinsic width. This class is useful, for example, when unlimited…api. flutter.dev

Table Of Contents::

Introduction

Constructor

Properties

Code Implement

Code File

Conclusion



Introduction:

IntrinsicWidth is a widget that estimates its child to the child’s intrinsic width. It tends to be helpful if the accessible width is limitless, however you need to set the size of a widget to its intrinsic width.

IntrinsicWidth is when limitless width is free and clients might want a child that would somehow endeavor to expand endlessly to rather estimate itself to a more sensible width.

Constructor:

There are constructor of IntrinsicWidth are:

const IntrinsicWidth({ 
Key key,
this.stepWidth,
this.stepHeight,
Widget child
})

Properties :

There are some properties of IntrinsicWidth are:

  • > key: The widget key, used to control if it should be replaced.
  • > stepWidth: This property will force its child’s width to Multiple of this Value. This value must be null or > 0.0.
  • > stepHeight: This property will set a child’s height to be multiple of this Value. If null or 0.0 the child’s height will not be constrained. Its value must not be negative.
  • > child: This Property represents a widget under the current widget in a tree. Child widgets have only one child. To the user, multiple children users can make use of Column WidgetRow WidgetStack Widget and provide children to that widget.

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 should begin with a model where there is a Column widget with the crossAxisAlignment sets to stretch. It has two Container widgets as its children with the second container are wrapped as the child of an Expanded widget. That implies the height of the second container will be extended to the most maximum space. For the width of the Column, since it utilizes CrossAxisAlignment.stretch, it will likewise be expanded to the most maximum space.

final Widget data = Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
width: 200,
height: 100,
color: Colors.cyan,
),
Expanded(
child: Container(
width: 100,
height: 100,
color: Colors.orange,
),
),
],
);

In the body, we will add IntrinsicWidth() widget. In this widget, we will add the only stepWidth is of 300 and add child property as data.

IntrinsicWidth(
stepWidth: 300,
child: data,
),

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

Using stepWidth

Then, we will set the stepHeight argument to 300. In the past models where the stepHeight isn’t passed, the height of the child expands to occupy the maximum space. Bypassing the stepWidth argument, the height of the child will be set to a base value that is a multiplication of the stepHeight.

IntrinsicWidth(
stepHeight: 300,
child: data,
),

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

Using stepHeight

Utilizing IntrinsicWidth is considered costly due to the need to add a speculative design pass before the final layout phase. Hence, the utilization of IntrinsicWidth ought to be kept away from if conceivable. For the above cases, you can consider utilizing a widget that can be utilized to add limitations to the child, like SizedBox or ConstrainedBox.

Remember that the imperatives applied by IntrinsicWidth the widget should agree with the constraints of the parent. In this way, the child’s width can be not as much as its intrinsic width if the most extreme width limitation from the parent isn’t sufficiently huge. Similarly, the child’s width can be bigger than its inherent width if the base width requirement is bigger than the intrinsic width.

IntrinsicWidth(
stepWidth: 300,
stepHeight: 300,
child: data,
),

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';

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

class MyApp extends StatelessWidget {

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

class _IntrinsicWidthDemo extends StatelessWidget {

final Widget data = Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
width: 200,
height: 100,
color: Colors.cyan,
),
Expanded(
child: Container(
width: 100,
height: 100,
color: Colors.orange,
),
),
],
);

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.teal,
title: Text('Flutter IntrinsicWidth Demo'),
),
body: IntrinsicWidth(
stepWidth: 300,
stepHeight: 300,
child: data,
),
);
}
}

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the IntrinsicWidth in your flutter projects. We will show you what the Introduction is?. Show constructor and properties of the IntrinsicWidth. Make a demo program for working IntrinsicWidth and you can likewise pass stepWidth as well as stepHeight contentions to drive the width and additionally the height of the child to be a multiplication of the given values. 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.

Related: Explore Exception Handling In Flutter

Related: Explore Dart String Interpolation

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


ScaleTransition Widget In Flutter

0

Animation is an exceptionally incredible and significant idea in Flutter. We can’t envision any mobile application without animations. At the point when you tap on a button or move starting with one page then onto the next page are for the most part animations. Animations upgrade user encounters and make the applications more interactive.

In this article, we will explore the ScaleTransition Widget In Flutter. We will execute a demo program of the scale transition and show you how to create scale transition in your flutter applications.

ScaleTransition class – widgets library – Dart API
Animates the scale of a transformed widget.api.flutter.dev

Table Of Contents::

ScaleTransition Widget

Constructor

Properties

Code Implement

Code File

Conclusion



ScaleTransition Widget:

At times, we might have to show animation when a widget is being shown. Assuming you need it to seem more modest first and afterward it expands steadily, you can utilize ScaleTransition.

This is only the widget that will animate itself while being drawn. It requires the scale parameter to be passed while the other two parameters — alignment and child are discretionary.

Constructor:

To utilize ScaleTransition, you need to call the constructor underneath:

const ScaleTransition({
Key key,
@required Animation<double> scale,
this.alignment = Alignment.center,
this.child,
})

In the Above Constructor, all attributes marked with @required must not be empty.

Properties:

There are some properties of ScaleTransition are:

  • >Key: This property is used to show how one widget should replace another widget in a tree.
  • > Animation<double> scale: This property will be the animation that controls the scale of the child. On the off chance that the current value of the scale animation is v, the child will be painted v times its typical size.
  • > Alignment: This property will characterize the alignment of the beginning of the organized framework in which the scale happens, comparative with the size of the box. For instance, to set the beginning of the scale to the base center, you can utilize an arrangement of (0.0, 1.0).
  • > Child: This property is used to define the widget below this widget in the tree. This widget can only have one child. To layout multiple children, let this widget’s child be a widget such as Row WidgetColumn Widget, or Stack Widget, which have a children’s property, and then provide the children to that widget.

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.

To make the progress, we need to make a case of AnimationController and Animation<double> inside the StatefulWidget. Remember to utilize it with TickerProviderStateMixin while making Animation in Flutter App.

AnimationController _controller;
Animation<double> _animation;

In initState() method, we will add _controller ie equal to the AnimationController(). Inside AnimationController, we will add duration will be 2 seconds. Also, we will add vsyn, value, and repeat(reverse: true). In this method, we will add _animation is equal to the CurvedAnimation(). Inside, we will add parent and curve.

initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(
seconds: 2,
),
vsync: this,
value: 0.1,
)..repeat(reverse: true);
_animation = CurvedAnimation(
parent: _controller,
curve: Curves.bounceIn,
);
}

We need to dispose of the controller like underneath:

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

In the body, we will add ScaleTransition() widget. In this widget, we will add scale means animation that controls the scale of the child. We will add _animation variable. We will add alignment as the center. It’s child property, we will add Row() widget. Inside the widget, we will add mainAxisAlignment and crossAxisAlignment was center. Also, we will add an image with height.

ScaleTransition(
scale: _animation,
alignment: Alignment.center,
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset("assets/logo.png",height: 150,),
],
),
),
),

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

Code File:

import 'package:flutter/material.dart';
import 'package:flutter/animation.dart';
import 'package:flutter_scale_transition_demo/splash_screen.dart';

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

class MyApp extends StatelessWidget {

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


class ScaleTransitionWidgetDemo extends StatefulWidget {
_ScaleTransitionWidgetDemoState createState() => _ScaleTransitionWidgetDemoState();
}

class _ScaleTransitionWidgetDemoState extends State<ScaleTransitionWidgetDemo>
with TickerProviderStateMixin {
AnimationController _controller;
Animation<double> _animation;

initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(
seconds: 2,
),
vsync: this,
value: 0.1,
)..repeat(reverse: true);
_animation = CurvedAnimation(
parent: _controller,
curve: Curves.bounceIn,
);
}

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

Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.teal,
automaticallyImplyLeading: false,
title: Text("Flutter ScaleTransition Widget Demo"),
),
body: Container(
child: ScaleTransition(
scale: _animation,
alignment: Alignment.center,
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset("assets/logo.png",height: 150,),
],
),
),
),
),
);
}
}

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the ScaleTransition Widget in your flutter projects. We will show you what the ScaleTransition Widget is?. Show a constructor and properties of the ScaleTransition Widget. Make a demo program for working ScaleTransition 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.


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.


LongPressDraggable In Flutter

0

A Draggable Widget permits a widget to be dragged, a DragTarget gives an objective to the draggable. A widget that can be dragged from to a DragTarget Widget.

At the point when a draggable widget perceives the beginning of a drag gesture, it shows a feedback widget that tracks the client’s finger across the screen. On the off chance that the user lifts their finger while on top of a DragTarget, that target is offered the chance to accept the data conveyed by the draggable.

In this article, we will explore the LongPressDraggable In Flutter. We will execute a demo program of the LongPressDraggable and how to create a widget that can be dragged beginning from a long press utilizing LongPressDraggable it in your flutter applications.

Table Of Contents::

LongPressDraggable

Constructor

Properties

Code Implement

Code File

Conclusion



LongPressDraggable:

It is utilized to makes a widget that can be dragged beginning from LongPress. On the off chance that you need to make a widget draggable after the client plays out a long press on it, Flutter has a widget for that reason. LongPressDraggable is a widget that permits its child to be dragged beginning from a long press. What you need to do is wrap the draggable widget as the child of the LongPressDraggable widget.

Demo Module :

This demo video shows how to use LongPressDraggable in a flutter. It shows how LongPressDraggable will work in your flutter applications. It tells you the best way to utilize it, including how to set the dragging axis, set the child to show while dragging, add data to the draggable, just as handle events. It will be shown on your device.

Constructor:

To utilize LongPressDraggable, you need to call the constructor underneath:

const LongPressDraggable({
Key? key,
required Widget child,
required Widget feedback,
T? data,
Axis? axis,
Widget? childWhenDragging,
Offset feedbackOffset = Offset.zero,
DragAnchor dragAnchor = DragAnchor.child,
int? maxSimultaneousDrags,
VoidCallback? onDragStarted,
DragUpdateCallback? onDragUpdate,
DraggableCanceledCallback? onDraggableCanceled,
DragEndCallback? onDragEnd,
VoidCallback? onDragCompleted,
this.hapticFeedbackOnStart = true,
bool ignoringFeedbackSemantics = true,
})

There are two contentions you need to pass, child and feedbackchild is the widget that can be dragged beginning from a long press. You likewise need to characterize the widget to be displayed under the pointer during a drag as feedback.

Properties:

There are some properties of LongPressDraggable are:

  • > Key: This property is used to controls how one widget replaces another widget in the tree.
  • > child: This property is used to the widget below this widget is in the tree.
  • > feedback: This property is used to shows the widget to show under the pointer when a drag is underway.
  • > data: This property is used for the data that will be dropped by this draggable.
  • > Axis: This property is used Axis to restrict this draggable’s movement if specified.
  • > childWhenDragging: This property is utilized regarding the widget to show rather than a child when at least one drags are in progress.
  • > feedbackOffset: This property is utilized to set the hit test target point for finding a drags target. Defaults to Offset.zero
  • > dragAnchor: This property is utilized to where this widget should be anchored during a drag.
  • > maxSimultaneousDrags: How many simultaneous drag to support. When null, no limit is applied. Set this to 1 if you want to only allow the drag source to have one item dragged at a time. Set this to 0 if you want to prevent the draggable from actually being dragged.
  • > onDragStarted: This property is called when a drag is started on a widget.
  • > onDraggableCanceled: This property is called when a drag is started on a widget. called when the draggable is dropped without being accepted by a DragTarget Widget.
  • > onDragCompleted: When a draggable is dragged to a DragTarget Widget and accepted, this callback is called. We have a separate article for it. Users can read it from DragTarget Widget.
  • > hapticFeedbackOnStart: Whether haptic feedback should be triggered on drag start.
  • > ignoringFeedbackSemantics: Whether the semantics of the feedback widget is ignored when building the semantics tree.

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.

First, we will create a variable of Offset that is equal to Offset(100,250). Generally, Offset(dy, dx) will be zero.

Offset _offset = Offset(100,250);

In the body, we will add LayoutBuilder() widget. In this widget, we will add a builder and pass argument context, constraints in the bracket. Then, we will return a Stack() widget. We will add Positioned() widget. Inside we will add left define _offset. dx and top define _offset.dy.

LayoutBuilder(
builder: (context, constraints) {
return Stack(
children: [
Positioned(
left: _offset.dx,
top: _offset.dy,
child: LongPressDraggable(
feedback: Image.asset("assets/logo.png",height: 100,color: Colors.cyan,),
child: Image.asset("assets/logo.png",height: 100,),
onDragEnd: (details) {
setState(() {
final adjustment = MediaQuery.of(context).size.height -
constraints.maxHeight;
_offset = Offset(
details.offset.dx, details.offset.dy - adjustment);
});
},
),
),
],
);
},
),

It’s child property, we will add LongPressDraggable() widget. In this widget, we will add feedback means the widget to show under the pointer when a drag is underway and we will add an image with height and color. Then, add child which means the widget below this widget is in the tree. Also, add onDragEnd means called when the draggable is dropped. We will add setState() method. Inside, we will add final adjustment is equal to height minus max height, and _offset is equal to Offset(details. offset. dx, details.offset.dy — adjustment).

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';
import 'package:flutter/rendering.dart';
import 'package:flutter_longpressdraggable_dem/splash_screen.dart';

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

class MyApp extends StatelessWidget {

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

class LongPressDraggableDemo extends StatefulWidget {

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

class _LongPressDraggableDemoState extends State<LongPressDraggableDemo> {

Offset _offset = Offset(100,250);

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: Text('Flutter LongPressDraggable Demo '),
),
body: Center(
child: LayoutBuilder(
builder: (context, constraints) {
return Stack(
children: [
Positioned(
left: _offset.dx,
top: _offset.dy,
child: LongPressDraggable(
feedback: Image.asset("assets/logo.png",height: 100,color: Colors.cyan,),
child: Image.asset("assets/logo.png",height: 100,),
onDragEnd: (details) {
setState(() {
final adjustment = MediaQuery.of(context).size.height -
constraints.maxHeight;
_offset = Offset(
details.offset.dx, details.offset.dy - adjustment);
});
},
),
),
],
);
},
),
),
);
}
}

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the LongPressDraggable in your flutter projects. We will show you what the LongPressDraggable is?. Show a constructor and properties of the LongPressDraggable. To make a widget draggable after the user plays out a long press, you can wrap it as the child of LongPressDraggable. Thusly, you are likewise needed to characterize a widget to be displayed under the pointer during a drag. You can likewise pass a few callback works that will be considered when certain events happen. 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.

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.