Google search engine
Home Blog Page 53

Modal Bottom Sheet In Flutter

0

In this blog, we will explore the Modal Bottom Sheet Widget In Flutter. We will also implement a demo of the Modal Bottom Sheet Widget, and describes its properties. and how to use them in your flutter applications.


Table Of Contents::

Flutter

Modal Bottom Sheet

Code Implement

Code File

Conclusion


Flutter :

“ Flutter is Google’s UI toolkit that helps you build beautiful and natively combined applications for mobile, web, and desktop in a single codebase in record time It means that you can use one programming language and one codebase to create two different apps (for iOS and Android)”.

Modal Bottom Sheet :

The bottom sheet material is a very good component given by design. It is like a dialog that is open from the bottom. We use the sheet below when we have to show some options for the user to proceed. And here you can use any widget as per your requirement.

Two Required Properties of the Modal Bottom Sheet :

BuildContext: The build context for a particular widget can change the location over time. Because it helps the creation method to determine which widget it is going to pull and it also helps in determining the position of the widget to be pulled in the widget tree.

WidgetBuilder: The builder widget needs to pass a widget, but only has a function that returns the widget.

Some Optional Properties of the Modal Bottom Sheet :

  1. shape: Using shape properties, we can give a circular border and color of the border according to our own.
  2. background: Using shape properties, we can give a circular border and color of the border according to our own.
  3. elevation: The elevation property is used to raise the shadow of the bottom sheet and it is an optional property.

Demo Module :

Code Implementation :

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

First of all, we will create one button on the modal bottom sheet page screen. And we will open the sheet at the click.

Now, at the click of a button, we will show the bottom sheet in which the column has been taken inside the bottom sheet and used the List Tile widget inside the column widget, in which some images and titles are displayed.

Let us understand this with the help of a reference.

showModalBottomSheet(
context: context,
builder: (context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
leading: new Icon(Icons.photo),
title: new Text('Photo'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: new Icon(Icons.music_note),
title: new Text('Music'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: new Icon(Icons.videocam),
title: new Text('Video'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: new Icon(Icons.share),
title: new Text('Share'),
onTap: () {
Navigator.pop(context);
},
),
],
);
});

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

Code File:

import 'package:flutter/material.dart';

class ModalBottomSheet extends StatefulWidget {
@override
_ModalBottomSheetState createState() => _ModalBottomSheetState();
}

class _ModalBottomSheetState extends State<ModalBottomSheet> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Modal Bottom Sheet',
style: TextStyle(color: Colors.white),
),
centerTitle: true,
),
body: Container(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"MODAL BOTTOM SHEET EXAMPLE",
style: TextStyle(
fontStyle: FontStyle.italic,
letterSpacing: 0.4,
fontWeight: FontWeight.w600),
),
SizedBox(
height: 20,
),
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0))),
onPressed: () {
showModalBottomSheet(
context: context,
builder: (context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
leading: new Icon(Icons.photo),
title: new Text('Photo'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: new Icon(Icons.music_note),
title: new Text('Music'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: new Icon(Icons.videocam),
title: new Text('Video'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: new Icon(Icons.share),
title: new Text('Share'),
onTap: () {
Navigator.pop(context);
},
),
],
);
});
},
padding:
EdgeInsets.only(left: 30, right: 30, top: 15, bottom: 15),
color: Colors.pink,
child: Text(
'Click Me',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
letterSpacing: 0.6),
),
),
],
),
),
);
}
}

Conclusion:

In this article, I have explained a Modal Bottom Sheet demo, which you can modify and experiment with according to your own. This little introduction was from the Modal Bottom Sheet widget from our side.

I hope this blog will provide you with sufficient information in Trying up the Modal Bottom Sheet widget in your flutter project. We will show you the Modal Bottom Sheet is?, and working on it in your flutter applications, So please try it.

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

Clap 👏 If this article helps you.

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

❤ ❤ Thanks for reading this article ❤❤

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 Facebook, GitHub, Twitter, 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.

Expansion Tile In Flutter

0

Hello friends, I will talk about my new blog on Expansion Tile Widget In Flutter. We will also implement a demo of the Expansion Tile Widget, and describes its properties, and how to use them in your flutter applications. So let’s get started.


Table of Contents :

Flutter

Expansion Tile Widget

Code Implementation

Code File

Conclusion



Flutter :

“ Flutter is Google’s UI toolkit that helps you build beautiful and natively combined applications for mobile, web, and desktop in a single codebase in record time ,Flutter offers great developer tools, with amazing hot reload”

Expansions Tile Widget :

The expansion tile widget is a very useful widget. This widget lets you create a detailed tile that can be used as part of a list view. We need to show some detailed information on the list for many applications, but for this, we do not have enough space to expand and collapse the list. Then we can create it with the extension tile widget.

Following Some Properties of the Expansions Tile :

  • title — The Title property allows you to choose the title for the expansion tile widget. This will be an item that will always be visible to the user.
  • children — The children’s property holds any number of widgets. It can be a card for a simple text. And the extension tiles will know this only by clicking on the title of the widget.
  • leading — The leading property is used on the first left side of the title, just as the leading list tile widget uses leading, similarly this feature works here.
  • trailing — Use the trailing property to the right after the title, you can use text and icons in this property.
  • backgroundColor — Using the background property gives color to the background of the expanded tile. Note, it assigns a color to the extended tile, not the title.

Demo Module :

In this screen, we will create a list with the help of a list view builder in which the expansion tile widget will be used and initialize the list data into the

Code Implementation :

You need to implement it in your code respectively:

Create a new dart file called expansion_title_demo.dart inside the libfolder.

In this screen, we will create a list with the help of a list view builder in which the expansion tile widget will be used and initialize the list data into the expansion tile widget. Let’s understand it with the help of a reference.

ExpansionTile(
title: Text(
items.playerName,
style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w500),
),
children: <Widget>[
ListTile(
title: Text(
items.description,
style: TextStyle(fontWeight: FontWeight.w700),
),
)
],
),

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

Code File:

import 'package:flutter/material.dart';
import 'package:flutter_expansion_tile_demo/Constants/Constants.dart';
import 'package:flutter_expansion_tile_demo/model/month_model.dart';

class ExpansionTileDemo extends StatefulWidget {
@override
_ExpansionTileDemoState createState() => _ExpansionTileDemoState();
}

