Google search engine
Home Blog Page 17

Password Strength Checker In Flutter

0

Flutter just intrigued me with the pleasant UI stuff you could do effectively, and obviously, it permits you to create for both platforms simultaneously. The focal reason for existing is to construct the application out of widgets. It portrays how your application view should look with their present setup and state. When you modify 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 this blog, we will explore the Password Strength Checker In Flutter. We will implement a demo program and create a Password Strength Checker without using any third-party plugins in your flutter applications.

Table Of Contents ::

Introduction

Code Implement

Code File

Conclusion



Introduction:

The below demo video shows how to create a password strength checker in a flutter. It shows how the password strength checker will work without using any third-party plugins in your flutter applications. When the user enters the password on the text field, then they will show your password was strong, weak, great, and not acceptable, etc. Also, the linear progress bar was shown with different colors. It will be shown on your device.

Demo Module :


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 late String _password variable, the double _strength variable is equal to zero, and the String _displayText variable is equal to the text ‘Please enter a password.’

late String _password;
double _strength = 0;
String _displayText = 'Please enter a password'

Now, we will add RegExp for number and letter

RegExp numReg = RegExp(r".*[0-9].*");
RegExp letterReg = RegExp(r".*[A-Za-z].*");

In the body, we will add the TextField() method. In this method, we will add onChanged navigate to _checkPassword(value). We will deeply describe it below. Also, we will add obscureText was true, hintText was ‘Password’.

TextField(
onChanged: (value) => _checkPassword(value),
obscureText: true,
decoration: const InputDecoration(
border: OutlineInputBorder(), hintText: 'Password',
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12.0)),
borderSide: BorderSide(color: Colors.teal),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12.0)),
borderSide: BorderSide(color: Colors.teal),
),),
),

In the body, we will add the LinearProgressIndicator widget. In this widget, we will add a value that was _strength variable. It will change colors according to _strength variable conditions.

LinearProgressIndicator(
value: _strength,
backgroundColor: Colors.grey[300],
color: _strength <= 1 / 4
? Colors.red
: _strength == 2 / 4
? Colors.yellow
: _strength == 3 / 4
? Colors.blue
: Colors.green,
minHeight: 15,
),

Now, we will add text was _displayText variable and add ElevatedButton() widget. In this widget, we will add the onPressed method. The button will be enabled in this method if the password strength is medium or beyond and add text ‘Continue’.

Text(
_displayText,
style: const TextStyle(fontSize: 18),
),
const SizedBox(
height: 50,
),
ElevatedButton(
onPressed: _strength < 1 / 2 ? null : () {},
child: const Text('Continue'))

Now, we will deeply describe _checkPassword(value):

We will add _password variable was equal to value. trim().

_password = value.trim();

If the password was empty and add it inside the setState() method. In this method, _strength was equal to zero and _displayText was ‘Please enter your password.’

if (_password.isEmpty) {
setState(() {
_strength = 0;
_displayText = 'Please enter you password';
});
}

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

Password Empty

If the password was 6 characters less than in length, then it was weak, and add it inside the setState() method. In this method, _strength was equal to 1/4 and _displayText was ‘Your password is too short’.’

else if (_password.length < 6) {
setState(() {
_strength = 1 / 4;
_displayText = 'Your password is too short';
});
}

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

Password Short

If the password was 6 characters to less than 8 characters in length, then it was acceptable but not strong, and add it inside the setState() method. In this method, _strength was equal to 2/4 and _displayText was ‘Your password is acceptable but not strong.’

else if (_password.length < 8) {
setState(() {
_strength = 2 / 4;
_displayText = 'Your password is acceptable but not strong';
});
}

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

Password is Acceptable but not Strong

If the password was greater than equal to 8 characters in length, and but doesn’t contain both letters and digit characters, then it was strong, and add it inside the setState() method. In this method, _strength was equal to 3/4 and _displayText was ‘Your password is strong.’

