Google search engine
Home Blog Page 26

AutoRoute In Flutter

0

For routing in a flutter, one must compose a great deal of code and check validations before exploring navigating with one screen then onto the next. This cycle can be simplified with code generation. When a project gets greater and greater in Flutter, it’s the ideal opportunity to utilize named routes, and implementing routing in flutter is tedious.

We can save time by producing all the routes ourselves and utilize the auto_route package and code generation for your flutter application.

auto_route | Flutter Package
AutoRoute is a declarative routing solution, where everything needed for navigation is automatically generated for you…pub.dev

In this article, we will explore the AutoRoute In Flutter. We will also implement a demo program using the auto_route package and code generation for your flutter applications.

Table Of Contents::

Introduction

Implementation

Code Implement

Code File

Conclusion



Introduction:

AutoRoute is a definitive routing arrangement, where everything required for navigation is automatically generated for you. We will make a basic application utilizing the auto_route package and code generation.

Demo Module ::

Demo Video

This demo video shows how to use an AutoRoute in a flutter and shows how AutoRoute will work using the auto_route package and code generation in your flutter applications, and show how all pages will navigating easily they will be shown on your device.

Implementation:

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:

auto_route: 

Step 2: Add the dev dependencies

Add dev dependencies to pubspec — yaml file.

dev_dependencies:

build_runner:
auto_route_generator:

Step 3: Import

import 'package:auto_route/auto_route.dart';

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

Step 5: Enable AndriodX

Add this to your gradle.properties file:

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

How to implement code in dart file :

You need to implement it in your code respectively:

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

Home Page

On this homepage, we will create a three-button. In three-button, we will navigate three different screens.

Now, we will deeply define all three page and code shown below:

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

On the first page, we will take single construction ‘info’ in the string and called the class on the home page.

import 'package:flutter/material.dart';

class FirstPage extends StatelessWidget {
const FirstPage({
Key key,
@required this.info,
}) : super(key: key);

final String info;

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white70,
appBar: AppBar(
backgroundColor: Colors.black,
title: Text("First Page"),
),
body: SafeArea(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(info,style: TextStyle(fontSize: 22),),
],
),
),
),
);
}
}

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

On the second page, we will take two construction, “name” in the string and “emp” in integer, and called the class on the home page.

import 'package:flutter/material.dart';

class SecondPage extends StatelessWidget {
const SecondPage({
Key key,
@required this.name,
@required this.emp,
}) : super(key: key);

final String name;
final int emp;

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white70,
appBar: AppBar(
backgroundColor: Colors.black,
title: Text("Second Page"),
),
body: SafeArea(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Name : $name",
style: TextStyle(fontSize: 22),),
Text("Employee : $emp",
style: TextStyle(fontSize: 22),),
],
),
),
),
);
}
}

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

On the third page, we will take two construction, “name” and “dsg,” in the string, and called the class on the home page.

import 'package:flutter/material.dart';

class ThirdPage extends StatelessWidget {
const ThirdPage({
Key key,
@required this.name,
@required this.dsg,
}) : super(key: key);

final String name;
final String dsg;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white70,
appBar: AppBar(
backgroundColor: Colors.black,
title: Text("Third Page"),
),
body: SafeArea(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Name : $name",style: TextStyle(fontSize: 22),),
Text("Designation : $dsg",style: TextStyle(fontSize: 22),),
],
),
),
),
);
}
}

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

To generate routes utilizing the auto_route package, we need to annotate on the Router class with AdaptiveAutoRouter(), which accepts a list of routes as an argument.

In this FlutterRouter class, we have accepted AutoRoute as a type of list. If you are developing this android application, you can take MaterialRoute or develop it just for iOS, and you can take CupertinoRoute. Its name should be prefixed with $ to get a generated class with a similar name minus the $. $Router => Router.

AdaptiveRoute and AutoRoute can deal with the page progress animation as per the stage you are utilizing, Android or iOS.

Now generate the code using build_runner you have to run this command in your terminal.

flutter packages pub run build_runner watch

If you want to build fresh and any conflict will occur, you can also use the command given below.

flutter pub run build_runner watch –delete-conflicting-outputs

This command will generate a router.gr.dart file in your directory which will look like the underneath.

// GENERATED CODE - DO NOT MODIFY BY HAND

// **************************************************************************
// AutoRouteGenerator
// **************************************************************************

// ignore_for_file: public_member_api_docs

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

import '../pages/first_page.dart';
import '../pages/home_page.dart';
import '../pages/second_page.dart';
import '../pages/third_page.dart';

class Routes {
static const String homePage = '/';
static const String firstPage = '/first-page';
static const String secondPage = '/second-page';
static const String thirdPage = '/third-page';
static const all = <String>{
homePage,
firstPage,
secondPage,
thirdPage,
};
}

class FlutterRouter extends RouterBase {
@override
List<RouteDef> get routes => _routes;
final _routes = <RouteDef>[
RouteDef(Routes.homePage, page: HomePage),
RouteDef(Routes.firstPage, page: FirstPage),
RouteDef(Routes.secondPage, page: SecondPage),
RouteDef(Routes.thirdPage, page: ThirdPage),
];
@override
Map<Type, AutoRouteFactory> get pagesMap => _pagesMap;
final _pagesMap = <Type, AutoRouteFactory>{
HomePage: (data) {
return buildAdaptivePageRoute<dynamic>(
builder: (context) => const HomePage(),
settings: data,
);
},
FirstPage: (data) {
final args = data.getArgs<FirstPageArguments>(nullOk: false);
return buildAdaptivePageRoute<dynamic>(
builder: (context) => FirstPage(
key: args.key,
info: args.info,
),
settings: data,
);
},
SecondPage: (data) {
final args = data.getArgs<SecondPageArguments>(nullOk: false);
return buildAdaptivePageRoute<dynamic>(
builder: (context) => SecondPage(
key: args.key,
name: args.name,
emp: args.emp,
),
settings: data,
);
},
ThirdPage: (data) {
final args = data.getArgs<ThirdPageArguments>(nullOk: false);
return buildAdaptivePageRoute<dynamic>(
builder: (context) => ThirdPage(
key: args.key,
name: args.name,
dsg: args.dsg,
),
settings: data,
);
},
};
}

/// ************************************************************************
/// Arguments holder classes
/// *************************************************************************

/// FirstPage arguments holder class
class FirstPageArguments {
final Key key;
final String info;
FirstPageArguments({this.key, @required this.info});
}

/// SecondPage arguments holder class
class SecondPageArguments {
final Key key;
final String name;
final int emp;
SecondPageArguments({this.key, @required this.name, @required this.emp});
}

/// ThirdPage arguments holder class
class ThirdPageArguments {
final Key key;
final String name;
final String dsg;
ThirdPageArguments({this.key, @required this.name, @required this.dsg});
}

In main. Dart file to notify our application to utilize these generated routes to determine the builder in your MaterialApp widget.

import 'package:auto_route/auto_route.dart';
import 'package:auto_route_demo/router_page/router.gr.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
builder: ExtendedNavigator.builder(
router: FlutterRouter(),
initialRoute: Routes.homePage,
builder: (_, navigator) => Theme(
data: ThemeData.dark(),
child: navigator,
),
),
debugShowCheckedModeBanner: false,
);
}
}

Presently, on the home page, we will call onPressed() in a button. To navigate utilizing generated routes, you should utilize ExtendedNavigator class, which comes from the auto_route package.

ExtendedNavigator.root.push(“route name”);

In this flat button, navigate to FirstPage, which has one argument in the constructor is the info: “Hello Flutter Dev’s.”

In this flat button, navigate to SecondPage, which takes two arguments in the constructor are name: “Flutter Dev’s” and emp: 165.

In this flat button, navigate to ThirdPage, which takes two arguments in the constructor are name: “Flutter Dev’s” and dsg: “Software Engineer.”

Code File:

https://gist.github.com/ShaiqAhmedkhan/3dd51bd7b32c99708c42e24009100f03#file-router_home_page-dart

Conclusion:

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

I hope this blog will provide you with sufficient information in Trying up the AutoRoute in your flutter projects. We will show you the AutoRoute is?, and shows how to use an AutoRoute in a flutter and shows how AutoRoute will work using the auto_route package and code generation in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter AutoRoute Demo:

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


From Our Parent Company Aeologic

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

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

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

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

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


Display Dynamic Events At Calendar In Flutter

Flutter has been a magnificent experience from the very beginning. Building gorgeous UI had never been quicker. It’s easy to fall in love with Flutter, regardless of whether you’re a beginner or an accomplished developer. All software developers realize that dates are the trickiest thing. What’s more, calendars are no exception.