class _ExpansionTileDemoState extends State<ExpansionTileDemo> {
List<MonthModel> monthModel;

@override
void initState() {
monthModel = Constants.getMonthModel();
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('Expansion Tile Demo'),
),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
child: ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
physics: BouncingScrollPhysics(),
itemCount: monthModel.length,
itemBuilder: (BuildContext context, int index) {
return _buildPlayerModelList(monthModel[index]);
},
),
),
);
}

Widget _buildPlayerModelList(MonthModel items) {
return Card(
child: ExpansionTile(
title: Text(
items.playerName,
style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w500),
),
children: <Widget>[
ListTile(
title: Text(
items.description,
style: TextStyle(fontWeight: FontWeight.w700),
),
)
],
),
);
}
}

Conclusion:

In this article, I have explained an Expansion Tile in a flutter, which you can modify and experiment with according to your own, this little introduction was from the Expansion Tile demo from our side.

I hope this blog will provide you with sufficient information in Trying up the Expansion Tile in your flutter project. We showed you what the Expansion Tile is and work on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

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

Clap 👏 If this article helps you.

From Our Parent Company Aeologic

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

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

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

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, 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.

Vertical Card Pager In Flutter

0

The flutter widget is built using a modern framework. It is like a reaction. In this, we start with the widget to create any application. Each component in the screen is a widget. The widget describes what his outlook should be given his present configuration and condition. Widget shows were similar to its idea and current setup and state. Flutter is a free and open-source tool to develop mobile, desktop, web applications with a single code base.

In this blog, we will explore the Vertical Card Pager In Flutter. We will also implement a demo of the Vertical Card Pager, and describes its properties. and how to use them in your flutter applications. So let’s get started.


Table of Contents :

Vertical Card Pager

Implementation

Code Implementation

Code File

Conclusion



Vertical Card Pager :

A vertical card pager displays an animated card list in the application by scrolling vertically. It is a very beautiful and dynamic card view pager. We can define the card pager list differently. Let us understand in detail about its properties

vertical_card_pager | Flutter Package
Add this to your package’s pubspec.yaml file: dependencies: vertical_card_pager: ^1.4.0 You can install packages from…pub.dev

The following are the basic properties of the Vertical Card Pager.

  1. titles: The title property is used to display some of its details in the card, it is a type of list.
  2. align: You can use the align property to arrange the list item, according to it according to left, centre and right.
  3. images: We use the images property to display the image in the list item, it is a type of list.
  4. textStyle: Using the text style property, we can reduce the size of the text of the title and change the color of the text.

Demo Module :

Implementation :

You need to implement it in your code respectively :

Step 1: Add dependencies.

Add dependencies to pubspec — yaml file.

dependencies:
vertical_card_pager: ^1.4.0

Step 2: import the package :

import 'package:vertical_card_pager/vertical_card_pager.dart';

Step 3: Run flutter package get

How to implement code in dart file :

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

First of all, we have created a list of the titles in which we have named the tiles.

final List<String> titles = [
"RED",
"YELLOW",
"CYAN",
"BLUE",
"GREY",
];

Before using this widget, an image variable has been defined which is list type. In this, we have given the color of the items which have been defined in the images property.