if (!letterReg.hasMatch(_password) || !numReg.hasMatch(_password)) {
setState(() {
// Password length >= 8
// But doesn't contain both letter and digit characters
_strength = 3 / 4;
_displayText = 'Your password is strong';
});
}

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

Password Strong

If the password was greater than equal to 8 characters in length, and Password contains both letters and digit characters, then it was great, and add it inside the setState() method. In this method, _strength was equal to 1 and _displayText was ‘Your password is great.’

else {
// Password length >= 8
// Password contains both letter and digit characters
setState(() {
_strength = 1;
_displayText = 'Your password is great';
});
}

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

Password Great

Code File:

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

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

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
// Hide the debug banner
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.teal,
),
home: Splash(),
);
}
}

class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);

@override
State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
late String _password;
double _strength = 0;

RegExp numReg = RegExp(r".*[0-9].*");
RegExp letterReg = RegExp(r".*[A-Za-z].*");

String _displayText = 'Please enter a password';

void _checkPassword(String value) {
_password = value.trim();

if (_password.isEmpty) {
setState(() {
_strength = 0;
_displayText = 'Please enter you password';
});
} else if (_password.length < 6) {
setState(() {
_strength = 1 / 4;
_displayText = 'Your password is too short';
});
} else if (_password.length < 8) {
setState(() {
_strength = 2 / 4;
_displayText = 'Your password is acceptable but not strong';
});
} else {
if (!letterReg.hasMatch(_password) || !numReg.hasMatch(_password)) {
setState(() {
// Password length >= 8
// But doesn't contain both letter and digit characters
_strength = 3 / 4;
_displayText = 'Your password is strong';
});
} else {
// Password length >= 8
// Password contains both letter and digit characters
setState(() {
_strength = 1;
_displayText = 'Your password is great';
});
}
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: const Text('Flutter Password Strength Checker Demo'),
),
body: Padding(
padding: const EdgeInsets.all(30),
child: Column(
children: [
TextField(
onChanged: (value) => _checkPassword(value),
obscureText: true,
decoration: const InputDecoration(
border: OutlineInputBorder(), hintText: 'Password',
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12.0)),
borderSide: BorderSide(color: Colors.teal),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12.0)),
borderSide: BorderSide(color: Colors.teal),
),),
),
const SizedBox(
height: 30,
),
// The strength indicator bar
LinearProgressIndicator(
value: _strength,
backgroundColor: Colors.grey[300],
color: _strength <= 1 / 4
? Colors.red
: _strength == 2 / 4
? Colors.yellow
: _strength == 3 / 4
? Colors.blue
: Colors.green,
minHeight: 15,
),
const SizedBox(
height: 20,
),

// The message about the strength of the entered password
Text(
_displayText,
style: const TextStyle(fontSize: 18),
),
const SizedBox(
height: 50,
),
// This button will be enabled if the password strength is medium or beyond
ElevatedButton(
onPressed: _strength < 1 / 2 ? null : () {},
child: const Text('Continue'))
],
),
));
}
}

Conclusion:

In the article, I have explained the basic structure of the Password Strength Checker in a flutter; you can modify this code according to your choice. This was a small introduction to Password Strength Checker 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 Password Strength Checker in your flutter projects. We will show you what the Introduction is?. Make a demo program for working Password Strength Checker without using any third-party plugins. In this blog, we have examined the Password Strength Checker of the flutter app. I hope this blog will help you in the comprehension of the Password Strength Checker 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.


Draggable GridView In Flutter

0

Draggable GridView is a regular mobile application connection. As the user presses now and again called touch and holds on a widget, another widget appears under the user’s finger, and the user draggable the widget to the last region and conveyances it. On multitouch devices, different draggable can happen at the same time because that there can be various pointers in touch with the devices immediately.

In this article, we will explore the Draggable GridView In Flutter. We will implement a draggable grid view demo program and create a draggable of the GridViewItems using the flutter_draggable_gridview package in your flutter applications.

Table Of Contents::

Draggable GridView