A lot of these libraries are as yet under active development. Likewise, because a library can’t play out the entirety of the challenge calendar’s prerequisites doesn’t make it a more fragile library. Each calendar has various requirements!

In this blog, we will explore the Display Dynamic Events At Calendar In Flutter. We will also implement a demo program, display and create dynamic events on the calendar using the table_calendar package in your flutter applications.

table_calendar | Flutter Package
Highly customizable, feature-packed Flutter Calendar with gestures, animations, and multiple formats. Table Calendar…pub. dev

Table Of Contents::

Flutter Calendar

Features

Implementation

Code Implement

Code File

Conclusion



Flutter Calendar:

A calendar is a framework used to arrange the days, weeks, or months for business, religious, social, or regulatory purposes. It tracks which events fall on a specific date and when the special events will occur.

Flutter gives a basic plugin named table_calendar to show the calendar in our application. The table calendar is exceptionally adjustable and has numerous features, for example, gesture, animation, and various configurations.

Demo Module ::

Demo Screen

In this screenshot of the demo, we will add events on a particular date using the table_calendar package and use shared preference to store events in your flutter application.

Features:

  • > It is easy to use API.
  • It provides Dynamic events.
  • It provides Custom Builders for UI control.
  • It has vertical auto-sizing.
  • It provides beautiful animations.
  • It provides gesture handling.
  • It provides multiple calendar formats such as a month, weak, year, etc.
  • We can also use multiple days of the week formats.

Implementation:

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:

table_calendar: 
shared_preferences:

Step 2: Import

import 'package:table_calendar/table_calendar.dart';
import 'package:shared_preferences/shared_preferences.dart';

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

Step 4: Enable AndriodX

Add this to your gradle.properties file:

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

How to implement code in dart file :

You need to implement it in your code respectively:

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

In the TableCalendar, all data are required; we will deeply describe below the code. We will set a calendar format is week.

CalendarStyle(
canEventMarkersOverflow: true,
todayColor: Colors.orange,
selectedColor: Theme.of(context).primaryColor,
todayStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18.0,
color: Colors.white)),

In the CalendarStyle, we will add current date color and selected color for users easily identified, and users can change text color according to your applications.

HeaderStyle(
centerHeaderTitle: true,
formatButtonDecoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.circular(20.0),
),
formatButtonTextStyle: TextStyle(color: Colors.white),
formatButtonShowsNext: false,
),

In the HeaderStyle, we will center the header title and create a formatButtonDecoration for a month, week, year, etc., and color on it.

CalendarBuilders(
selectedDayBuilder: (context, date, events) => Container(
margin: const EdgeInsets.all(4.0),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(10.0)),
child: Text(
date.day.toString(),
style: TextStyle(color: Colors.white),
)),
todayDayBuilder: (context, date, events) => Container(
margin: const EdgeInsets.all(4.0),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.circular(10.0)),
child: Text(
date.day.toString(),
style: TextStyle(color: Colors.white),
)),
),

In the CalendarBuilders, we will add two builders that were selectedDayBuilder and todayDayBuilder. In selectedDayBuilder, we will add a container for the selected date, text, add color. In todayDayBuilder, we will add the same container, but the color was changed for the user to be identified for the current date.

Display Dynamic Events

First, let us create a variables that keeps our events interval calendar

Map<DateTime, List<dynamic>> _events;
List<dynamic> _selectedEvents;

Event is a map of key DateTime and lists the dynamic list of where this list is the list of events for that day. Create another variable list dynamic for selected events. Both variables will be initialized on initState().

@override
void initState() {
super.initState();
_events = {};
_selectedEvents = [];
}

In TableCalendar, let us assign events as underscore events. Whenever the day is selected, set state, so interval calendar on the day selected property.

onDaySelected: (date, events,holidays) {
setState(() {
_selectedEvents = events;
});
},

We will add a floating action button in our scaffold that will allow us to load the dialog from which we can add events to the selected date.

floatingActionButton: FloatingActionButton(
backgroundColor: Colors.black,
child: Icon(Icons.add),
onPressed: _showAddDialog,
),

Let’s create a method _showAddDialog().

_showAddDialog() async {
await showDialog(
context: context,
builder: (context) => AlertDialog(
backgroundColor: Colors.white70,
title: Text("Add Events"),
content: TextField(
controller: _eventController,
),
actions: <Widget>[
FlatButton(
child: Text("Save",style: TextStyle(color: Colors.red,fontWeight: FontWeight.bold),),
onPressed: () {
if (_eventController.text.isEmpty) return;
setState(() {
if (_events[_controller.selectedDay] != null) {
_events[_controller.selectedDay]
.add(_eventController.text);
} else {
_events[_controller.selectedDay] = [
_eventController.text
];
}
_eventController.clear();
Navigator.pop(context);
});

},
)
],
));
}

In this dialog, we will add a title, textField, and flat button. In the button onPressed() method, if the underscore event controller the text is empty, then return. If not underscore events so, first we check if on the square events, so our controller is a table calendar controller dot selected day if this is not equal to null then add underscore events in square bracket controller dot selected day dot to add event controller text so we’ll add a new event else if that is null then we need to create that object is controller dot selected day is equal to the event controller text. Let us wrap this always in setState().

..._selectedEvents.map((event) => Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: MediaQuery.of(context).size.height/20,
width: MediaQuery.of(context).size.width/2,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Colors.white,
border: Border.all(color: Colors.grey)
),
child: Center(
child: Text(event,
style: TextStyle(color: Colors.blue,
fontWeight: FontWeight.bold,fontSize: 16),)
),
),
)),

After TableCalendar inside the column, let us use this for selected events dot map(). We will use container and child property; we will add text events. When we run the application, we ought to get the screen’s output like the underneath video capture.

Display Dynamic Events Without Shared Preferences

This video shows how to select a date and then click on the floating action button. A dialog box opens; we will add an event and then save the events. Also, we will add multiple events. The event name will be displayed on our devices. We will not add shared preferences.

Now, We will add shared preferences.

SharedPreferences prefs;

First, we will be called SharePrences as prefs and then initialize to initState().

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

I have also added two functions, helper functions that help to encode and decode our events map, so this will help us covert our events map into a string that we can save to sharedPreference and load it from sharedPreference.

Map<String, dynamic> encodeMap(Map<DateTime, dynamic> map) {
Map<String, dynamic> newMap = {};
map.forEach((key, value) {
newMap[key.toString()] = map[key];
});
return newMap;
}
Map<DateTime, dynamic> decodeMap(Map<String, dynamic> map) {
Map<DateTime, dynamic> newMap = {};
map.forEach((key, value) {
newMap[DateTime.parse(key)] = map[key];
});
return newMap;
}

Let’s define prefsData() function.

First, prefs is equal to SharedPreferences.getInstance(). Underscore events are equal to the map dot from decodeMap.In decodeMap, json dot decode and prefs.getString(“events”), and if this is null, then we pass an empty map integer string.

prefsData() async {
prefs = await SharedPreferences.getInstance();
setState(() {
_events = Map<DateTime, List<dynamic>>.from(
decodeMap(json.decode(prefs.getString("events") ?? "{}")));
});
}

Now, we will add a dialog box onPressed() method, and whenever we add new events, we’d like to save those to the sharePreference.

prefs.setString("events", json.encode(encodeMap(_events)));

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

Display Dynamic Events With Shared Preferences

This video shows how to select a date and then click on the floating button. A dialog box opens; we will add the event and then save the events. Also, we will add multiple events. The event name will be displayed on our devices. When hot restart so these events should be persisted and loaded from sharePreference, you can see the events marker, and if we press here if we select the dates, we can see those events on our devices.

Code File:

https://gist.github.com/ShaiqAhmedkhan/b859609c91d8df5ed92fa506e2126bf8#file-dynamic_events-dart

Conclusion:

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

I hope this blog will provide you with sufficient information in Trying up the Display Dynamic Events At Calendar in your flutter projects. We will show you the flutter calendar, some features, and show how to display and create dynamic events on the calendar using the table_calendar package and store the events on sharePreferences in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤https://giphy.com/embed/lD76yTC5zxZPG/twitter/iframe


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

Clap 👏 If this article helps you.

find the source code of the Flutter Dynamic Event Calendar Demo:

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


From Our Parent Company Aeologic

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

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

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

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

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


ImageFiltered Widget In Flutter

0