final List<Widget> images = [
Container(
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
),
Container(
decoration: BoxDecoration(
color: Colors.yellow,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
),
Container(
decoration: BoxDecoration(
color: Colors.cyan,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
),
Container(
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
),
Container(
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
),
];

Before using this widget, we have created a container inside which uses the vertical card widget, in this, we have given the color of the item which is of list type in its titles and image properties and centre the list item.

These are snapshots image after running the app.

Code File :

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

class VerticalCardPagerDemo extends StatefulWidget {
@override
_VerticalCardPagerDemoState createState() => _VerticalCardPagerDemoState();
}

class _VerticalCardPagerDemoState extends State<VerticalCardPagerDemo> {
final List<String> titles = [
"RED",
"YELLOW",
"CYAN",
"BLUE",
"GREY",
];

@override
Widget build(BuildContext context) {
final List<Widget> images = [
Container(
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
),
Container(
decoration: BoxDecoration(
color: Colors.yellow,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
),
Container(
decoration: BoxDecoration(
color: Colors.cyan,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
),
Container(
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
),
Container(
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
),
];
return Scaffold(
appBar: AppBar(
title: Text(
'Vertical Card Pager',
style: TextStyle(color: Colors.white),
),
centerTitle: true,
),
body: SafeArea(
child: Expanded(
child: Container(
child: VerticalCardPager(
textStyle:
TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
titles: titles,
images: images,
onPageChanged: (page) {},
align: ALIGN.CENTER,
onSelectedItem: (index) {},
),
),
),
),
);
}
}

Conclusion :

In the article, I have explained the basic structure of Vertical Card Pager in a flutter; you can modify this code according to your choice. This was a small introduction to Vertical Card Pager 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 Vertical Card Pager in your flutter project. We will show you the Vertical Card Pager is?, and work on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

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

Clap 👏 If this article helps you.

From Our Parent Company Aeologic

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

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

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

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, 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.

Swiper In Flutter

In this article, we will explore the Swiper in flutter using the fluter_swiper_package. With the help of the package, we can easily achieve flutter animated Swiper. So let’s get started.

We will implement a demo of the Swiper that can be easily embedded in your flutter applications.

flutter_swiper | Flutter Package
中文说明 The best swiper for flutter , with multiple layouts, infinite loop. Compatible with Android & iOS. We are using…pub.dev


Table Of Contents :

Swiper

Implementation

Code Implement

Code File

Conclusion


Swiper :

Swiper flutter has a touch slider plugin using which a user can slide any view like an image slider. Using the swiper library we can use different types of layouts. This library is compatible with both android and ios.

Some Basic Properties:

  1. scrollDirection: The scroll direction property is to give the direction of the scroll that we can scroll the list in the vertical or horizontal direction.
  2. autoplay: We use the autoplay property when we have to move one of the lists, it is of type bool.
  3. physics: We use the Physics property to do scrolling. It determines when the user reaches the maximum scroll limit or stops scrolling.
  4. controller: The controller is used to control the index of the swiper, start or stop autoplay.
  5. index: The index property is the index number of the initial slide that initiates the slide and updates the previous index.
  6. loop: We can use the loop property to continuously rotate the list

Demo Module :

Implementation :

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies :

flutter_swiper: ^1.1.6

Step 2: Importing

import 'package:flutter_swiper/flutter_swiper.dart';

Step 3: Run flutter package get

Code Implementation :

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

First of all, we have created a home page screen in which four buttons have been created and at the click of each button, a new page will open in which we have shown the swiper list in different ways.

Default Swiper :

In the default swiper, we have listed an image and used the default layout in the swiper class whose scroll direction is horizontal. Let us understand this in detail with the help of a reference.

Swiper(
scrollDirection:Axis.horizontal,
itemBuilder:(BuildContext context, int index) {
return _buildSwiperList(imageModel[index],index);
},
itemCount: imageModel.length,
// pagination: new SwiperPagination(),
layout: SwiperLayout.DEFAULT,
),

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

Stack Swiper :

In the stack swiper, we have listed an image and used the stack layout in the swiper class in which the items are positioned on top of each other which allows the items to overlap and render them from bottom to top. Let us understand this in detail with the help of a reference.

Swiper(
itemBuilder:(BuildContext context, int index) {
return _buildSwiperList(imageModel[index],index);
},
itemCount: imageModel.length,
itemWidth:DeviceSize.width(context),
layout: SwiperLayout.STACK,
),

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

Tinder Swiper :

In tinder swiper, we have listed an image and used the Tinder layout in the swiper class in which the item is positioned on top of each other which swaps the item very quickly. Let us understand this in detail with the help of a reference.

Swiper(
itemBuilder:(BuildContext context, int index) {
return _buildSwiperList(imageModel[index],index);
},
itemWidth:DeviceSize.width(context),
itemHeight:DeviceSize.height(context)/3,
itemCount: imageModel.length,
layout: SwiperLayout.TINDER,
// control:SwiperControl(),
),

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

Pagination Swiper :

In this screen, we have used the pagination property, in which a list of an image whose layout property is of custom type has used animation in its custom layout option. Let us understand this in detail with the help of a reference.

Swiper(
itemBuilder: (BuildContext context, int index) {
return _buildSwiperList(imageModel[index], index);
},

itemWidth: DeviceSize.width(context),
itemHeight: DeviceSize.height(context) / 3,
itemCount: imageModel.length,
layout: SwiperLayout.CUSTOM,
pagination: SwiperPagination(),
customLayoutOption:
new CustomLayoutOption(startIndex: -1, stateCount: 3)
.addRotate([-45.0 / 180, 0.0, 45.0 / 180]).addTranslate([
new Offset(-340.0, -40.0),
new Offset(0.0, 0.0),
new Offset(340.0, -40.0)
]),
// control:SwiperControl(),
),

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

Code File :

import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:flutter_swiper_demo/Constants/Constants.dart';
import 'package:flutter_swiper_demo/modal/image_model.dart';
import 'package:flutter_swiper_demo/themes/device_size.dart';

class CustomSwiperPagination extends StatefulWidget {
@override
_CustomSwiperPaginationState createState() => _CustomSwiperPaginationState();
}

class _CustomSwiperPaginationState extends State<CustomSwiperPagination> {
List<ImageModel> imageModel;

@override
void initState() {
imageModel = Constants.getImageModel();
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Swiper Pagination'),
),
body: Center(
child: Container(
height: DeviceSize.height(context) / 3,
width: DeviceSize.width(context),
alignment: Alignment.center,
child: Swiper(
itemBuilder: (BuildContext context, int index) {
return _buildSwiperList(imageModel[index], index);
},

itemWidth: DeviceSize.width(context),
itemHeight: DeviceSize.height(context) / 3,
itemCount: imageModel.length,
layout: SwiperLayout.CUSTOM,
pagination: SwiperPagination(),
customLayoutOption:
new CustomLayoutOption(startIndex: -1, stateCount: 3)
.addRotate([-45.0 / 180, 0.0, 45.0 / 180]).addTranslate([
new Offset(-340.0, -40.0),
new Offset(0.0, 0.0),
new Offset(340.0, -40.0)
]),
// control:SwiperControl(),
),
),
),
);
}

Widget _buildSwiperList(ImageModel items, int index) {
return Container(
margin: EdgeInsets.only(left: 15, right: 15),
height: DeviceSize.height(context) / 6,
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(10)),
child: Image.asset(
items.img,
fit: BoxFit.fill,
),
),
);
}
}

Conclusion :

In this article, I have explained a Swiper in a flutter, which you can modify and experiment with according to your own, this little introduction was from the swiper demo from our side.

I hope this blog will provide you with sufficient information in Trying up the Percent Indicator in your flutter project. We will show you the swiper is?, and work on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

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

Clap 👏 If this article helps you.


From Our Parent Company Aeologic

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

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

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

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, 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.


PhotoView InFlutter

0

In this article, we will explore the PhotoView in flutter using the fluter_photo_view_package. With the help of the package, we can easily achieve flutter animated Swiper. So let’s get started.

photo_view | Flutter Package
A simple zoomable image/content widget for Flutter. PhotoView enables images to become able to zoom and pan with user…pub.dev


Table Of Contents :

Flutter

PhotoView

Implementation

Code Implement

Code File

Conclusion


Flutter :

“ Flutter is Google’s UI toolkit that helps you build beautiful and natively combined applications for mobile, web, and desktop in a single codebase in record time ,Flutter offers great developer tools, with amazing hot reload”

PhotoView :

Photo View Widget in Flutter is a simple zoomable image or any content widget in flutter application development. Users of the app can rotate and zoom the image. The package provides a loading property that we use for the time it takes for any image until then the loading indicator will rotate. Let us understand the properties in detail.

Some Basic Properties:

  1. scrollDirection: The scroll direction property is to give the direction of the scroll that we can scroll the list in the vertical or horizontal direction.
  2. enableRotation: The enable rotation property is used to rotate the image, it is a type of bool.
  3. physics: We use the Physics property to do scrolling. It determines when the user reaches the maximum scroll limit or stops scrolling.
  4. controller: The Controller properties are a way to control the change factors of PhotoView and listen for its updates.
  5. backgroundDecoration: The index property is the index number of the initial slide that initiates the slide and updates the previous index.
  6. loadingBuilder: The loadingBuilder property is a focused circular progress indicator that is called by photoview into the screen the image.
  7. maxScale: The maxScale property defines the maximum size of the image in which the image will be allowed to take, it is proportional to the original image size.
  8. minScale: The minScale property defines the maximum size of the image in which the image will be allowed to take, it is proportional to the original image size.

Demo Module :