Constructor

Properties

Implementation

Code Implement

Code File

Conclusion



Draggable GridView:

Draggable GridView expands the convenience of the GridView widget in Flutter and offers you the chance of making a reorder of the GridViewItems clear by Draggable. It is too easy to even consider executing and superb to use.

Demo Module :

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

Constructor:

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

const DraggableGridViewBuilder({
Key? key,
required this.gridDelegate,
required this.listOfWidgets,
required this.dragCompletion,
this.isOnlyLongPress = true,
this.dragFeedback,
this.dragChildWhenDragging,
this.dragPlaceHolder,
this.scrollDirection = Axis.vertical,
this.reverse = false,
this.controller,
this.primary,
this.physics,
this.shrinkWrap = false,
this.padding,
this.addAutomaticKeepAlives = true,
this.addRepaintBoundaries = true,
this.addSemanticIndexes = true,
this.cacheExtent,
this.semanticChildCount,
this.dragStartBehavior = DragStartBehavior.start,
this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
this.restorationId,
this.clipBehavior = Clip.hardEdge,
})

In the above Constructor, all fields marked with @required must not be empty.

Properties:

There are some properties of DraggableGridViewBuilder are:

  • > listOfWidgets: This property is used to [listOfWidgets] will show the widgets in Gridview.builder.
  • > isOnlyLongPress: This property is used to accept ‘ true’ and ‘false’.
  • > dragFeedback: This property is used to you can set this to display the widget when the widget is being dragged.
  • > dragChildWhenDragging: This property is used to you can set this to display the widget at dragged widget original place when the widget is being dragged.
  • > dragPlaceHolder: This property is used to you can set this to display the widget at the drag target when the widget is being dragged.
  • > dragCompletion: This property is used to you have to set this callback to get the updated list.

Implementation:

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:
flutter:
sdk: flutter
flutter_draggable_gridview:

Step 2: Import

import 'package:flutter_draggable_gridview/flutter_draggable_gridview.dart';

Step 3: Add the assets

Add assets to pubspec — yaml file.

assets:
- assets/

Step 4: 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 Stateful widget and the respective State class has to use with DragFeedback, DragPlaceHolder, DragCompletion.

class MyHomePageState extends State<MyHomePage>
with DragFeedback, DragPlaceHolder, DragCompletion {
}

We will create a list of strings of an image that is equal to a List. generate().

static List<String> listOfImages =
List.generate(12, (index) => 'assets/${index + 1}.jpeg');

Now, we will create a listOf Widgets that are equal to the List. generate(). In bracket, inside we will add listOfImages.length (index), then return a Container widget. In this widget, we will add padding and its child property, we will add an Image. asset(). In bracket, we will add listOfImages[index] and Boxfit is cover.

List<Widget> listOfWidgets = List.generate(
listOfImages.length,
(index) => Container(
padding: EdgeInsets.only(
left: 4.0,
right: 4.0,
top: 8.0,
),
child: Image.asset(
listOfImages[index],
fit: BoxFit.cover,
),
),
);

In the body, we will add DraggableGridViewBuilder() widget. In this widget, we will add gridDelegate was SliverGridDelegateWithFixedCrossAxisCount(). Also add crossAxisCount was 2 and childAspectRatio. We will add listOfWidgets, dragCompletion, isOnlyLongPress, dragFeedback and dragPlaceHolder.

DraggableGridViewBuilder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 3),
),
listOfWidgets: listOfWidgets,
dragCompletion: this,
isOnlyLongPress: false,
dragFeedback: this,
dragPlaceHolder: this,
),

Now, widget feedback is used to can set this to display the widget when the widget is being dragged. We will return the container, it’s child property we will add items. child with width and height.

@override
Widget feedback(List<Widget> list, int index) {
var item = list[index] as Container;
return Container(
child: item.child,
width: 200,
height: 150,
);
}

Now, PlaceHolderWidget will use to show at drag target, when the widget is being dragged. We will return PlaceHolderWidget, it’s child property we will add a Container with white color.