Flutter widgets are simply bits of your UI. Truth be told, everything in the UI is a widget. Indeed, even the application itself is a widget!. There are significantly more widgets than simply structural elements like buttons, text, and pictures. For instance, padding is a widget. Layout columns are widgets. Styles are widgets. Indeed, even gesture detectors are widgets.

The Widget, as such, is straightforward, gives a Child property and a Filter property. Playing with this Filter property makes great impacts native to Flutter and doesn’t need importing Edited Pictures(Even however it may appear to be simple).

In this article, we explore the ImageFiltered Widget In Flutter. We will implement a demo program of the image filtered widget and use it in our Flutter application.

Table Of Contents::

ImageFiltered Widget

Code Implement

Code File

Conclusion



ImageFiltered Widget:

Flutter provides an ImageFiltered, a low-level class that takes pixels and rearranges them. It applies an ImageFilter to its child. A filter operation to apply to a raster image.

ImageFiltered will blur the images, text, and anything will be blurry. It also works on any matrix for transformation like scaling, translating, skewing, rotating, etc.

For more info on ImageFiltered Widget,Watch this video:

Code Implement:

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

Home Page

We will make four buttons on this home page screen, and each button will show ImageFiltered, and we will show the deeply below detail.

Blur Image:

First, we will import it from dart:ui.

import 'dart:ui';

Then we will add an ImageFiltered.blur(), we will add sigmaX, sigmaY for blurring the image. Users can provide a greater amount of blurring in X and Y directions for increasing the blurring of the image. Its child, we will add an image or widget() for blurring.

Container(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ImageFiltered(
imageFilter: ImageFilter.blur( sigmaY: 4,sigmaX: 4),
child: Image.asset("assets/devs.jpg",)
),
],
),
),
)

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

Blur Image

ImageFilter Matrix:

Using a matrix transformation is a little more complicated if you are a genius. You can directly provide the matrix as a float64 list.

Container(
child: Center(
child: Column(
//mainAxisAlignment: MainAxisAlignment.center,
children: [
ImageFiltered(
imageFilter: ImageFilter.matrix(
Float64List.fromList([
1,1,0,0,
0,1,1,0,
1,1,0,1,
1,1,0,1
]),
),
child: Image.asset("assets/devs.jpg",scale: 3.5,)
),
],
),
),
)

We will wrap the image you want to filter with ImageFiltered and provides the filter so that the image can be filtered. When we run the application, we ought to get the screen’s output like the underneath screen capture.

ImageFilter Matrix

Matrix4 Rotation:

Most users will opt to use the matrix4 class from the vector path instead of the float64 list.

Container(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ImageFiltered(
imageFilter: ImageFilter.matrix(
Matrix4.rotationZ(0.15).storage,
),
child: Image.asset("assets/devs.jpg",scale:3.5)
),
],
),
),
)

In ImageFiltered, we will add Matrix4.rotaionZ() dot storage and provide a rotation in Z directions. When we run the application, we ought to get the screen’s output like the underneath screen capture.

Matrix4 Rotation

Blur Full Screen:

It’s good to keep in mind that everything in flutter is a widget. Therefore, you can filter anything, not just images.

Container(
child:ImageFiltered(
imageFilter: ImageFilter.blur( sigmaY: 3,sigmaX: 3),
child: FullScreen()
) ,
);

We will wrap the widget/class you want to filter with ImageFiltered and provides the filter that anything can be filtered. We will add sigmaX, sigmaY for blurring the screen. Users can provide an amount of blurring in X and Y directions.

Create a FullScreen() class on blur_full_screen.dart inside the lib folder.

return Scaffold(
backgroundColor: Color(0xffFFFFFF),
appBar: AppBar(
backgroundColor: Colors.black,
title: Text("ImageFiltered Demo"),
centerTitle: true,
),
body: Container(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset("assets/devs.jpg",)
],
),
),
)
);

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

Blur Full Screen

Code File:

import 'package:flutter/material.dart';
import 'package:flutter_imagefiltered_demo/blur_full_screen.dart';
import 'package:flutter_imagefiltered_demo/blur_image.dart';
import 'package:flutter_imagefiltered_demo/imagefilter_matrix.dart';
import 'package:flutter_imagefiltered_demo/matrix4_rotation.dart';

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

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

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

),
SizedBox(height: 8,),

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


),
SizedBox(height: 8,),

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


),

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

Conclusion:

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

I hope this blog will provide you with sufficient information in Trying up the ImageFiltered Widget in your flutter projects. We will show you what the ImageFiltered widget is?, some properties using in ImageFiltered, and make a demo program for working ImageFiltered in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter ImageFiltered Widget Demo:

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


From Our Parent Company Aeologic

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

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

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

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

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


Stepper Widget In Flutter

0

Flutter is Google’s UI toolkit for making lovely, natively compiled iOS and Android applications from a single code base. To build any application, we start with widgets—the structure block of flutter applications. Widgets depict what their view ought to resemble, given their present configuration and state. It incorporates a text widget, row widget, column widget, container widget, and some more.

Every component on a screen of the Flutter application is a widget. The screen’s perspective entirely relies on the choice and grouping of the widgets used to build the application. Also, the structure of the code of an application is a tree of widgets.

In this article, we explore the Stepper Widget In Flutter. We will implement a stepper widget demo program and how to use it in your flutter applications.

Table Of Contents::

Stepper Widget

Code Implement

Code File

Conclusion



Stepper Widget:

A material stepper widget that showcases progress through a succession of steps. Steppers are especially valuable on account of forms where one step requires another or where various steps should be finished to present the complete form.

The widget is a flexible wrapper. A parent class should pass currentStep to this widget dependent on some rationale set off by the three callbacks that it gives.

Demo Module ::

This video shows how to create a stepper widget in a flutter and shows how the stepper widget will work in your flutter applications. They will change the type horizontal/vertical direction when you tap on the floating action button. They will be shown on your device.

Code Implement:

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

We’ll need to hook into onStepContinueonStepCancel , onStepTapped and currenStepallow a user to cycle through it.

Now we will create an integer of currentStep. The index into steps of the current step whose content is displayed.

int _currentStep = 0;

Now, onStepTapped is the callback called when a step is tapped, with its index passed as an argument. We will create a tapped() widget and the code as shown below.

tapped(int step){
setState(() => _currentStep = step);
}

Now, onStepContinue is the callback called when the ‘continue’ button is tapped. If null, the ‘continue’ button will be disabled. We will create a continued() widget and the code, as shown below.

continued(){
_currentStep < 2 ?
setState(() => _currentStep += 1): null;
}

When we press the continue button then the step will forward to another step.

Now, onStepCancel is the callback called when the ‘cancel’ button is tapped. If null, the ‘cancel’ button will be disabled. We will create a cancel() widget and the code, as shown below.

cancel(){
_currentStep > 0 ?
setState(() => _currentStep -= 1) : null;
}

When we press the cancel button, then the step will backward to the previous step.

Now, we will define steps.

We will create a Stepper with three steps. We will deeply define all three steps below are:

Account Step

In a first step, we will be called an Account as the title. In this step, we will create two TextFormField called Email Address and Password.

Step(
title: new Text('Account'),
content: Column(
children: <Widget>[
TextFormField(
decoration: InputDecoration(labelText: 'Email Address'),
),
TextFormField(
decoration: InputDecoration(labelText: 'Password'),
),
],
),
isActive: _currentStep >= 0,
state: _currentStep >= 0 ?
StepState.complete : StepState.disabled,
),

When the user taps the continue button, the step will forward to the next step. The number was changed to an active tick icon. In this step, the cancel button will not work.

Address Step

In a second step, we will be called an Address as the title. In this step, we will create two TextFormField called Home Address and Postcode.

Step(
title: new Text('Address'),
content: Column(
children: <Widget>[
TextFormField(
decoration: InputDecoration(labelText: 'Home Address'),
),
TextFormField(
decoration: InputDecoration(labelText: 'Postcode'),
),
],
),
isActive: _currentStep >= 0,
state: _currentStep >= 1 ?
StepState.complete : StepState.disabled,
),

In this step, when the user will tap the continue button, the step will forward to the next step, and the number was changed to the active tick icon. When the user taps on the cancel button, the step will backward to the previous step, and the active tick icon was changed to a number again.

Mobile Number Step

In the last step, we will be called a Mobile Number as the title. In this step, we will create one TextFormField called Mobile Number.