Implementation :

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies :

dependencies:   
photo_view: ^0.11.0

Step 2: Importing

import 'package:photo_view/photo_view.dart';

Step 3: Run flutter package get

Code Implementation :

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

First of all, we have created a list of the image.

final imageList = [
'assets/images/villa_img2.jpg',
'assets/images/resort_1.jpg',
'assets/images/resort_3.jpg',
'assets/images/getRadyForSummer.jpg',
];

Before using the PhotoView widget we created a container inside which the PhotoViewGallery.builder class is used. This class will create an image list. Inside the builder class is the PhotoViewGalaryPageOptions class, which has set the scale of the image and the type of enableRotation is true which we image can rotate.

PhotoViewGallery.builder(
itemCount: imageList.length,
builder: (context, index) {
return PhotoViewGalleryPageOptions(
imageProvider:AssetImage(imageList[index],),
minScale: PhotoViewComputedScale.contained * 0.8,
maxScale: PhotoViewComputedScale.covered * 2,
);
},
scrollPhysics: BouncingScrollPhysics(),
backgroundDecoration: BoxDecoration(
borderRadius:BorderRadius.all(Radius.circular(20)),
color: Theme.of(context).canvasColor,
),
enableRotation:true,
loadingBuilder: (context, event) => Center(
child: Container(
width: 30.0,
height: 30.0,
child: CircularProgressIndicator(
backgroundColor:Colors.orange,
value: event == null
? 0
: event.cumulativeBytesLoaded / event.expectedTotalBytes,
),
),
),
),

These are snapshots image after running the app.

When we run the application and rotate the image, this kind of output appears on the screen.

Code File :

import 'package:flutter/material.dart';
import 'package:flutter_photo_view_demo/themes/device_size.dart';
import 'package:photo_view/photo_view.dart';
import 'package:photo_view/photo_view_gallery.dart';

class PhotoViewDemo extends StatefulWidget {
@override
_PhotoViewDemoState createState() => _PhotoViewDemoState();
}

class _PhotoViewDemoState extends State<PhotoViewDemo> {
final imageList = [
'assets/images/villa_img2.jpg',
'assets/images/resort_1.jpg',
'assets/images/resort_3.jpg',
'assets/images/getRadyForSummer.jpg',
];

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("PhotoView Demo"),
),
// add this body tag with container and photoview widget
body: Container(
height: DeviceSize.height(context),
margin: EdgeInsets.only(left: 15, right: 15),
width: DeviceSize.width(context),
child: PhotoViewGallery.builder(
itemCount: imageList.length,
builder: (context, index) {
return PhotoViewGalleryPageOptions(
imageProvider: AssetImage(
imageList[index],
),
minScale: PhotoViewComputedScale.contained * 0.8,
maxScale: PhotoViewComputedScale.covered * 2,
);
},
scrollPhysics: BouncingScrollPhysics(),
backgroundDecoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
color: Theme.of(context).canvasColor,
),
enableRotation: true,
loadingBuilder: (context, event) => Center(
child: Container(
width: 30.0,
height: 30.0,
child: CircularProgressIndicator(
backgroundColor: Colors.orange,
value: event == null
? 0
: event.cumulativeBytesLoaded / event.expectedTotalBytes,
),
),
),
),
),
);
}
}

Conclusion :

In this flutter article, I have explained a PhotoView in a flutter, which you can modify and experiment with according to your own, this little introduction was from the PhotoView demo from our side.

I hope this blog will provide you with sufficient information in Trying up the PhotoView in your flutter project. We will show you the PhotoView is?, and work on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

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

Clap 👏 If this article helps you.


From Our Parent Company Aeologic

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

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

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

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, 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.


ReadMore In Flutter

Flutter is a portable UI toolkit. In other words, it’s a comprehensive app Software Development toolkit (SDK) that comes complete with widgets and tools. Flutter is a free and open-source tool to develop mobile, desktop, web applications. Flutter is a cross-platform development tool. This means that with the same code, we can create both ios and android apps. This is the best way to save time and resources in our entire process. In this, hot reload is gaining traction among mobile developers. Allows us to quickly see the changes implemented in the code with hot reload

Hello friends, I will talk about my new blog on ReadMore in flutter using the read_more_package. We will also implement a demo of ReadMore, and describes its properties, and how to use them in your flutter applications. So let’s get started.

Readmore | Flutter Package
example/lib/example.dart import ‘package:readmore/readmore.dart’; import ‘package:flutter/material.dart’; void main() {…pub.dev


Table of Contents :

Read More

Code Implementation

Code File

Conclusion


ReadMore :

Use the Read More plugin when we have to show two-three lines of the entire paragraph, the rest of the text is hidden. To create such a view, we use the properties of the Read More plugin and the user can give two texts anything. Which can be clicked to show and less the text of the paragraph.

The following are the basic properties of the Read More.

  • style — Use the style properties to change the text size color and style etc.
  • trimLines — The trimlines property is used to show some two-three lines of paragraph text.
  • trimCollaspsedText — The trimCollaspsedText property is used to show paragraph text, in which the user can give some text according to it which is clickable.
  • trimExpandedText — The trimExpandedText property is used to show paragraph text, in which the user can give some text according to it which is clickable.
  • trimMode — Using the trimMode property we can change the mode of paragraph text to line length etc. Length mode shows the entire text and line mode shows some line.
  • colorClickableText — The colorClickable Text property is used to change the color of the trimCollaspsedText and trimExpandedText clickable text. The user can change the color of the text according to it.

Demo Module :

Implementation :

You need to implement it in your code respectively :

Step 1: Add dependencies.

Add dependencies to pubspec — yaml file.

dependencies:   
readmore: ^1.0.1

Step 2: import the package :

import 'package:readmore/readmore.dart';

Step 3: Run flutter package get

How to implement code in dart file :

Create a new dart file called read_more_demo.dart inside the libfolder.

First of all, we will create a list readmoremodel named and define it in initState() method.

List <ReadMoreModel>readMoreModel;
@override
void initState() {
readMoreModel=Constants.getReadMoreModel();
super.initState();
}

Now we will create a container in the body and add the ListView.Builder() inside it and define the Readmore item list.

Container(
height:DeviceSize.height(context),
width:DeviceSize.width(context),
margin:EdgeInsets.only(left:10,right:10,top:10),
child:ListView.builder(
itemCount:readMoreModel.length,
scrollDirection:Axis.vertical,
itemBuilder:(BuildContext context, int index) {
return _buildReadMoreModelList(readMoreModel[index],index);
},
),
),

Now we will create a container in the body and add the ListView.Builder() inside it and define the Readmore item list.

In this widget, we will create a container and take the ListView.Builder() widget inside it and define the ReadMoreText() plugin and show the list which has some text paragraphs when the user presses the Readmore and less text then the text opens downwards

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

Code File :

import 'package:flutter/material.dart';
import 'package:flutter_read_more_demo/Constants/Constants.dart';
import 'package:flutter_read_more_demo/modal/read_more_model.dart';
import 'package:flutter_read_more_demo/themes/device_size.dart';
import 'package:readmore/readmore.dart';

class ReadMoreDemo extends StatefulWidget {
@override
_ReadMoreDemoState createState() => _ReadMoreDemoState();
}

class _ReadMoreDemoState extends State<ReadMoreDemo> {
List<ReadMoreModel> readMoreModel;

@override
void initState() {
readMoreModel = Constants.getReadMoreModel();
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Read More Demo'),
centerTitle: true,
),
body: Container(
height: DeviceSize.height(context),
width: DeviceSize.width(context),
margin: EdgeInsets.only(left: 10, right: 10, top: 10),
child: ListView.builder(
itemCount: readMoreModel.length,
scrollDirection: Axis.vertical,
itemBuilder: (BuildContext context, int index) {
return _buildReadMoreModelList(readMoreModel[index], index);
},
),
),
);
}