@override
PlaceHolderWidget placeHolder(List<Widget> list, int index) {
return PlaceHolderWidget(
child: Container(
color: Colors.white,
),
);
}

This method, onDragAccept is used to you have to set this callback to get the updated list.

@override
void onDragAccept(List<Widget> list) {

}

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';
import 'package:flutter_draggable_gridview/flutter_draggable_gridview.dart';
import 'package:flutter_draggable_gridview_dem/splash_screen.dart';

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

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

class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);

final String title;

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

class MyHomePageState extends State<MyHomePage>
with DragFeedback, DragPlaceHolder, DragCompletion {
static List<String> listOfImages =
List.generate(12, (index) => 'assets/${index + 1}.jpeg');
List<Widget> listOfWidgets = List.generate(
listOfImages.length,
(index) => Container(
padding: EdgeInsets.only(
left: 4.0,
right: 4.0,
top: 8.0,
),
child: Image.asset(
listOfImages[index],
fit: BoxFit.cover,
),
),
);

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.cyan[200],
automaticallyImplyLeading: false,
title: Text(
widget.title,
),
),
body: DraggableGridViewBuilder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 3),
),
listOfWidgets: listOfWidgets,
dragCompletion: this,
isOnlyLongPress: false,
dragFeedback: this,
dragPlaceHolder: this,
),
);
}

@override
Widget feedback(List<Widget> list, int index) {
var item = list[index] as Container;
return Container(
child: item.child,
width: 200,
height: 150,
);
}

@override
PlaceHolderWidget placeHolder(List<Widget> list, int index) {
return PlaceHolderWidget(
child: Container(
color: Colors.white,
),
);
}

@override
void onDragAccept(List<Widget> list) {
}
}

Conclusion:

In the article, I have explained the basic structure of the Draggable GridView in a flutter; you can modify this code according to your choice. This was a small introduction to Draggable GridView 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 Draggable GridView in your flutter projects. We will show you what the Draggable GridView is?. Show constructor and properties of the Draggable GridView. Make a demo program for working Draggable GridView, and it shows draggable interaction where the user long/touch presses on a choice of item and then drags it to the picture using the draggable technique. Something like a grid view with draggable can change the position both horizontally and vertically in your flutter application. 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.


Implement Tooltip In Flutter

0

A tooltip shows a useful message when users hover, tap, or focus on a component. In Flutter, you can utilize a built-in widget named Tooltip to make tooltips effortlessly. It widget turns out to be extremely valuable when the UI of the application is too thick to even think about showing all the data at once on the screen, in a way it essentially makes the application more open.

In this blog, we will explore the Implement Tooltip In Flutter. We will see how to implement a demo program and we will see how to use Tooltip in your flutter applications.

Tooltip class – material library – Dart API
A material design tooltip. Tooltips provide text labels that help explain the function of a button or other user…api. flutter.dev

Table Of Contents::

Tooltip

Constructor

Properties

Code Implement

Code File

Conclusion



Tooltip:

A tooltip is a material design class in Flutter that gives text marks to clarify the functionality of a button or UI action. All in all, it is utilized to show extra data when the user moves or focuses over a specific widget. It expands the availability of our application. Assuming we wrap the widget with it, it is exceptionally valuable when the user long presses the widget because, all things considered, it shows up as a floating label.

There are two different ways to execute the Tooltip in a widget, the first is by utilizing the actual widget and the alternate way is restricted to certain widgets like IconButton, FloatingActionButton, and so forth which give tooltip as a property that thusly takes in a string as a parameter.

Demo Module ::

The above demo video shows how to use Tooltip in a flutter. It shows how Tooltip will work in your flutter applications. It shows when the user tap log pressed on the image, then shows a popup message. It will be shown on your device.

Constructor:

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

const Tooltip({
Key? key,
required this.message,
this.height,
this.padding,
this.margin,
this.verticalOffset,
this.preferBelow,
this.excludeFromSemantics,
this.decoration,
this.textStyle,
this.waitDuration,
this.showDuration,
this.child,
})