Step(
title: new Text('Mobile Number'),
content: Column(
children: <Widget>[
TextFormField(
decoration: InputDecoration(labelText: 'Mobile Number'),
),
],
),
isActive:_currentStep >= 0,
state: _currentStep >= 2 ?
StepState.complete : StepState.disabled,
),

In this step, when the user will tap the continue button, the step will forward to the next step, and the number was changed to the active tick icon. When the user taps on the cancel button, the step will backward to the previous step, and the active tick icon was changed to a number again.

Horizontal Step

We will also change the type of direction in the stepper, so we make a floating action button, and on this button, we called an icon and switchStepsType() widget.

floatingActionButton: FloatingActionButton(
child: Icon(Icons.list),
onPressed: switchStepsType,
),

Now we can deep define switchStepsType() widget.

switchStepsType() {
setState(() => stepperType == StepperType.vertical
? stepperType = StepperType.horizontal
: stepperType = StepperType.vertical);
}

In this widget, we can define the default stepper type as vertical, and the user can tap the floating action button, then the stepper will changes vertical to horizontal. When we run the application, we ought to get the screen’s output like the underneath screen capture.

Final Output

Code File:

https://gist.github.com/ShaiqAhmedkhan/b4c41a30004d6275b97fc0a4c70106ac#file-stepper_demo-dart

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up Stepper Widget in your flutter projects. We will show you the stepper widget is?, show the stepper widget demo program, and how to change type direction horizontal/vertical when the user presses a floating action button in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter Stepper Widget Demo:

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


From Our Parent Company Aeologic

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

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

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

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

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


Widget Testing With Flutter

0

As your application gets greater and greater, a decent arrangement of tests may help you save time, as tests can discover new bugs that could show up with ordinary alterations. Flutter automated testing empowers you to accomplish higher responsiveness in your application since it helps discover bugs and different issues in your application. It is likewise significant in different viewpoints like believability as a developer.

In this article, we explore Widget Testing With Flutter. We will implement a demo of widget testing for our Flutter application, and why do we need test cases for our application?.

Table Of Contents::

Flutter Testing

Why Test cases?

Widget Test

Implementation

Code Implement

Code File

Conclusion



Flutter Testing:

The more highlights your application has, the harder it is to test manually. Automated tests help guarantee that your application performs accurately before you publish it while holding your feature and bug-fix velocity.

Flutter has immediately picked up prominence among developers for building excellent Android and iOS applications. Like applications built with some other development toolkit, Flutter applications’ automated testing is the best way to guarantee application quality in the briefest time conceivable.

Flutter testing falls into three categories:

  • Unit Test
  • Widget Test
  • Integration Test

Note: In this article, we will discuss only the widget test.

Why Test cases?:

We compose test cases for our application since we need our application bug-free and fulfill the application necessities before publishing our work to the client. The client doesn’t need a terrible item. So to stay away from it, we test our application by composing the test cases.

A definition from Software Testing Fundamentals test cases is a bunch of conditions under which an analyzer will decide if an application fulfills necessities or works accurately. The way toward developing test cases can likewise help discover issues in an application’s necessities or design.

Widget Test:

Widget testing is otherwise called component testing. As its name proposes, it is utilized for testing a single widget, and the objective of this test is to check whether the widget works and looks true to form.

Likewise, you can utilize the WidgetTester utility for various things while testing, for example, sending input to a widget, finding a part in the widget tree, confirming values, etc.

For more info on Widget Test,Watch this video:

Widget testing proves to be useful when we are trying the particular widgets. On the off chance that the Text widget doesn’t contain the text, at that point, Widget testing throws an error expressing that the Text widget doesn’t have a text inside it. We likewise don’t host to install any third-party dependencies for widget testing in Flutter.

Implementation:

Steps to Implement Widget Testing

Step 1: Add the dependencies

Add the flutter_test dependency to pubspec — yaml file.

dev_dependencies:
flutter_test:
sdk: flutter

Step 2: Create a widget to test.

Step 3: Create a testWidgets test.

Step 4: Build the widget using the WidgetTester.

Step 5: Search for the widget using a Finder.

Step 6: Verify the widget using a Matcher.

How to implement code in dart file :

You need to implement it in your code respectively:

Lets’s create a new dart file called home_page.dart inside the lib folder.

TextField(
controller: _controller,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "Enter text"),
),

We will make a TextField() on this home page, and now we will test for this text field. We will write test cases to pass the functionality of our Flutter application.

Create a widget_testing.dart file under the test directory and insert the code below.

First, we will import the package:

import 'package:flutter_test/flutter_test.dart';

Let us dive into the syntax for the widget testing in Flutter:

testWidgets(description, callback)

We, as a whole, know the importance of description in test cases. It is utilized to describe test cases’ utilization; however, the callback will pursue the main function’s execution. Here callback alludes to the testWidgets, a function that permits you to characterize a widget test and makes a widget with the assistance of a WidgetTesterWidgetTester It is utilized to build widgets during the running test cases.

testWidgets(Some Description, (WidgetTester tester) async {});

We will use this tester and a couple of other methods to test our visit a test. Testing visits the first thing we need to do is tell which widgets to test.

testWidgets("Flutter Widget Test",  (WidgetTester tester) async {
await tester.pumpWidget(MyApp());
var textField = find.byType(TextField);
expect(textField, findsOneWidget);
});

The first thing we had like to do is we need to find the text filed and confirm that it exists, so we use textField is equal to the find.byType(). Now run this test in the terminal by command.

** flutter test ./test/widget_testing.dart **

Test passed

Now next thing we can do is we can enter a text in this text field using await tester.enterText() and then expect(actual, matcher). So we should be able to find one widget.

testWidgets("Flutter Widget Test",  (WidgetTester tester) async {
await tester.pumpWidget(MyApp());
var textField = find.byType(TextField);
expect(textField, findsOneWidget);
await tester.enterText(textField, 'Flutter Devs');
expect(find.text('Flutter Devs'), findsOneWidget);
print('Flutter Devs');
});

We again run the terminal by command, and we ought to get the screen’s output like the underneath screen capture.

TextField Test Passed

Now we add a button on the home page file:

RaisedButton(
color: Colors.blueGrey,
child: Text("Reverse Text"),
onPressed: () {
if (_controller.text.isEmpty) return;
setState(() {
_reversedText = reverseText(_controller.text);
});
},
),

In this button function, when we add text on the text field and then press the button, the text was reversed shown on our screen. Now we will test this button on widget test.

testWidgets("Flutter Widget Test",  (WidgetTester tester) async {
await tester.pumpWidget(MyApp());
var textField = find.byType(TextField);
expect(textField, findsOneWidget);
await tester.enterText(textField, 'Flutter Devs');
expect(find.text('Flutter Devs'), findsOneWidget);
print('Flutter Devs');
var button = find.text("Reverse Text");
expect(button,findsOneWidget);
print('Reverse Text');
await tester.tap(button);
await tester.pump();
expect(find.text("sveD rettulF"),findsOneWidget);
print('sveD rettulF');
});

Now we will add buttons equal to the find. Text (), in the expected bracket, we will add a button and finds one widget, then we will use the awaiting tester. tap(), and we need to wait to execute one frame using the await tester. pump(). Finally, we can expect to find the reverse text in one widget. We run the terminal by command, and we ought to get the screen’s output like the underneath screen capture.

Button Test Passed

To look at how it looks when the test fails, let’s write findsNothing. They will show many types of errors in your terminal, like matching, finder, actual, and, Etc.

testWidgets("Flutter Widget Test",  (WidgetTester tester) async {
await tester.pumpWidget(MyApp());
var button = find.text("Reverse Text");
expect(button,findsOneWidget);
print('Reverse Text');
await tester.tap(button);
await tester.pump();
expect(find.text("sveD rettulF"),findsNothing);
print('sveD rettulF');
});

Last time again, we run the terminal by command, and we ought to get the screen’s output like the underneath screen capture.

Test Fail

Code File:

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

Conclusion:

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

I hope this blog will provide you with sufficient information in Trying up Widget Testing With Flutter in your flutter projects. We will show you the widget test is?, set it up in our project, and show the widget test’s demo program in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter Widget Testing Demo:

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


From Our Parent Company Aeologic

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

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

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

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

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


Hive DataBase With TypeAdapter In Flutter

Many applications require information handling on the phone and, further, their synchronization with the backend. For instance, to-do lists, arrangements of any information (analyzes, notes, and so forth). It’s not under any condition cool when the list of only a couple thousand things while erasing one of them and afterward keeping in touch with the cache or looking through the cache begins to back off.

Quite possibly, the main part of application development is data storage and manipulation, and the equivalent is valid for flutter applications. There are numerous approaches to store local data in flutter applications.