Widget _buildReadMoreModelList(ReadMoreModel items, int index) {
return Container(
// height:DeviceSize.height(context),
child: Card(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: ReadMoreText(
items.title,
trimLines: 2,
colorClickableText: Colors.pink,
trimMode: TrimMode.Line,
trimCollapsedText: '..Read More',
style: TextStyle(fontSize: 13),
trimExpandedText: ' Less',
),
),
/* Divider(
color: const Color(0xFF167F67),
),,*/
),
);
}
}

Conclusion :

In the article, I have explained the basic structure of Read More in a flutter; you can modify this code according to your choice. This was a small introduction to Read More 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 Read More in your flutter project. We will show you the Read More is?, and work on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

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

Clap 👏 If this article helps you.

From Our Parent Company Aeologic

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

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

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

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, 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.

LayoutBuilder Widget In Flutter

0

Flutter has made it quite easy to develop complex UIs for developers. Pulsation automated testing empowers you to meet high responsiveness in your application as it helps in discovering bugs and various issues in your application. Pulsation is a tool for developing mobile, desktop, web applications with a code & is a free and open-source tool.

In this blog, we will explore the Layout Builder In Flutter. We will also implement a demo of the Layout Builder. and how to use them in your flutter applications. So let’s get started.


Table of Contents :

Flutter

Layout Builder

Code Implementation

Code File

Conclusion


Flutter :

“ Flutter is Google’s UI toolkit that helps you build beautiful and natively combined applications for mobile, web, and desktop in a single codebase in record time ,Flutter offers great developer tools, with amazing hot reload”

Layout Builder :

LayoutBuilder helps to create a widget tree in the widget flutter which can depend on the size of the original widget. flutter can take the layout builder as a parameter. It has two parameters. build context and Boxconstrant. BuildContext refers to a widget. But box constraint is more important, it gives the width to the parent widget which is used to manage the child according to the size of the parent.

Note: The main difference between Media Query and LayoutBuilder is that Media Query uses the full context of the screen instead of the size of your particular widget. While the layout builder can determine the maximum width and height of any widget.

Demo Module :

Code Implementation :

You need to implement it in your code respectively:

Create a new dart file called layout_builder_demo.dart inside the libfolder.

Now, we will describe the LayoutBuilder() class.

Before using the LayoutBuilder class, we have taken a container widget in which the LayoutBuilder is used. The layout builder has three containers, all of which have different colors and text and has a condition. If the width of the device size given by the user is greater than 480 then two container boxes will appear which will be visible when the tablet or screen is rotated horizontally. otherwise, the normal container will be visible. Let us understand this in detail with the help of a reference.