In the above Constructor, all fields marked with @required must not be empty.

Properties:

There are some properties of Tooltip are:

  • > child: This property is utilized to decide the widget for which the tooltip must be shown.
  • > decoration: This property with the assistance of decoration property background color, border (Shape), of the tooltip can be controlled.
  • > excludeFormSemantics: This property is used to take in boolean as a parameter, and by default it is false. It controls whether the tooltip’s message should be added to the semantic tree or not.
  • > height: This property is used to determine the height of the tooltip. It takes in double value as a parameter.
  • > margin: This property is used to determine the space around the tooltip. It takes EdgeInsetsGeometry as the parameter.
  • > message: This property is used to take a string value as the parameter to display the text in the tooltip.
  • > padding: This property is used to also take EdgeInsetsGeometry as the parameter to determine the space between the border and the main content of the tooltip.
  • > preferBelow: This property is used to control whether to display the tooltip on the widget or below that by taking a boolean as the parameter. By default, it is set to true.
  • > showDuration: This property is used to determine the time in seconds for which the tooltip should be displayed.
  • > textStyle: This property is used to take care of the styling of the message in the tooltip such as font size or color.
  • > verticalOffset: This property is utilized to control the vertical distance between the tooltip and the widget.
  • > waitDuration: This property is utilized to control the time after which the tooltip will be made apparent once the user floats over the widget of presses it for over one second.

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 Center widget. In this widget, we will add the Tooltip() widget. Inside the widget, we will add a message that means it takes a string value as the parameter to display the text in the tooltip and it is a required property so must not be empty. Next, we will add paddingmargindecoration with color and border-radius.

Center(
child: Tooltip(
message: '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.',
padding: const EdgeInsets.all(30),
margin: const EdgeInsets.only(top: 30, left:30,right: 30),
decoration: BoxDecoration(
color: Colors.blueAccent.withOpacity(0.6),
borderRadius: BorderRadius.circular(22)),
textStyle: const TextStyle(
fontSize: 15,
fontStyle: FontStyle.italic,
color: Colors.white),
child: SizedBox(
width: 320,
height: 150,
child: Image.asset(
'assets/logo.png',
fit: BoxFit.cover,
),
)))

We will add a textStyle means it takes care of the styling of the message in the tooltip such as font size or color. In child property, we will add the SizedBox widget. In this widget, we will add width, height, and its child property, we will add an image. 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';
import 'package:flutter_tooltips_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,
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Splash(),
);
}
}

class MyHomePage extends StatefulWidget {


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

class _MyHomePageState extends State<MyHomePage> {

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.blueAccent.withOpacity(0.6),
automaticallyImplyLeading: false,
title: Text('Flutter Tooltip Demo'),
),
body: Center(
child: Tooltip(
message: '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.',
padding: const EdgeInsets.all(30),
margin: const EdgeInsets.only(top: 30, left:30,right: 30),
decoration: BoxDecoration(
color: Colors.blueAccent.withOpacity(0.6),
borderRadius: BorderRadius.circular(22)),
textStyle: const TextStyle(
fontSize: 15,
fontStyle: FontStyle.italic,
color: Colors.white),
child: SizedBox(
width: 320,
height: 150,
child: Image.asset(
'assets/logo.png',
fit: BoxFit.cover,
),
))),
);
}
}

Conclusion:

In the article, I have explained the basic structure of the Tooltip in a flutter; you can modify this code according to your choice. This was a small introduction to Tooltip 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 Tooltip in your flutter projects. We will show you what the Tooltip is?. Show constructor and properties of the Tooltip. Make a demo program for working Tooltip. It shows when the user long-press the widget, then shows a popup message in your flutter application. 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.


RouteAware In Flutter

0

The most ideal situation when you create an application that gets delivered is that it’s a prompt achievement and users love it and use it precisely how you expected. The truth is dislike that, and you will require each piece of information accessible to see how users utilize your item.