In this post, we will explore the Hive DataBase With TypeAdapter In Flutter. We will also implement a demo program, create a todo app using hive packages, and use them in your flutter applications.

hive | Dart Package
Hive is a lightweight and blazing fast key-value database written in pure Dart. Inspired by Bitcask. 🚀 Cross-platform…pub.dev

Table Of Contents::

Hive

Hive Boxes

Type Adapters

Why Hive DataBase

Advantages

Implementation

Code Implement

Code File

Conclusion



Hive:

Hive is a quick, lightweight, NoSQL database for flutter and dart applications. Hive is truly helpful if you need a straightforward key-value database without numerous relations and truly simple to utilize. It is an offline database(store data in local devices). It has no native dependencies (it runs on Flutter Web!) can be the ideal choice. Hive bolsters all stages upheld by Flutter.

Hive having the idea of boxes(which store data). A Box must be opened before use. Notwithstanding the plain-enhanced Boxes, there are additional alternatives that help lazy-loading of values and encryption.

Demo Module ::

Demo Module

In this screenshot of the demo, there was a to-do list, and all red color tick will show progress, and the purple tick will show completed; and we also used filter the data using Hive in your flutter applications.

Hive Boxes:

Hive stores its data in boxes containing key-value sets. I like to see boxes as an organizer with files listed and arranged by a numbering framework or as normal maps in the dart. With hive, before you can read/compose data, a box should be opened. Boxes can be opened with await Hive.Openbox(‘name’) can get an instance of an opened box with Hive. Box (‘name’), where ‘name’ is the name of the case (saying the DB name).

You can call Hive.openBox(‘name’) regardless of whether you as of now have the box opened elsewhere, here and there it very well might be smart to do this.

Type Adapters:

Hive permits you to store most standard types — String, int, Map, List, DateTime, yet you need to have a model class for your data since this makes development a lot simpler and quicker. To utilize these model kinds, you need to enroll TypeAdapters, which causes you to encode/decode your item to binary form on a disk.

You can manually compose your Type Adapters, yet we’ll generate our own with the hive_generator and build_runner packages we added to our dev dependencies earlier. Somewhere in your lib/folder, you can make your model file.

Why Hive DataBase?:

  • It’s the most efficient database in terms of speed and performance compared to SQFlite and SharedPrefrences.
  • It provides a straightforward way to perform basic (CRUD) operations.

Advantages:

  • Cross-platform: since there are no native dependencies on pure Dart — mobile, desktop, browser.
  • High performance.
  • Built-in strong encryption.
  • NO native dependencies.

Implementation:

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:

hive: 
hive_flutter:
path_provider:

Step 2: Add the dev dependencies

Add dev dependencies to pubspec — yaml file.

dev_dependencies:

hive_generator: 
build_runner:

Step 3: Import

import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:path_provider/path_provider.dart';

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

Step 5: Enable AndriodX

Add this to your gradle.properties file:

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

How to implement code in dart file :

You need to implement it in your code respectively:

Now let’s create the class and add the right annotations so the TypeAdapters can be generated:

Let’s build a model class, e.g., DataModel.

import 'package:hive/hive.dart';

part 'data_model.g.dart';

@HiveType(typeId: 0)
class DataModel{
@HiveField(0)
final String title;
@HiveField(1)
final String description;
@HiveField(2)
final bool complete;

DataModel({this.title, this.description, this.complete});

}

First import hive. At that point, add ‘data_model.g.dart’ as a section (this is where the type adapter is generated). Clarify the model class with @HiveType(), so the generator realizes this should be a TypeAdapter. Annotate on each field you need to save with @HiveField(index), the index is an int, and each index ought to show up once, and you shouldn’t transform it in the wake of enlisting them. We have three factors like title, description, and complete to store, and they are explained as @HiveField.

Now, We will run a code generator by typing the following command in the terminal which will automatically generate database code for us.

$ flutter packages pub run build_runner build

Note: File name is `data_model.dart`. We will add a line part ‘data_model.g.dart’.Where g stands for generated. Thus new generated file would be data_model.g.dart

// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'data_model.dart';

// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************

class DataModelAdapter extends TypeAdapter<DataModel> {
@override
final typeId = 0;

@override
DataModel read(BinaryReader reader) {
var numOfFields = reader.readByte();
var fields = <int, dynamic>{
for (var i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return DataModel(
title: fields[0] as String,
description: fields[1] as String,
complete: fields[2] as bool,
);
}

@override
void write(BinaryWriter writer, DataModel obj) {
writer
..writeByte(3)
..writeByte(0)
..write(obj.title)Demo
..writeByte(1)
..write(obj.description)
..writeByte(2)
..write(obj.complete);
}
}

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

floatingActionButton: FloatingActionButton(
onPressed: (){
showDialog(
context: context,
child: Dialog(

backgroundColor: Colors.blueGrey[100],
child: Container(
padding: EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
TextField(
decoration: InputDecoration(hintText: "Title"),
controller: titleController,
),
SizedBox(
height: 8,
),
TextField(
decoration: InputDecoration(
hintText: "Description"),
controller: descriptionController,
),
SizedBox(
height: 8,
),
FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
color: Colors.red,
child: Text("Add Data",style: TextStyle(color: Colors.white),),
onPressed: () {
final String title = titleController.text;
final String description = descriptionController.text;
titleController.clear();
descriptionController.clear();
DataModel data = DataModel(title: title, description: description, complete: false);
dataBox.add(data);
Navigator.pop(context);

},
)
],
),
)
)
);
},
child: Icon(Icons.add),
),

On this screen, we will make a FloatingActionButton(). In this button onPressed()method, we will open a dialog box with text fields.

Dialog Box With Text Fields

When we tap on the floating button, then a dialog box will open with a text field, and then we will write any title, description and then press on add data button, then data will show on your screen.

ValueListenableBuilder(
valueListenable: dataBox.listenable(),

builder: (context, Box<DataModel> items, _){

List<int> keys= items.keys.cast<int>().toList();
return ListView.separated(
separatorBuilder: (_, index) => Divider(),
itemCount: keys.length,
shrinkWrap: true,
scrollDirection: Axis.vertical,
physics: NeverScrollableScrollPhysics(),
itemBuilder:(_, index){
final int key = keys[index];
final DataModel data = items.get(key);
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
color: Colors.blueGrey[200],
child: ListTile(
title: Text(data.title, style: TextStyle(fontSize: 22,color: Colors.black),),
subtitle: Text(data.description,style: TextStyle(fontSize: 20,color:Colors.black38)),
leading: Text("$key", style: TextStyle(fontSize: 18,color: Colors.black),),

),
);
},

);
},
),

We will use ValueListenableBuilder(), In this builder ,we will return a ListView.separated(). We will add a separator builder, itemCount, shrinkWrap, and itemBuilder. In itemBuilder, we will return a Card.

Data

On this screen, We will add a card and add a ListTile(). Add title, description, index. We will add a trailing on a list tile method when we add the tick icon on the right side.

trailing: Icon(Icons.check, color: data.complete ? Colors.deepPurpleAccent : Colors.red,),

When data are completed, the color was purple otherwise was red. Now we will create a tap function on the list tile method and open a dialog box.

onTap: (){
showDialog(
context: context,
child: Dialog(
backgroundColor: Colors.white,
child: Container(
padding: EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
color: Colors.blueAccent[100],
child: Text("Mark as complete",
style: TextStyle(color: Colors.black87),
),
onPressed: () {
DataModel mData = DataModel(
title: data.title,
description: data.description,
complete: true
);
dataBox.put(key, mData);
Navigator.pop(context);
},
)
],
),
)
)
);
},

In this dialog box, we will make a button; on this button, a text will be shown “Mark as complete.” When we click on this button, the tick color was changed from red to purple or from progress to complete.

Completed Data

Now we will add a filter, and we will make three types of the filter; the first was All. In this method, all the data will be shown all your screen. The second was Completed, In this method, only completed data will be shown, and last was Progress, In this method, only progress data will be shown, and the tick color was red.

enum DataFilter {ALL, COMPLETED, PROGRESS}

We will make a PopupMenuButton(). In this button, we will add All, Completed, and Progress with DataFilter. The menu is shown on the right side of the app bar.