LayoutBuilder(
builder: (BuildContext ctx, BoxConstraints constraints) {
// if the screen width >= 480 i.e Wide Screen
if (constraints.maxWidth >= 480) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
padding:EdgeInsets.symmetric(horizontal: 8),
alignment: Alignment.center,
height: constraints.maxHeight * 0.3,
margin: EdgeInsets.fromLTRB(10.0, 0.0,10.0,0.0),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Text(
'Left Wide Screen',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
Container(
padding:EdgeInsets.symmetric(horizontal: 8),
alignment: Alignment.center,
height: constraints.maxHeight * 0.3,
margin: EdgeInsets.fromLTRB(10.0, 0.0,10.0,0.0),
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Text(
'Right Wide Screen',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
],
);

// If screen size is < 480
} else {
return Container(
alignment: Alignment.center,
height: constraints.maxHeight * 0.3,
margin: EdgeInsets.fromLTRB(10.0, 0.0,10.0,0.0),
decoration: BoxDecoration(
color: Colors.cyan,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Text(
'Normal Screen',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
);
}
},
)

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

When the screen size larger than 480 then the result will the image is given on rotating the device.

Code File :

import 'package:flutter/material.dart';
import 'package:flutter_layout_builder_demo/themes/device_size.dart';

class LayoutBuilderDemo extends StatefulWidget {
@override
_LayoutBuilderDemoState createState() => _LayoutBuilderDemoState();
}

class _LayoutBuilderDemoState extends State<LayoutBuilderDemo> {
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(
title: Text('LayoutBuilder Demo'),
centerTitle: true,
),
body: Container(
/// Giving dimensions to parent Container
/// using MediaQuery
height: DeviceSize.height(context),
width: DeviceSize.width(context),
alignment: Alignment.center,

child: LayoutBuilder(
builder: (BuildContext ctx, BoxConstraints constraints) {
// if the screen width >= 480 i.e Wide Screen
if (constraints.maxWidth >= 480) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
padding:EdgeInsets.symmetric(horizontal: 8),
alignment: Alignment.center,
height: constraints.maxHeight * 0.3,
margin: EdgeInsets.fromLTRB(10.0, 0.0,10.0,0.0),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Text(
'Left Wide Screen',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
Container(
padding:EdgeInsets.symmetric(horizontal: 8),
alignment: Alignment.center,
height: constraints.maxHeight * 0.3,
margin: EdgeInsets.fromLTRB(10.0, 0.0,10.0,0.0),
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Text(
'Right Wide Screen',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
],
);

// If screen size is < 480
} else {
return Container(
alignment: Alignment.center,
height: constraints.maxHeight * 0.3,
margin: EdgeInsets.fromLTRB(10.0, 0.0,10.0,0.0),
decoration: BoxDecoration(
color: Colors.cyan,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Text(
'Normal Screen',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
);
}
},
),
),
),
);
}
}

Conclusion :

In this article, I have explained a LayoutBuilder in a flutter, which you can modify and experiment with according to your own, this little introduction was from the LayoutBuilder demo from our side.

I hope this blog will provide you with sufficient information in Trying up the LayoutBuilder in your flutter project. We showed you what the LayoutBuilder is and work on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

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

Clap 👏 If this article helps you.

From Our Parent Company Aeologic

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

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

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

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, 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.

Sortable ListView In Flutter

0

While creating Flutter applications, now and again, we might need to give a choice to the user to sort the items in the ListView based on explicit models. This sortable ListView provides an easy-to-understand method for a survey and sorting the information in the application, making it more straightforward and quicker for them to find the data they need.

This article will explore the Sortable ListView In Flutter. We will perceive how to execute a demo program and we are going to learn about how we can create it in your Flutter applications without using any third-party packages.

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


Table Of Contents::

Introduction

Implementation

Code File

Conclusion



Introduction:

The below demo video tells the best way to make a Sortable ListView in a flutter. It shows how the Sortable ListView will function in your Flutter applications. It shows when the user can sort the items in the ListView by value low to high, and high to low by tapping the price label in the header of the ListView.

Demo Module :


How to implement code in dart file :

You need to implement it in your code respectively:

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

Our demo application has a ListView that shows a list of fiction items with 3 attributes: idname, and price. The header will likewise show an up or down bolt symbol demonstrating whether the items are arranged in ascending or descending request.

First, we will create a new HomePage() class. In this class, we will add the sort order. We will add a bool variable was _sortAscending is equal to true.

bool _sortAscending = true;

Now, we will add the list of products. We will add a list map of the string, dynamics, and the variable was _products.

final List<Map<String, dynamic>> _products = [
{'id': 1, 'name': 'Flutter Course', 'price': 23.99},
{'id': 2, 'name': 'ReactNative Course', 'price': 19.99},
{'id': 3, 'name': 'Python Course', 'price': 16.99},
{'id': 4, 'name': 'Swiftic Course', 'price': 35.99},
{'id': 5, 'name': 'Xamarin Course', 'price': 25.99},
];

Now, we will add the _sortProducts() method. In this method, we will add the setState() function. In this function, we sort the list of products. This function is called when the user taps the sort button.

void _sortProducts(bool ascending) {
setState(() {
_sortAscending = ascending;
_products.sort((a, b) => ascending
? a['price'].compareTo(b['price'])
: b['price'].compareTo(a['price']));
});
}

In the body, we will add a Container widget. In this widget, we will add the Row Widget. Inside the widget, we will add the header of the list that was text ‘Price Low to High’ else ‘Price High to Low’. Now, we will add the sort button for the user. We will add the InkWell widget. In this widget, we will add onTap was navigate _sortProducts(!_sortAscending), add a row widget inside a text and icons was arrow up and down.

Container(
padding: const EdgeInsets.symmetric(vertical: 29, horizontal: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
_sortAscending ? 'Price Low to High' : 'Price High to Low',
style: const TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
// the sort button
InkWell(
onTap: () => _sortProducts(!_sortAscending),
child: Row(
children: [
Text(
'Price',
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
color: Colors.blue.shade500,
),
),
// the up/down arrow that indicates the sort order
Icon(
_sortAscending
? Icons.arrow_drop_down
: Icons.arrow_drop_up,
color: Colors.blue,
),
],
),
),
],
),
),

Now, we will add the list of products. We will add the Expanded widget. In this widget, we will add ListView.builder() method. In this method, we will add the itemCount as products. length, itemBuilder was the list item- product. We will return a Container widget. In this widget, we will add a row widget. Inside the widget, we will add three texts idname, and price.

Expanded(
child: ListView.builder(
itemCount: _products.length,
itemBuilder: (context, index) {
// the list item - product
return Container(
padding: const EdgeInsets.all(16),
margin: const EdgeInsets.only(bottom: 3),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey),
borderRadius: BorderRadius.circular(5.0),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${_products[index]['id']}',
style: const TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
),
),
Text(
'${_products[index]['name']}',
style: const TextStyle(
fontSize: 16.0,
),
),
Text(
'\$${_products[index]['price']}',
style: const TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
color: Colors.green,
),
),
],
),
);
},
),
),

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

Final Output

Code File:

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

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

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

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

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

@override
State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {

bool _sortAscending = true;

final List<Map<String, dynamic>> _products = [
{'id': 1, 'name': 'Flutter Course', 'price': 23.99},
{'id': 2, 'name': 'ReactNative Course', 'price': 19.99},
{'id': 3, 'name': 'Python Course', 'price': 16.99},
{'id': 4, 'name': 'Swiftic Course', 'price': 35.99},
{'id': 5, 'name': 'Xamarin Course', 'price': 25.99},
];

// the function that sorts the list of products
// this function is called when the user taps the sort button
void _sortProducts(bool ascending) {
setState(() {
_sortAscending = ascending;
_products.sort((a, b) => ascending
? a['price'].compareTo(b['price'])
: b['price'].compareTo(a['price']));
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Flutter Sortable Listview Demo'),
automaticallyImplyLeading: false,
centerTitle: true,
backgroundColor: Colors.red.shade300,
),
body: Column(
children: [
Container(
padding: const EdgeInsets.symmetric(vertical: 29, horizontal: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
_sortAscending ? 'Price Low to High' : 'Price High to Low',
style: const TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
InkWell(
onTap: () => _sortProducts(!_sortAscending),
child: Row(
children: [
Text(
'Price',
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
color: Colors.blue.shade500,
),
),
Icon(
_sortAscending
? Icons.arrow_drop_down
: Icons.arrow_drop_up,
color: Colors.blue,
),
],
),
),
],
),
),
Expanded(
child: ListView.builder(
itemCount: _products.length,
itemBuilder: (context, index) {
// the list item - product
return Container(
padding: const EdgeInsets.all(16),
margin: const EdgeInsets.only(bottom: 3),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey),
borderRadius: BorderRadius.circular(5.0),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${_products[index]['id']}',
style: const TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
),
),
Text(
'${_products[index]['name']}',
style: const TextStyle(
fontSize: 16.0,
),
),
Text(
'\$${_products[index]['price']}',
style: const TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
color: Colors.green,
),
),
],
),
);
},
),
),
],
),
);
}
}

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying the Sortable ListView in your Flutter projectsWe will show you what the Introduction is. Make a demo program for a working Length Converter in your Flutter applications. So please try it.