In this blog, we will explore RouteAware In Flutter. We will see how to implement a demo program and show how to use RouteAware to screen navigation in your flutter applications.

Table Of Contents::

RouteAware

Methods

Code Implement

Conclusion



RouteAware:

An interface for objects that know about their present Route. This is utilized with RouteObserver to make a widget mindful of changes to the Navigator’s meeting history.

Demo Module ::

The above demo video shows how to use RouteAware in a flutter. It shows how RouteAware will work in your flutter applications. It shows when the user navigates between two screens. When HomePage is loaded, didPush of HomePage is called. At the point when we tapped on the button, the first didPushNext of HomePage got called and afterward, our SecondPage got delivered and didPush of SecondPage got called. At the point when we tapped on back from SecondPage, the HomePage’s didPopNext got called and afterward, SecondPage got poped and didPop of SecondPage got called. And afterward, the means were again repeated. It will be shown on your device.

Methods:

RouteAware class gives the accompanying methods which we can expand:

  • > didPop(): In this method, when we pop the current screen, the didPop method is called.
  • > didPopNext(): In this method, on the off chance that you have extended HomePage with RouteAware, and in case SecondPage is popped so HomePage is noticeable now, didPopNext is called. As such, this strategy is considered when the top screen is popped off and the current screen is apparent.
  • > didPush(): In this method, this is called when the current screen or route has been pushed into the navigation stack!
  • > didPushNext(): In this method, when we push SecondPage from HomePage, didPushNext is called. In other words, this method is called when a new screen/route is pushed from the current screen and the current screen is no longer visible.

How to implement code in dart file :

You need to implement it in your code respectively:

To start with, make a variable of RouteObserver in main.dart

final RouteObserver<ModalRoute> routeObserver = RouteObserver<ModalRoute>();

Inside your, MaterialApp you need to set navigatorObservers and pass our variable into it!. Then, our main. dart will look like this:

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

void main() => runApp(MyApp());
final RouteObserver<ModalRoute> routeObserver = RouteObserver<ModalRoute>();

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

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

Now will be to extend RouteAware so that you can override the different methods! Also, inside the initState() of HomePage, subscribe to the route.

@override
void initState() {
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
routeObserver.subscribe(this, ModalRoute.of(context)!);
});
super.initState();
}

Override the methods. In the body, we will add the Column widget. In this widget, we will add an image and ElevatedButton(). We are just overriding all the methods available and navigating to our next page onClick of our ElevatedButton().

import 'package:flutter/material.dart';
import 'package:flutter_route_aware_demo/second_page.dart';
import 'main.dart';

class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);

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

class _HomePageState extends State<HomePage> with RouteAware {
@override
void didPush() {
print('HomePage: Called didPush');
super.didPush();
}

@override
void didPop() {
print('HomePage: Called didPop');
super.didPop();
}

@override
void didPopNext() {
print('HomePage: Called didPopNext');
super.didPopNext();
}

@override
void didPushNext() {
print('HomePage: Called didPushNext');
super.didPushNext();
}

@override
void initState() {
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
routeObserver.subscribe(this, ModalRoute.of(context)!);
});
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.cyan,
automaticallyImplyLeading: false,
title: Text('Flutter RouteAware Demo'),
),
body: 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: MediaQuery.of(context).size.height*0.25,),
ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: TextStyle(fontSize: 20),
minimumSize: Size.fromHeight(40),
primary: Colors.cyan,
),
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => SecondPage(),
),
),
child: Text("Home Page",)
),
],
),
),
),
);
}
}

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

All same things can be done for the second_page.dart. In the body, we will add the text ”Flutter Dev’s” and wrap to it’s Center widget.

import 'package:flutter/material.dart';

import 'main.dart';