PopupMenuButton<String>(
onSelected: (value) {
if(value.compareTo("All") == 0){
setState(() {
filter = DataFilter.ALL;
});
}else if (value.compareTo("Compeleted") == 0){
setState(() {
filter = DataFilter.COMPLETED;
});
}else{
setState(() {
filter = DataFilter.PROGRESS;
});
}
},
itemBuilder: (BuildContext context) {
return ["All", "Compeleted", "Progress"].map((option) {
return PopupMenuItem(
value: option,
child: Text(option),
);
}).toList();
},
)

When we click on any filter type, they will show only those items data but initially, data default show “All.”

Filter

We will add a filter function on ValueListenableBuilder() and map to the keys with DataFilter.

if(filter == DataFilter.ALL){
keys = items.keys.cast<int>().toList();
}else if(filter == DataFilter.COMPLETED){
keys = items.keys.cast<int>().where((key) => items.get(key).complete).toList();
}else{
keys = items.keys.cast<int>().where((key) => !items.get(key).complete).toList();
}

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

Final Output

In this Final video output, you will see how Hive DataBase With TypeAdapter will work and how to use filters to change data in your flutter applications.

Code File:

https://gist.github.com/ShaiqAhmedkhan/1c4e75c682295953c9f3e1d150c5a8f5#file-hive_demo-dart

Conclusion:

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

I hope this blog will provide you with sufficient information in Trying up to Hive DataBase With TypeAdapter in your flutter projects. We will show you the hive is?, TypeAdapter is?, and working on a hive database with a type adapter using hive in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter Hive Database Demo:

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


From Our Parent Company Aeologic

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

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

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

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

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


Explore Implicit Animation In Flutter

0

Animations are straightforward to do in Flutter, and a great deal of unpredictability can be accomplished with significantly less exertion than native Android. This is generally accomplished through ways like characterizing an Animation and an AnimationController. However, there are inbuilt widgets that even diminish this and make animations as simple as basically changing values!

Animations assume a significant part in upgrading your application’s general user experience from the visual criticism, motion, and up to the custom animations you can actually envision!. Like some other items integrated into an application, animations should be useful instead of simply a regular stylistic layout.

In this post, we will Explore Implicit Animation In Flutter. We will also implement a demo program, common types, properties and use them in your flutter applications.

Table Of Contents::

Implicit Animation

Types

Properties

Code Implementation

Code File

Conclusion



Implicit Animation:

The implicit animation could be separated into worked-in widgets and customized widgets.ImplicitAnimtatedWidget It is an abstract class for building widgets that animate changes to their properties. Widgets of this sort won’t animate when they are first added to the widget tree. Or maybe, when they are rebuilt with various values, they will react to those progressions by animating the progressions over a predetermined duration.https://www.youtube.com/embed/IVTjpW3W33s?feature=oembedIntroduction Video

ImplicitlyAnimatedWidgets consequently animate changes in their properties at whatever point they change. For this, they make and deal with their own inner AnimationControllers to control the animation. While these widgets are easy to utilize and don’t expect you to deal with the lifecycle of an AnimationController physically, they are likewise, to some degree, restricted: Besides the objective value for the animated property, developers can pick a duration and curve for the movement.

Common Types of Widgets:

Various implicitly animated widgets transport with the framework. They are typically namedAnimatedFoo where Foo is the name of the non-animated rendition of that widget. There are some regularly utilized implicitly animated widgets include:

  • AnimatedContainer
  • AnimatedOpacity
  • AnimatedCrossFade
  • TweenAnimationBuilder

Properties

There are some properties:

  • Curve: The official document is clear and sweet in that they show all the inherent curve behaviors in videos. So on the off chance that you need to change the animation curve, pick what you need.
  • Duration: This is a real sense that implies the duration of the animation. It very well may be days, hours, minutes, seconds, milliseconds, even microseconds.
  • onEnd: We can accomplish something after the animation wraps up.

Code Implement:

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

Home Page

We will make four buttons on this home page screen, and each button will show implicit animation, and we will show the below detail.

AnimatedContainer:

An AnimatedContainer naturally transitions to the value characterized (colors, sizes, and so on) rather than immediately changing to them.

Animated Container

The Container the class causes you to make a widget with explicit properties, for example, heightwidthcolor and then some. This is normally utilized for wrapping child widgets to deal with their properties, for example, sizes, paddings, and margins advantageously.

AnimatedContainer(
width: width,
height: height,
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(10),
),
duration: Duration(milliseconds:600),
curve: Curves.easeInToLinear,
),

Utilizing the AnimatedContaineryou can animate a normal Container by changing its properties. It naturally changes the color, the sizes without you having the explicitly setting custom tweens or controllers.

floatingActionButton: FloatingActionButton(
onPressed: (){
setState(() {
width = width ==300? 250: 300;
height = height==250? 300: 250;
color = color == Colors.orange?
Colors.indigo[300]: Colors.orange;
});

},
child: Icon(Icons.add,color: Colors.black,),
),

We will create a floatingActionButton(). In this button, we will add the height, width, and color on the setState(). When we run the application, we ought to get the screen’s output like the underneath screen video.

Final Output

AnimatedOpacity:

AnimatedOpacity animates changes in opacity, for example, how noticeable a widget is. An opacity of 0 makes a widget totally transparent, while a 1 opacity is completely obvious.

Animated Opacity

Opacity is really self-explanatory — it’s liable for refreshing the transparency of a UI part. AnimatedOpacity It is a widget on top of the default Opacity widget — it animates the progressions dependent on its opacity property.

AnimatedOpacity(
child: Container(
width: width,
height: height,
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(10),
),
),
opacity: opacity,
duration: Duration(milliseconds:600),
curve: Curves.easeInToLinear,
),

In AnimatedOpacity, you change the opacity and setState, and it automatically animates the opacity change.

floatingActionButton: FloatingActionButton(
onPressed: (){
setState(() {
opacity = opacity == 0.4 ? 1.0 : 0.4;
});

},
child: Icon(Icons.add,color: Colors.black,),
),

When the button is clicked, it simply changes opacity and setsState. When we run the application, we ought to get the screen’s output like the underneath screen video.

Final Output

AnimatedCrossFade:

AnimatedCrossFade is smooth progress starting with one widget then onto the next with a given duration. Flutter makes this simple by utilizing an AnimatedCrossFade widget.

Animated CrossFade

Cross-fade animations, step by step, become fade a UI part while at the same time blurring in another UI component. The AnimatedCrossFade is a widget that gives cross-fade progress when exchanging between two given child widgets.

AnimatedCrossFade(
firstChild: Container(
width: 350,
height: 250,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(10),
),
),
secondChild: Container(
width: 150,
height: 150,
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(80),
),
),
crossFadeState: state,
duration: Duration(seconds:1),
firstCurve: Curves.easeInToLinear,
secondCurve: Curves.easeInToLinear,
sizeCurve: Curves.bounceOut,
),

The transition is triggered by changing the crossFadeState.

Note: If the two children are of different sizes then it automatically transitions from one size to the other.

floatingActionButton: FloatingActionButton(
onPressed: (){
setState(() {
state = state == CrossFadeState.showFirst?
CrossFadeState.showSecond:CrossFadeState.showFirst;
});

},
child: Icon(Icons.add,color: Colors.black,),
),

We will show the first child, then the second child, in the transition state or vice versa. When we run the application, we ought to get the screen’s output like the underneath screen video.

Final Output

TweenAnimationBuilder:

To utilize TweenAnimationBuilderI set the timeframe that I need my animation to take with the duration parameter and the range of values that I need to animate between the Tween boundary. As the name proposes, an Tween object empowers you to determine a range of values that you need to animate between.

TweenAnimationBuilder

The tween also characterizes the animation’s objective value: When the widget first builds, it animates from TweenBegin to TweenEnd Another animation can be set off whenever by furnishing another tween with another TweenEnd value. The new animation runs from the current animation value (which might be Tween. end of the old tween, if that animation is finished) to Tween. End of the new tween.

TweenAnimationBuilder(
tween: Tween<double>(begin: 0, end: value),
duration: Duration(milliseconds: 500),
builder: (context, size, _){
return IconButton(
iconSize: size,
icon: Icon(Icons.star,color: Colors.blueGrey,),
onPressed: (){
setState(() {
value = value == 60 ? 200 : 60;
});
},
);
},

)

When we run the code, the icon will show, and when we tap the icon, it was animated, and the icon’s size was larger. When we run the application, we ought to get the screen’s output like the underneath screen video.

Final Output

Code File :

import 'package:flutter/material.dart';
import 'package:flutter_implicit_animation_dem/animated_container_screen.dart';
import 'package:flutter_implicit_animation_dem/animated_cross_fade_screen.dart';
import 'package:flutter_implicit_animation_dem/animated_opacity_screen.dart';
import 'package:flutter_implicit_animation_dem/tween_animation_builder_Screen.dart';

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

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