❤ ❤ Thanks for reading this article ❤❤

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

Clap 👏 If this article helps you


From Our Parent Company Aeologic

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

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

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

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

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


Editable PDF in Flutter

0

Displaying data in PDF view prevents graphic integrity. Irrespective of the platform the user can get a similar view. PDFs are secure, compact multidimensional, and easy to store. Most of the applications today are using custom PDF to create invoices, user profiles, resumes, etc. In this blog, we will learn how to create a custom pdf view in the flutter.


Packages used :

pdf | Dart Package
This library is divided into two parts: a low-level Pdf creation library that takes care of the pdf bits generation. a…pub.dev

flutter_full_pdf_viewer | Flutter Package
Android and iOS working pdf viewer! Add this to your package’s pubspec.yaml file: dependencies…pub.dev

path_provider | Flutter Package
A Flutter plugin for finding commonly used locations on the filesystem. Supports iOS, Android, Linux and MacOS. Not all…pub.dev

pubspec.yaml file :

dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
pdf: ^3.0.1
flutter_full_pdf_viewer: ^1.0.6
path_provider: ^2.0.1

Create a Pdf Page :

final Document pdf = Document();
pdf.addPage(
Page(
build: (context) => Center(
child: Text('Hello World!'),
),

);

PDF is a Document , it uses addPage property to add a page in the PDF. Here we have created a Centered “Hello World” text in PDF.

Creating a Custom Page :

pdf.addPage(
Page(
orientation: PageOrientation.natural,
build: (context) => Column(
children: [
divider(500),
spaceDivider(5),
Text(
title,
style: TextStyle(fontSize: 40, color: PdfColors.grey),
),
spaceDivider(5),
divider(500),
spaceDivider(60),
Row(
children: [
Text(
"Aeologic Technologies",
textAlign: TextAlign.left,
style: textStyle1(),
),
],
),
spaceDivider(30),
textRow(["Vendor:", "Ship To:"], textStyle1()),
textRow(["Shop11", "Aeo Tech"], textStyle2()),
textRow(["Address", "Address"], textStyle2()),
textRow(["Address", "Address"], textStyle2()),
textRow(["Address", "Address"], textStyle2()),
spaceDivider(30),
Container(
color: PdfColors.white,
child: Table(
border: TableBorder.all(color: PdfColors.black),
children: [
tableRow(
["No.", "Name", "Qut.", "Price", "Amount"], textStyle1()),
tableRow(["1", "APPLE", "3", "20", "60"], textStyle2()),
tableRow(["2", "POP CORN", "20", "10", "200"], textStyle2()),
tableRow(["3", "MANGO", "2", "15", "30"], textStyle2()),
],
),
),
spaceDivider(30),
divider(500),
spaceDivider(30),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
width: 250,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
textRow(["Sub Total", "290"], textStyle2()),
textRow(["Discount", "90"], textStyle2()),
divider(500),
textRow(["Grand Total", "200"], textStyle2()),
divider(500),
],
),
),
],
),
],
),
),
);

Storing the PDF using path_provider package :

final String dir = (await getApplicationDocumentsDirectory()).path;
final String path = '$dir/customPDF.pdf';
final File file = File(path);
await file.writeAsBytes((await pdf.save()));

getApplicationDocumentsDirectory() is a method to get the path of the app directory, we will create a File with ‘$dir/customPDF.pdf’ name and then we will save pdf inside the file using writeAsBytes method.

Full file :

import 'package:flutter/material.dart' as material;
import 'package:path_provider/path_provider.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart';
import 'dart:io';
import 'main.dart';

orderPdfView(context, String title) async {
final Document pdf = Document();
pdf.addPage(
Page(
orientation: PageOrientation.natural,
build: (context) => Column(
children: [
divider(500),
spaceDivider(5),
Text(
title,
style: TextStyle(fontSize: 40, color: PdfColors.grey),
),
spaceDivider(5),
divider(500),
spaceDivider(60),
Row(
children: [
Text(
"Aeologic Technologies",
textAlign: TextAlign.left,
style: textStyle1(),
),
],
),
spaceDivider(30),
textRow(["Vendor:", "Ship To:"], textStyle1()),
textRow(["Shop11", "Aeo Tech"], textStyle2()),
textRow(["Address", "Address"], textStyle2()),
textRow(["Address", "Address"], textStyle2()),
textRow(["Address", "Address"], textStyle2()),
spaceDivider(30),
Container(
color: PdfColors.white,
child: Table(
border: TableBorder.all(color: PdfColors.black),
children: [
tableRow(
["No.", "Name", "Qut.", "Price", "Amount"], textStyle1()),
tableRow(["1", "APPLE", "3", "20", "60"], textStyle2()),
tableRow(["2", "POP CORN", "20", "10", "200"], textStyle2()),
tableRow(["3", "MANGO", "2", "15", "30"], textStyle2()),
],
),
),
spaceDivider(30),
divider(500),
spaceDivider(30),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
width: 250,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
textRow(["Sub Total", "290"], textStyle2()),
textRow(["Discount", "90"], textStyle2()),
divider(500),
textRow(["Grand Total", "200"], textStyle2()),
divider(500),
],
),
),
],
),
],
),
),
);

final String dir = (await getApplicationDocumentsDirectory()).path;
final String path = '$dir/report.pdf';
final File file = File(path);
await file.writeAsBytes((await pdf.save()));
material.Navigator.of(context).push(
material.MaterialPageRoute(
builder: (_) => PdfViewer(path: path),
),
);
}

Widget divider(double width) {
return Container(
height: 3,
width: width,
decoration: BoxDecoration(
color: PdfColors.grey,
),
);
}