class SecondPage extends StatefulWidget {
const SecondPage({Key? key}) : super(key: key);

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

class _SecondPageState extends State<SecondPage> with RouteAware {
@override
void didPush() {
print('SecondPage: Called didPush');
super.didPush();
}

@override
void didPop() {
print('SecondPage: Called didPop');
super.didPop();
}

@override
void didPopNext() {
print('SecondPage: Called didPopNext');
super.didPopNext();
}

@override
void didPushNext() {
print('SecondPage: Called didPushNext');
super.didPushNext();
}

@override
void initState() {
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
routeObserver.subscribe(this, ModalRoute.of(context)!);
});
super.initState();
}

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

When we run the application, we ought to get the console final output like the underneath.

Launching lib/main.dart on ONEPLUS A5010 in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
Debug service listening on ws://127.0.0.1:37333/8K4tNNeL45U=/ws
Syncing files to device ONEPLUS A5010...
I/flutter (19730): HomePage: Called didPush
I/flutter (19730): HomePage: Called didPushNext
I/flutter (19730): SecondPage: Called didPush
I/flutter (19730): HomePage: Called didPopNext
I/flutter (19730): SecondPage: Called didPop
I/flutter (19730): HomePage: Called didPushNext
I/flutter (19730): SecondPage: Called didPush
I/flutter (19730): HomePage: Called didPopNext
I/flutter (19730): SecondPage: Called didPop
I/flutter (19730): HomePage: Called didPushNext
I/flutter (19730): SecondPage: Called didPush
I/flutter (19730): HomePage: Called didPopNext
I/flutter (19730): SecondPage: Called didPop

Conclusion:

In the article, I have explained the basic structure of RouteAware in a flutter; you can modify this code according to your choice. This was a small introduction to RouteAware 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 RouteAware in your flutter projects. We will show you what RouteAware is?. Show the methods of RouteAware. Make a demo program for working RouteAware. 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.

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.


Cupertino Scrollbar In Flutter

0

At whatever point you will code for building anything in Flutter, it will be inside a widget. The focal intention is to build the application out of widgets. It portrays how your application view should look with their present design and state.

In Flutter, scrollable widgets (ListView, GridView, and so on) have no scrollbar by default. A scrollbar shows a user how long a view is. It shows how far the user has scrolled from the top limit and lets the person in question rapidly leap to a specific point.

In this blog, we will explore the Cupertino Scrollbar In Flutter. We will see how to implement a Cupertino Scrollbar demo program and show how to use it in your flutter applications.

CupertinoScrollbar class – Cupertino library – Dart API
An iOS-style scrollbar. To add a scrollbar to a ScrollView, simply wrap the scroll view widget in a CupertinoScrollbar…api.flutter.dev

Table Of Contents::

Introduction

Constructor

Properties

Code Implement

Code File

Conclusion



Introduction:

CupertinoScrollbar Widget is an iOS-style Scrollbar. A Scrollbar is essentially used to scroll information in a versatile screen and it demonstrates what part of a Scrollable Widget is apparent.

Naturally, the CupertinoScrollbar Widget will stay draggable and it likewise utilizes PrimaryScrollController. If the child ScrollView is limitlessly long, the RawScrollbar won’t be painted. For this situation, the scrollbar can’t precisely address the general area of the apparent region or compute the exact delta to apply while dragging the thumb or tapping on the track.

Demo Module :

The above demo video shows how to use a Cupertino Scrollbar Widget in a flutter. It shows how the Cupertino Scrollbar Widget will work in your flutter applications. It shows when the code successfully runs, then the user slides the screen up and down, and the Cupertino scrollbar will show was a vertical line/thumb. It will be shown on your devices.

Constructor:

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

const CupertinoScrollbar({
Key? key,
required Widget child,
ScrollController? controller,
bool isAlwaysShown = false,
double thickness = defaultThickness,
this.thicknessWhileDragging = defaultThicknessWhileDragging,
Radius radius = defaultRadius,
this.radiusWhileDragging = defaultRadiusWhileDragging,
ScrollNotificationPredicate? notificationPredicate,
})