RaisedButton(
child: Text('Animated Container'),
color: Colors.blueGrey,
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => AnimatedContainerScreen()));
},
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
padding: EdgeInsets.all(13),
),
SizedBox(height: 8,),
RaisedButton(
child: Text('Animated Opacity'),
color: Colors.blueGrey,
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => AnimatedOpacityScreen()));
},
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
padding: EdgeInsets.all(13),

),
SizedBox(height: 8,),

RaisedButton(
child: Text('Animated Cross Fade'),
color: Colors.blueGrey,
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => AnimatedCrossFadeScreen()));
},
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
padding: EdgeInsets.all(13),


),
SizedBox(height: 8,),

RaisedButton(
child: Text('Tween Animation Builder',),
color: Colors.blueGrey,

onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => TweenAnimationBuilderScreen()));
},
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
padding: EdgeInsets.all(13),


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

Conclusion:

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

I hope this blog will provide you with sufficient information in Trying up the Implicit Animation widget in your flutter projects. We will show you what Implicit Animation, some property is, some types using in Implicit Animation, and make a demo program for working Implicit Animation in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter Implicit Animation Demo:

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


From Our Parent Company Aeologic

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

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

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

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

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


Staggered GridView In Flutter

A grid view is a graphical control component used to show things in the tabular structure. GridView is a widget in Flutter that shows the things in a 2-D array (two-dimensional rows and columns). As the name proposes, it will be utilized when we need to show things in a Grid. We can choose the ideal thing from the grid list by tapping on them.

This widget can contain text, images, icons and show in a grid layout contingent upon the user necessity. It is additionally alluded to as a scrollable 2-D array of widgets. Since it is scrollable, we can indicate the direction just in which it scrolls.

In this article, we will explore the Staggered GridView In Flutter. We will also implement a demo and create a staggered gridview using the flutter_staggered_grid_view package in your flutter applications.

flutter_staggered_grid_view | Flutter Package
A Flutter staggered grid view which supports multiple columns with rows of varying sizes. Configurable cross-axis count…pub.dev

Table Of Contents::

Flutter

Staggered GridView

Features

Code Implementation

Code File

Conclusion



Flutter:

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

Flutter is built using a modern framework that takes inspiration from React. We have learned before that everything in Flutter is a widget. The specialized architecture of flutter applications is a lot simpler, clean, and exact code structure.

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

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

Staggered GridView:

Flutter staggered gridview is utilized to show the pictures in a stunned manner, simply like social networking applications like pin-interest, which is unique concerning the normal grid view see which we have found in the beneath the video.https://www.youtube.com/embed/bLOtZDTm4H8Normal GridView

Staggered gridview consists of multiple columns with different rows with varying sizes used to display different sizes’ images.

Demo Module ::

Demo Output

This video shows how to create a staggered gridview in a flutter and shows how to staggered gridview will work when using the flutter_staggered_grid_view package, and then they will be shown on your device.

Features:

  • > Configurable cross-axis count or max cross-axis extent like the GridView
  • > Tiles can have a fixed main-axis extent or a multiple of the cell’s length.
  • > Configurable main-axis and cross-axis margins between tiles.
  • > SliverStaggeredGrid for using in a CustomScrollView.
  • > Staggered and Spannable grid layouts.

Implementation:

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:

flutter_staggered_grid_view: 
transparent_image:

Step 2: Import

import 'package:transparent_image/transparent_image.dart';
import'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';

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

Step 4: Enable AndriodX

Add this to your gradle.properties file:

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

How to implement code in dart file :

You need to implement it in your code respectively:

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

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

We will create an imageList URL in a list and define it on a staggered gridview.

StaggeredGridView.countBuilder(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 12,
itemCount: imageList.length,
itemBuilder: (context, index) {
},
),

This constructor fits for staggered grid views with an enormous (or boundless) number of children because the countBuilder is considered distinctly for those children that are really noticeable. Giving a non-null ‘itemCount’ improves the capacity of the StaggeredGridView to gauge the most extreme scroll extent.’itemBuilder’ will be called distinctly with indices greater than or equivalent to zero and not exactly ‘itemCount.

itemBuilder: (context, index) {
return Container(
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.all(
Radius.circular(15))
),
child: ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(15)),
child: FadeInImage.memoryNetwork(
placeholder: kTransparentImage,
image: imageList[index],fit: BoxFit.cover,
),
),
);
},

In this itemBuilder, we will return a container and add FadeInImage.memoryNetwork(). In this function, we will use placeholder and image. In the placeholder, we will add kTransparentImage.

transparent_image | Dart Package
A simple, transparent image. Represented as a Uint8List, which was originally extracted from the Flutter codebase (was…pub.dev

A simple, transparent image. Represented as a Uint8List, which was originally extracted from the Flutter codebase.

staggeredTileBuilder: (index) {
return StaggeredTile.count(1, index.isEven ? 1.2 : 1.8);
}

Now, we will add staggeredTileBuilder inside StaggeredGridView.countBuilder(). In this builder,we will return StaggererdTile.count(). In this count function user can add integer for crossAxisCellCount and number for mainAxisCellCount.

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

Final Output

Code File:

import 'package:flutter/material.dart';
import 'package:transparent_image/transparent_image.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';

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

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

@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
backgroundColor: Colors.white24,
appBar: AppBar(
title: Text("Flutter Staggered GridView Demo"),
centerTitle: true,
automaticallyImplyLeading: false,
),
body: Container(
margin: EdgeInsets.all(12),
child: StaggeredGridView.countBuilder(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 12,
itemCount: imageList.length,
itemBuilder: (context, index) {
return Container(
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.all(
Radius.circular(15))
),
child: ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(15)),
child: FadeInImage.memoryNetwork(
placeholder: kTransparentImage,
image: imageList[index],fit: BoxFit.cover,),
),
);
},
staggeredTileBuilder: (index) {
return StaggeredTile.count(1, index.isEven ? 1.2 : 1.8);
}),
),
),
);
}
}

Conclusion :

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

I hope this blog will provide you with sufficient information in Trying up the Staggered GridView in your flutter projects. We will show you what is Staggered GridView, some features using in Staggered GridView, and make a demo program for working Staggered GridView in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter Staggered_GridView_Demo:

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


From Our Parent Company Aeologic

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

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

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

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

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


Video Calling In Flutter

Flutter is a cross-platform development framework made by Google to permit a single codebase for the two iOS and Android applications. In every case, it’s better to communicate vis-à-vis as opposed to a textual discussion; it has an amazing effect on the subsequent individual. Likewise, present-day applications are additionally developing by making next edge highlights like having an ever-increasing number of approaches to allow users to associate with one another.

Mobile applications are currently evolved with an incorporated voice or video calling office, which empowers clients to cooperate without any problem. Allowing users to choose their method of communication holds more user base for any application.

In this article, we will explore the Video Calling In Flutter. We will also implement a demo and use the agora to make a video call using the agora_rtc_engine package in your flutter applications.

agora_rtc_engine | Flutter Package
中文 This Flutter plugin is a wrapper for Agora Video SDK. Agora.io provides building blocks for you to add real-time…pub. dev

Table Of Contents::

Introduction

Setup

Implementation

Device Permission

Code Implement

Code File

Conclusion



Introduction:

Real-time video talking drenches individuals in the sights and hints of human associations, keeping them occupied with your application longer. Bring significant distance minutes into the center with live video calls.

Agora’s Video Call can upgrade social applications with fun highlights like AR facial masks and audio cues. In contrast, business and instruction applications can profit by screen sharing, whiteboards, and that’s just the beginning. This model tells the best way to build a straightforward video calling application utilizing Agora, including:

  • > Join/leave a channel
  • > Mute/unmute
  • > Switch camera
  • > Layout multiple video views

Demo Module ::

Demo Screens

In this screenshot of the demo, first is the home page, and the other is the video calling page using Agora in your flutter applications.

Setup:

  1. Clone the Agora-Flutter-Quickstart. The Agora Flutter Quickstart is open-sourced and available on GitHub.
  2. Create an account on Agora.

3. After completing the registration process, you will be redirected to the dashboard page.

4. Navigate to Projects > Project List within the dashboard tree on the left.

5. Copy the App ID to your clipboard.

Implementation:

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:

agora_rtc_engine: 
permission_handler:

Step 2: Import