tableRow(List<String> attributes, TextStyle textStyle) {
return TableRow(
children: attributes
.map(
(e) => Text(
" " + e,
style: textStyle,
),
)
.toList(),
);
}

Widget textRow(List<String> titleList, TextStyle textStyle) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: titleList
.map(
(e) => Text(
e,
style: textStyle,
),
)
.toList(),
);
}

TextStyle textStyle1() {
return TextStyle(
color: PdfColors.grey800,
fontSize: 22,
fontWeight: FontWeight.bold,
);
}

TextStyle textStyle2() {
return TextStyle(
color: PdfColors.grey,
fontSize: 22,
);
}

Widget spaceDivider(double height) {
return SizedBox(height: height);
}

PdfViewer :

class PdfViewer extends StatelessWidget {
final String path;
PdfViewer({this.path});

@override
Widget build(BuildContext context) {
return PDFViewerScaffold(
path: path,
);
}
}

PDFViewerScaffold is a widget used to view the pdf.

main.dart file :

import 'package:flutter/material.dart';
import 'package:flutter_full_pdf_viewer/full_pdf_viewer_scaffold.dart';
import 'package:flutter_pdf_create/review.dart';

void main() {
runApp(MaterialApp(
theme: ThemeData(textTheme: TextTheme()),
home: MyPage(),
));
}

class MyPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: MaterialButton(
color: Colors.blue,
child: Text("Generate Pdf"),
onPressed: () {
orderPdfView(context, "Purchase Order");
},
),
),
);
}
}

class PdfViewer extends StatelessWidget {
final String path;
PdfViewer({this.path});

@override
Widget build(BuildContext context) {
return PDFViewerScaffold(
path: path,
);
}
}

Demo Module:


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.

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

From Our Parent Company Aeologic

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

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

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, 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!.

Zoom Drawer In Flutter

In this article, we will explore the ZoomDrawer in flutter using the fluter_zoom_drawer_package. With the help of the package, we can easily achieve flutter animated Swiper. So let’s get started.

flutter_zoom_drawer | Flutter Package
A Flutter package with custom implementation of the Side Menu (Drawer) To start using this package, add…pub.dev


Table Of Contents :

Flutter

Zoom Drawer

Implementation

Code Implement

Code File

Conclusion


Futter :

“ Flutter is Google’s UI toolkit that helps you build beautiful and natively combined applications for mobile, web, and desktop in a single codebase in record time, Flutter offers great developer tools, with amazing hot reload”

Zoom Drawer :

The ZoomDrawer is a library for adding a beautiful slide drawer mode menu feature with menu animations. Using this, we can make it a completely customized menu as per our requirement, we can use many types of sliders in the zoom drawer package.

Some Basic Properties:

  • controller — The controller uses the property to control the position of his children.
  • mainScreen — The main screen property is like the home screen in a zoom drawer.
  • menuScreen — In the menu screen, we rotate the screen of all our drawers at the click of a menu item.
  • borderRadius — We use the border-radius property to change the radius of the slide.
  • backgroundColor—We use the background property to give the background color of the drawer shade
  • showShadow — Boolean, whether to show the drawer shadows — defaults to false.

Demo Module :

Implementation :

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies :

dependencies:   
flutter_zoom_drawer: ^2.0.0

Step 2: Importing

import 'package:flutter_zoom_drawer/flutter_zoom_drawer.dart';

Step 3: Run flutter package get

Code Implementation :

Create a new dart file called flutter__zoom_drawer_demo.dart inside the libfolder.

First of all, we will create a zoom drawer controller, we will initialize it under the name drawerController.

final _drawerController = ZoomDrawerController();

A class with a menu item name is created for the menu item list.

class MenuItem {
String title;
IconData icon;
MenuItem(this.icon, this.title);
}

Now we will create a list in which we will define the list of menu items.

final List<MenuItem> options = [
MenuItem(Icons.payment, 'Payments'),
MenuItem(Icons.favorite, 'Discounts'),
MenuItem(Icons.notifications, 'Notification'),
MenuItem(Icons.format_list_bulleted, 'Orders'),
MenuItem(Icons.help, 'Help'),
];

In this screen, we have created a class named MenuScreen inside which a list of menu items is created which contains the item name and icon and a new page opens when the item is clicked. and we will initialize this class in the main screen property of the zoom drawer.

ZoomDrawer(
menuScreen: MenuScreen(),
),

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

Now we are showing the main screen, inside which we can pass some content and widgets, we will initialize this class in the main screen property of the zoom drawer class.

ZoomDrawer(
mainScreen: MainScreen(),
),

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

Code File:

import 'package:flutter/material.dart';
import 'package:flutter_zoom_drawer/flutter_zoom_drawer.dart';
import 'package:flutter_zoom_drawer_demo/view/main_screen.dart';
import 'package:flutter_zoom_drawer_demo/view/menu_screen.dart';

class FlutterZoomDrawerDemo extends StatefulWidget {
@override
_FlutterZoomDrawerDemoState createState() => _FlutterZoomDrawerDemoState();
}

class _FlutterZoomDrawerDemoState extends State<FlutterZoomDrawerDemo> {
final _drawerController = ZoomDrawerController();

@override
Widget build(BuildContext context) {
return Scaffold(
body: ZoomDrawer(
controller: _drawerController,
style: DrawerStyle.Style1,
menuScreen: MenuScreen(),
mainScreen: MainScreen(),
borderRadius: 24.0,
showShadow: true,
angle: 0.0,
backgroundColor: Colors.grey[300],
slideWidth: MediaQuery.of(context).size.width *
(ZoomDrawer.isRTL() ? .45 : 0.65),
openCurve: Curves.fastOutSlowIn,
closeCurve: Curves.bounceIn,
),
);
}
}

Conclusion:

In this flutter article, I have explained a ZoomDrawer in a flutter, which you can modify and experiment with according to your own, this little introduction was from the ZoomDrawer demo from our side.

I hope this blog will provide you with sufficient information in Trying up the ZoomDrawer in your flutter project. We will show you the ZoomDrawer is?, and work on it in your flutter applications, So please try it.

❤ ❤ Thanks for reading this article ❤❤

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

Clap 👏 If this article helps you.


From Our Parent Company Aeologic

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

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

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

FlutterDevs team of Flutter developers to build high-quality and functionally-rich apps. Hire a flutter developer for your cross-platform Flutter mobile app project on an hourly or full-time basis as per your requirement! You can connect with us on Facebook, GitHub, Twitter, 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.