In the above Constructor, all fields marked with @required must not be empty.

Properties:

There are some properties of CupertinoScrollbar are:

  • Key: This property is used to control if it’s should be replaced.
  • Child: This property is used to the widget below this widget in the tree. Child Property will have only one child. To allocate multiple users needs to make use of Row Widget or Column Widget and wrap a child in it.
  • controller: This property is utilized to execute Scrollbar dragging. Assuming a ScrollController is passed, scrollbar dragging will be empowered on the given ScrollController. A stateful precursor of this CupertinoScrollbar needs to deal with the ScrollController and either pass it to a scrollable relative or utilize a PrimaryScrollController to share it.
  • isAlwaysShown: This property is utilized as a bool information type and it shows whether the Scrollbar ought to consistently be apparent. When false, the scrollbar will be displayed during scrolling and will fade out in any case. At the point when true, the scrollbar will consistently be noticeable and never fade out. The controller property should be set for this situation. It ought to be passed the pertinent Scrollable’s ScrollController.
  • > thickness: This property is used to the thickness of the scrollbar.
  • > radius: This property is used to set the shape of the scrollbar thumb (rounded corners).
  • > thicknessWhileDragging: This property is used to the thickness of the scrollbar when it’s being dragged by the user. When the user starts dragging the scrollbar, the thickness will animate from [thickness] to this value, then animate back when the user stops dragging the scrollbar.
  • > radiusWhileDragging: This property is used to the radius of the scrollbar edges when the scrollbar is being dragged by the user. When the user starts dragging the scrollbar, the radius will animate from [radius] to this value, then animate back when the user stops dragging the scrollbar.

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 dummyData is equal to List generate, and in the bracket, we will add the number of count and index.

final List dummyData = List.generate(20, (index) => '$index');

In the body, we will add CupertinoScrollbar() widget. In this widget, we will add a thickness was 12, the radius was circular(10), isAlwaysShown was shown true. It’s child property, we will add ListView.builder(). Inside, we will add itemCount was dummyData.length and itemBuilder. In itemBuilder, we will add inside a Card widget(). In this widget, we will add color, add text was dummyData[index] and wrap it to its Center widget. Center widget wrap to its padding widget.

CupertinoScrollbar(
thickness: 12,
radius: Radius.circular(10),
thicknessWhileDragging: 8,
isAlwaysShown: true,
child: ListView.builder(
itemCount: dummyData.length,
itemBuilder: (context, index) => Card(
color: Colors.cyan[100],
child: Padding(
padding: const EdgeInsets.all(20),
child: Center(
child: Text(
dummyData[index],
style: TextStyle(fontSize: 30),
),
),
),
),
)),

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_cupertinoscrollbar_dem/splash.dart';

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

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

class HomePage extends StatelessWidget {
final List dummyData = List.generate(20, (index) => '$index');
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.teal[200],
automaticallyImplyLeading: false,
title: Text('Flutter Cupertino Scrollbar Demo'),
),
body: CupertinoScrollbar(
thickness: 12,
radius: Radius.circular(10),
thicknessWhileDragging: 8,
isAlwaysShown: true,
child: ListView.builder(
itemCount: dummyData.length,
itemBuilder: (context, index) => Card(
color: Colors.cyan[100],
child: Padding(
padding: const EdgeInsets.all(20),
child: Center(
child: Text(
dummyData[index],
style: TextStyle(fontSize: 30),
),
),
),
),
)),
);
}
}

Conclusion:

In the article, I have explained the basic structure of the Cupertino Scrollbar in a flutter; you can modify this code according to your choice. This was a small introduction to Cupertino Scrollbar 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 Cupertino Scrollbar in your flutter projects. We will show you what the Introduction is?. Show constructor and properties of the Cupertino Scrollbar. Make a demo program for working Cupertino Scrollbar. It shows when the user slides the screen up and down, then the Cupertino scrollbar will show was a vertical line/thumb. in your flutter application. 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.


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.


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.


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.

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.


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.