import 'package:agora_rtc_engine/rtc_engine.dart';
import 'package:permission_handler/permission_handler.dart';

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

Step 4: Enable AndriodX

Add this to your gradle.properties file:

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

Device Permission:

For Andriod:

Open the AndroidManifest.xml file and add the required device permissions to the file.

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<!-- The Agora SDK requires Bluetooth permissions in case users are using Bluetooth devices.-->
<uses-permission android:name="android.permission.BLUETOOTH" />

For Ios:

Open the info. plist and add:

  • Privacy — Microphone Usage Description, and add a note in the Value column.
  • Privacy — Camera Usage Description, and add a note in the Value column.

How to implement code in dart file :

You need to implement it in your code respectively:

const APP_ID = Your App_ID
const Token = Your Token

You will add your app id from the agora dashboard and copy the App ID to your clipboard. Yow will generate a temporary token from the agora console page, and in other options, you will use the primary certificate key to copy and paste on the token.

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

Row(
children: <Widget>[
Expanded(
child: TextField(
controller: _channelController,
decoration: InputDecoration(
errorText:
_validateError ? 'Channel name is mandatory' : null,
border: UnderlineInputBorder(
borderSide: BorderSide(width: 1),
),
hintText: 'Channel name',
),
))
],
),

We will create a text field for the channel name; without add any name, they will show an error and not navigate to another page.

Now, we will make a button:

Padding(
padding: const EdgeInsets.symmetric(vertical: 20),
child: Row(
children: <Widget>[
Expanded(
child: RaisedButton(
onPressed: onJoin,
child: Text('Join'),
color: Colors.blueAccent,
textColor: Colors.white,
),
)
],
),
)

We will create a RaisedButton method. In this method, we will onJoin function. We will describe the function below:

Future<void> onJoin() async {
setState(() {
_channelController.text.isEmpty
? _validateError = true
: _validateError = false;
});
if (_channelController.text.isNotEmpty) {
await _handleCameraAndMic(Permission.camera);
await _handleCameraAndMic(Permission.microphone);
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => VideoCall(
channelName: _channelController.text,
role: _role,
),
),
);
}
}

In this Function, we will add a camera and mic permission for users. Anyone user can mic off/on, and camera switch front/back.

That’s it. You’ve successfully integrated the video calling in a flutter. When we run the application, we ought to get the screen’s output like the underneath video capture.

Final Output

When you run your application, you will see a screen requesting a channel name. Enter a random channel name that you need to make. Afterward, another device running a similar application joins the channel by entering a similar channel name. You will find that your video calling is great, and you are presently a video call with different devices.

Code File:

https://gist.github.com/ShaiqAhmedkhan/8a5658b2a7365f56d6effd8a33b16612#file-home-dart

Conclusion:

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

I hope this blog will provide you with sufficient information in Trying up Video Calling in your flutter projects. We will show you the agora is?, set it up in our project, and work on a video calling using agora in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter Video Call Demo:

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


From Our Parent Company Aeologic

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

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

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

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

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


Share Data To Another Application In Flutter

Flutter is actually a phenomenal tool to build mobile applications. Flutter is a free and open-source tool to develop mobile, desktop, web applications with a single code base. The specialized architecture of flutter applications is a lot simpler, clean, and exact code structure. The flutter developer’s community group is continually developing, assisting us with giving a superior encounter, and creating different modules. Modules are extraordinary, assist us with executing different usefulness with lesser code and time.

Flutter is built using a modern framework that takes inspiration from React. We have learned before that everything in Flutter is a widget. 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.

In this article, we will explore the Share Data To Another Application In Flutter. We will also implement a demo and share link, text, and image to another application using the share package in your flutter applications.

share | Flutter Package
A Flutter plugin to share content from your Flutter app via the platform’s share dialog. Wraps the ACTION_SEND Intent…pub. dev

Table Of Contents::

Share Data

Implementation

Code Implement

Code File

Conclusion



Share Data

We share information from our application to another, much the same as when you hit the button and share text, any link, and an image inside your gallery. The framework will request that you select an application to share it.

Demo module ::

Demo Module

We will create two buttons on this screen and an additional icon for an image to share text, link, and image to another application in your app, which will call the below three logics and do our work.

Implementation :

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies:

share: 
image_picker:

Step 2: Import

import 'package:image_picker/image_picker.dart';
import 'package:share/share.dart';

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

Step 4: Enable AndriodX

Add this to your gradle. Properties file:

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

How to implement code in dart file :

You need to implement it in your code respectively:

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

Share Data With Fields

In this screen, we will share the data with fields, like you will enter any link or text on this field, then they will be shared on another application, and your system will ask you to select an application to share it.

TextField(
decoration: const InputDecoration(
labelText: 'Share text:',
labelStyle: TextStyle(color: Colors.blue),
hintText: 'Enter some text and/or link to share',
),
maxLines: 2,
onChanged: (String value) => setState(() {
text = value;
}),
),
TextField(
decoration: const InputDecoration(
labelText: 'Share subject:',
labelStyle: TextStyle(color: Colors.blue),

hintText: 'Enter subject to share (optional)',
),
maxLines: 2,
onChanged: (String value) => setState(() {
subject = value;
}),
),

Make two text fields; in this text field, we will use the onchanged method and set the string is equal to the value.

String text = '';
String subject = '';

We will make a button, and onPressed method, we will apply the text as empty then, the button will not work, and we will be called _onShareData() widget on this button.

Builder(
builder: (BuildContext context) {
return RaisedButton(
color: Colors.orangeAccent[100],
child: const Text('Share'),
onPressed: text.isEmpty
? null
: () => _onShareData(context),
);
},
),

Let’s declare _onShareData() widget

_onShareData(BuildContext context) async {

final RenderBox box = context.findRenderObject();
{
await Share.share(text,
subject: subject,
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
}
}

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

Final Output

Now, we will share the data with empty fields:

Share Data With Empty Fields

In this screen, we will share the data with empty fields, like you will not enter any link or text on this field, then they will be shared on another application, and your system will ask you to select an application to share it.

We will make a button and onPressed method called _onShareWithEmptyFields() widget on this button.

Builder(
builder: (BuildContext context) {
return RaisedButton(
color: Colors.orangeAccent[100],
child: const Text('Share With Empty Fields'),
onPressed: () => _onShareWithEmptyFields(context),
);
},
),

Let’s declare _onShareWithEmptyFields() widget

_onShareWithEmptyFields(BuildContext context) async {
await Share.share("text");
}

We will locally add any data; when we run the application, we ought to get the screen’s output like the underneath screen video.

Final Output

Now, share the image inside our gallery:

Share Image Inside Our Gallery

In this screen, we will share the image inside your gallery, and we will add an icon button and image text. We will apply an image picker to pick from our gallery and share on another application on this tap function, and your system will ask you to select an application to share it.

ListTile(
leading: Icon(Icons.add),
title: Text("Add image"),
onTap: () async {
final imagePicker = ImagePicker();
final pickedFile = await imagePicker.getImage(
source: ImageSource.gallery,
);
if (pickedFile != null) {
setState(() {
imagePaths.add(pickedFile.path);
});
}
},
),

We will trim the string image path

String pickedFile = imagePaths ==null?"":imagePaths.toString();
String trimmedFileName = pickedFile.split("/").last;

Same button and onPressed method we will apply the text as empty and image path also empty then the button will not work, and we will be called _onShareData() widget on this button.

Builder(
builder: (BuildContext context) {
return RaisedButton(
color: Colors.orangeAccent[100],
child: const Text('Share'),
onPressed: text.isEmpty && imagePaths.isEmpty
? null
: () => _onShareData(context),
);
},
),

Let’s declare _onShareData() widget, we will add condition on the same widget.

_onShareData(BuildContext context) async {

final RenderBox box = context.findRenderObject();

if (imagePaths.isNotEmpty) {
await Share.shareFiles(imagePaths,
text: text,
subject: subject,
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
} else {
await Share.share(text,
subject: subject,
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
}
}

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

Final Output

Code File

https://gist.github.com/ShaiqAhmedkhan/6866431a2029d22c132fbc4ea3d4ee62#file-share_data-dart

Conclusion:

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

I hope this blog will provide you with sufficient information in Trying up Share Data To Another Application in your flutter projects. We will show share the data with fields, without fields, and images inside your gallerand shared on another application. Your system will ask you to select an application to share it and make a demo program for share data in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤


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

Clap 👏 If this article helps you.

find the source code of the Flutter Share Data Demo:

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


From Our Parent Company Aeologic

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

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

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

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

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