Google search engine
Home Blog Page 469

Explore Motion Bottom TabBar 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.

In this article, we will explore the Explore Motion Bottom TabBar In Flutter using the motion_tab_bar_package. With the help of the package, Users can use this to give the bottom bar an animation type of tab bar motion on click of item. So let’s get started.

motion_tab_bar | Flutter Package
A beautiful
animated widget for your Flutter apps |———|———-| | | Add the plugin: dependencies…pub.dev


Table Of Contents :

Motion Bottom TabBar

Implementation

Code Implement

Code File

Conclusion


Motion Bottom TabBar :

The Motion Tab Bar Plugin in Flutter provides us with a motion animation, this is a kind of bottom tab bar, when we tap on the item in the tab bar, we see that it animates to the next item in the upward motion flow. It can be used instead of the bottom tab bar, it is very good and an attractive bottom tab bar.

Implementation :

Step 1: Add the dependencies

Add dependencies to pubspec — yaml file.

dependencies :

dependencies:
motion_tab_bar: ^0.1.5

Step 2: Importing

import 'package:motion_tab_bar/MotionTabBarView.dart';
import 'package:motion_tab_bar/MotionTabController.dart';
import 'package:motion_tab_bar/TabItem.dart';
import 'package:motion_tab_bar/motiontabbar.dart';

Step 3: Enable AndriodX

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

Code Implementation :

You need to implement it in your code respectively:

Before exploring the motion tab bar we will create a controller and define it inside initState() and define it inside the initialIndex property in MotionTabController().

late MotionTabController _tabController;

@override
void initState() {
super.initState();
_tabController = MotionTabController(initialIndex: 1, vsync: this);
}

We will add MotionTabBar() in bottomNavigationBar. Inside, we will add labels, initialSelectedTab, tabIconColor and onTabItemSelected. In onTabItemSelected, we will add inside setState() method. In this method, we will add _tabController.index is equal to the value. Also, add icons and textStyle.bottomNavigationBar:

MotionTabBar(
labels: [
"Account","Home","Dashboard"
],
initialSelectedTab: "Home",
tabIconColor: Colors.green,
tabSelectedColor: Colors.red,
onTabItemSelected: (int value){
print(value);
setState(() {
_tabController.index = value;
});
},
icons: [
Icons.account_box,Icons.home,Icons.menu
],
textStyle: TextStyle(color: Colors.red),
),

After this we will use MotionTabBarView in the motion tab bar, inside it we have taken three different types of container which has some different type of text on its child when we tap on a given item of bottom navigation bar then a different type of page according to index will show.

MotionTabBarView(
controller: _tabController,
children: <Widget>[
Container(
child: Center(
child: Text("Account"),
),
),
Container(
child: Center(
child: Text("Home"),
),
),
Container(
child: Center(
child: Text("Dashboard"),
),
),
],
)

Code File :

import 'package:flutter/material.dart';
import 'package:motion_tab_bar/MotionTabBarView.dart';
import 'package:motion_tab_bar/MotionTabController.dart';
import 'package:motion_tab_bar/motiontabbar.dart';

class MotionTabBarDemo extends StatefulWidget {
@override
_MotionTabBarDemoState createState() => _MotionTabBarDemoState();
}

class _MotionTabBarDemoState extends State<MotionTabBarDemo>with TickerProviderStateMixin {
late MotionTabController _tabController;

@override
void initState() {
super.initState();
_tabController = MotionTabController(initialIndex: 1, vsync: this);
}

@override
void dispose() {
super.dispose();
_tabController.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Motion Tabbar Demo'),
),
bottomNavigationBar: MotionTabBar(
labels: [
"Account","Home","Dashboard"
],
initialSelectedTab: "Home",
tabIconColor: Colors.green,
tabSelectedColor: Colors.red,
onTabItemSelected: (int value){
print(value);
setState(() {
_tabController.index = value;
});
},
icons: [
Icons.account_box,Icons.home,Icons.menu
],
textStyle: TextStyle(color: Colors.red),
),
body: MotionTabBarView(
controller: _tabController,
children: <Widget>[
Container(
child: Center(
child: Text("Account"),
),
),
Container(
child: Center(
child: Text("Home"),
),
),
Container(
child: Center(
child: Text("Dashboard"),
),
),
],
)
);
}
}

Conclusion:

In this article, I have explained Glassmorphism Card In Flutter, which you can modify and experiment with according to your own, this little introduction was from the Glassmorphism Card In Flutter demo from our side.

I hope this blog will provide you with sufficient information on Trying up the Glassmorphism Card In Flutter in your flutter project. We showed you what the Glassmorphism Card In Flutter 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.

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.

Related: Cupertino TabBar In Flutter

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

HeroMode Widget in Flutter

0

In Flutter 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 blog, we will understand the HeroMode widget and its functionality in the flutter. and We will see in this implementation of a demo program on the HeroMode Widget.


Table Contents:

Flutter

Hero Widget

HeroMode Widget

Code Implementation

Conclusion

GitHub Link


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 is free and open-source. It was at first evolved from Google and is presently overseen by an ECMA standard. Flutter applications utilize the Dart programming language for making an application. The dart programming shares a few same highlights as other programming dialects, like Kotlin and Swift, and can be trans-arranged into JavaScript code.

If you want to explore more about Flutter, please visit Flutter’s official website to get more information.

Flutter Is Proudly Entrusted By These Organizations For their Products : — Flutter Showcase


Hero Widget:

Hero widget is a great out-of-the-box animation for communicating the navigation action of a widget flying from page to page. Hero animation is a shared element transition (animation) between two different pages. Now to See this, Imagine a superhero flying in action. For example, you must have an image list. As we wrap it with a hero tag. Now we tap on an item list. and when tapped. Then the images list item lands its position on the detail page. when we cancel it and come back to the list page, then the hero widget returns to its page.

HeroMode Widget:

HeroMode widget has animation power to enable or disable the element between two screens. basically, this widget is required, when you want to disable the animation functionality of the Hero widget. If you want to know about the Hero Mode widget, then first you need to understand the Hero widget.

HeroMode widget is the part of the Hero widget, and the purpose of introducing this widget is to enable and disable the animation of the hero widgets, if you don’t want to animate the element between two screens then wrap the Hero widget with the HeroMode Widget and we can enable and disable by using their static properties or dynamically, and then by wrapping this widget what happened when you see carefully below example video, then you can see what is the measurable difference in this animation.

Demo Module :

How to implement code in dart file :

You need to implement it in your code respectively:

First, I have created a ViewModel class for the set and get a boolean value on the switch button. Which I passed in HeroMode Widget.

bool _isHeroModeEnable= true;

bool get isHeroModeEnable => _isHeroModeEnable;set isHeroModeEnable(bool value) {
_isHeroModeEnable = value;
}

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

Then, I have to add a text and switch button for showing enable and disable the functionality of the HeroMode widget.

Widget buildCategoriesSection() {
return Container(
padding: EdgeInsets.only(left: 20),
child: Row(
//mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
child: Text("Hero Mode",
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.bold
),),
),
Switch(
value: model!=null && model!.isHeroModeEnable,
onChanged:(value){
print("value:$value");
model!.isHeroModeEnable=value;
},
activeTrackColor: Color(ColorConstants.light_blue),
activeColor: Color(ColorConstants.pure_white),
),

],
),
);
}

Then, I have created a listview with movie banner API, but you can use a dummy images list for test purposes according to your requirement. and after that, I have wrap images with the Hero widget, and Hero widget wrap with the HeroMode widget. for disabling the animation of Hero Widget. basically, this is a medium to enable and disable the animation of Hero Widget .you can not disable animation directly from the Hero Widget.

Widget _buildPopularSection() {
return Container(
height: 300,
padding: EdgeInsets.only(left: 20, top: 5),
width: MediaQuery.of(context).size.width,
child: model != null && model!.isPopularLoading
? Center(child: CircularProgressIndicator())
: Provider.value(
value: Provider.of<HomeViewModel>(context),
child: Consumer(
builder: (context, value, child) => Container(
child: ListView.builder(
shrinkWrap: true,
itemCount: model != null && model!.popularMovies != null
? model!.popularMovies!.results!.length : 0,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return _buildPopularItem(
index, model!.popularMovies!.results![index]);
},
),
),
),
),
);
}Widget _buildPopularItem(int index, Results result) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MovieDetailView(movieDataModel: result)),
);
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 200,
width: 150,
margin: EdgeInsets.only(right: 16),
child: HeroMode(
child: Hero(
tag: '${result.id}',
child: ClipRRect(
borderRadius: BorderRadius.circular(25.0),
child: Image.network(
Constants.IMAGE_BASE_URL +
Constants.IMAGE_SIZE_1 +
'${result.posterPath}',
fit: BoxFit.cover,
),
),
),
enabled: true,
//enabled:model.isHeroModeEnabled,
),
),
SizedBox(
height: 18,
),
Container(
child: Text(
result.title!,
style: TextStyle(color: Colors.white, fontSize: 15),
),
),
SizedBox(
height: 5,
),
Container(
child: GFRating(
value: _rating,
color: Color(ColorConstants.orange),
size: 16,
onChanged: (value) {
setState(() {
_rating = value;
});
},
),
)
],
),
);
}

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

Last, I have created a second dart file and in this file, I have made a method for showing images animation here. and then images wrap with the Hero widget with the same tag. When you have multiple images then you pass the image list id.

Widget _buildMovieBanner(Results movieItems) {
return Container(
height: 380,
child: Stack(
children: [
Positioned(
top: 20,
child: Container(
height: 350,
width: 240,
margin: EdgeInsets.only(left: 28, right: 30),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(22),
color: Color(ColorConstants.saphire_blue2),
),
),
),
Positioned(
top: 10,
child: Container(
height: 350,
width: 250,
margin: EdgeInsets.only(left: 22, right: 25),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(22),
color: Color(ColorConstants.cobaltBlue),
),
),
),
Container(
height: 350,
width: 260,
margin: EdgeInsets.only(left: 16, right: 16),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(24),
child: Hero(
tag: '${widget.movieDataModel.id}',
child: Image.network(
Constants.IMAGE_BASE_URL +
Constants.IMAGE_SIZE_1 +
widget.movieDataModel.posterPath!,
fit: BoxFit.cover,
),
),
),
),
],
),
);
}

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the Explore, HeroMode Widget in your flutter projects.

❤ ❤ 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.


GitHub Link:

find the source code of the Flutter HeroMode Demo:

GitHub – flutter-devs/flutter_heromode_demo: A new Flutter project for HeroMode Demo
A new Flutter project. This project is a starting point for a Flutter application. A few resources to get you started…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 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.

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


SnackBar Widget in Flutter

0

Whenever you are going to code for building anything in Flutter, it will be inside a widget. each element on the 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 blog, we will understand the static and custom SnackBar widget and its functionality in the flutter. We will see in this implementation of a simple demo program on the SnackBar Widget.


Table Contents:

SnackBar Widget

Code Implementation

Code File

Conclusion

GitHub Link



SnackBar:

In Flutter the SnackBar is a widget that lightweight pop up a quick message in your app that briefly signifies the user when something happened. Using a SnackBar you pop up a message for a few seconds at the bottom of your app.

By default, the snack bar displays at the bottom of the screen, and when the specified time is completed, it will be disappeared from the screen and we can make a custom snack bar also and It contains some actions that allow the user to add or remove any action and images. SnackBar requires a Scaffold, with a Scaffold instance and your SnackBar will instantly pop up. it’s easy to get a reference of your scaffold at any point in your widget tree by using the scaffold. of function.

Demo Module :


How to implement code in dart file :

You need to implement it in your code respectively:

First, In this dart file, I have created two buttons, the first button is for showing the default SnackBar and the second one is for the custom SnackBar.I am going to introduce first the Default SnackBar.

Default SnackBar

There are two steps for displaying a SnackBar. First, you have to create a SnackBar which can be done by calling the following constructor. it is very simple to use. here is the code.final snackBar = SnackBar(content: Text(‘Yay! A DefaultSnackBar!’));
ScaffoldMessenger.of(context).showSnackBar(snackBar);

But some of our requirements are not met, by default SnackBar .so May custom SnackBar is doing it. For custom SnackBar, I have to use a Flushbar dependency. it is a very congruent dependency to design your custom SnackBar upon your choice.

First, add the dependency of the SnackBar in pubspec.yaml

another_flushbar: ^1.10.24

And then have to create a method for showing the custom SnackBar.

void showFloatingFlushbar( {@required BuildContext? context,
@required String? message,
@required bool? isError}){
Flushbar? flush;
bool? _wasButtonClicked;
flush = Flushbar<bool>(
title: "Hey User",
message: message,
backgroundColor: isError! ? Colors.red : Colors.blueAccent,
duration: Duration(seconds: 3),
margin: EdgeInsets.all(20),

icon: Icon(
Icons.info_outline,
color: Colors.white,),
mainButton: FlatButton(
onPressed: () {
flush!.dismiss(true); // result = true
},
child: Text(
"ADD",
style: TextStyle(color: Colors.amber),
),
),) // <bool> is the type of the result passed to dismiss() and collected by show().then((result){})
..show(context!).then((result) {

});
}

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

Custom SnackBar

Code File:

import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';

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

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

class _SnackBarViewState extends State<SnackBarView> {

@override
Widget build(BuildContext context) {

return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildSnackBarButton()
],
),
);
}

Widget _buildSnackBarButton() {
return Column(
children: [
Center(
child: InkWell(
onTap: (){
final snackBar = SnackBar(content: Text('Yay! A Default SnackBar!'));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
child: Container(
height: 40,
width: 180,
decoration: BoxDecoration(
color: Colors.pinkAccent,
borderRadius: BorderRadius.all(Radius.circular(15))
),
child: Center(
child: Text("SnackBar",
style: TextStyle(
color: Colors.white,
fontSize: 16,

),),
),

),
),
),
SizedBox(height: 10,),
Center(
child: InkWell(
onTap: (){
showFloatingFlushbar(context: context,
message: 'Custom Snackbar!',
isError: false);
// showSnackBar(
// context: context,
// message: 'Custom Snackbar!',
// isError: false);
},
child: Container(
height: 40,
width: 180,
decoration: BoxDecoration(
color: Colors.pinkAccent,
borderRadius: BorderRadius.all(Radius.circular(15))
),
child: Center(
child: Text("Custom SnackBar",

style: TextStyle(
color: Colors.white,
fontSize: 16,

),),
),

),
),
),
],
);
}
}

void showFloatingFlushbar( {@required BuildContext? context,
@required String? message,
@required bool? isError}){
Flushbar? flush;
bool? _wasButtonClicked;
flush = Flushbar<bool>(
title: "Hey User",
message: message,
backgroundColor: isError! ? Colors.red : Colors.blueAccent,
duration: Duration(seconds: 3),
margin: EdgeInsets.all(20),

icon: Icon(
Icons.info_outline,
color: Colors.white,),
mainButton: FlatButton(
onPressed: () {
flush!.dismiss(true); // result = true
},
child: Text(
"ADD",
style: TextStyle(color: Colors.amber),
),
),) // <bool> is the type of the result passed to dismiss() and collected by show().then((result){})
..show(context!).then((result) {

});
}

void showSnackBar(
{@required BuildContext? context,
@required String? message,
@required bool? isError}) {
final snackBar = SnackBar(
content: Text(
message!,
style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.normal),
),
duration: Duration(seconds: 3),
backgroundColor: isError! ? Colors.red : Colors.green,
width: 340.0,
padding: const EdgeInsets.symmetric(
horizontal: 8.0,
),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),

action: SnackBarAction(
label: 'Undo',
textColor: Colors.white,
onPressed: () {},
),
);
ScaffoldMessenger.of(context!).showSnackBar(snackBar);
}

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the Explore, SnackBar Widget in your flutter projects.

❤ ❤ 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.


GitHub Link:

find the source code of the Flutter SnackBar Demo:

GitHub – flutter-devs/flutter_snackbar_demo
Permalink Failed to load the latest commit information. A new Flutter project. This project is a starting point for a…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 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.

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


Slide Transition Widget In Flutter

0

In Flutter 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 blog, we will explore the SlideTransition widget and custom Transition widget using PageRouteBuilder and its functionality in the flutter, and Cupertino Sliding Segmented Control In Flutterlso we will see how to implement this Slide transition widget step by step in this demo program.


Table Contents:

Slide Transition

Constructor

Properties

PageRoughtBuilder

Code Implementation

Conclusion

GitHub Link


Slide Transition:

In the Flutter SlideTransition is a widget that animates the position of a widget relative to its normal position and slides required a little bit more interaction by using tween, in this case, offset, and flutter widget. The translation is expressed as an Offset scaled to the child’s size. For example, an Offset with a dx of 0.25 will result in a horizontal translation of one-quarter of the width of the child.

By default, the offsets are applied in the coordinate system of the canvas (so positive x offsets move the child towards the right). If a widget direction is provided, then the offsets are applied in the reading direction, so in the right-to-left widget, positive x offsets move towards the left, and in the left-to-right widget, positive x offsets move towards the right as same applied top to bottom.

Demo Module :


Constructor:

Default Constructor for it will look like as below:

SlideTransitionWidget({
Key key,
@required Animation<Offset> position,
bool transformHitTests: true,
TextDirection textDirection,
Widget child,
});

Properties:

There are some properties of Slide Transition are:

  • > Key: This attribute key, controls how one widget replaces another widget in the tree.
  • > Animation<Offset> position: This attribute is used to define the animation that controls the position of the child. If the current value of the position animation is (dx, dy), the child will be translated horizontally by width * dx and vertically by height * dy, after applying the textDirection if available.
  • > bool transformHitTests: This attribute defines whether hit testing should be affected by the slide animation. If false, hit testing will proceed as if the child was not translated at all. Setting this value to false is useful for fast animations where you expect the user to commonly interact with the child widget in its final location and you want the user to benefit from “muscle memory”.
  • > TextDirection textDirection: This attribute will define the direction to use for the x offset described by the position. If textDirection is null, the x offset is applied in the coordinate system of the canvas so positive x offsets move the child towards the right. Now if textDirection is TextDirection.rtl, the x offset is applied in the reading direction such that x offsets move the child towards the left. So now, if textDirection is TextDirection.ltr, the x offset is applied in the reading direction such that x offsets move the child towards the right.
  • > Widget child: This attribute is used to define the widget below this widget in the tree. This widget can only have one child. To layout multiple children, let this widget’s child be a widget such as Row Widget, Column Widget, or Stack Widget, which have a children’s property, and then provide the children to that widget.

To make more custom the transition flexibly, I am using PageRouteBuilder class.

PageRouteBuilder:

A utility class for defining one-off page routes in terms of callbacks. PageRouteBuilder provides an Animation object. This Animation can be used with Tween and Curve objects to customize the transition animation. This recipe shows how to transition between routes by animating the new route into view from the bottom of the screen.

To create a custom page route transition, this recipe uses the following steps:

  • Set up a PageRouteBuilder
  • Create a Tween
  • Add an AnimatedWidget
  • Use a CurveTween
  • Combine the two Tweens

How to implement code in the dart file:

You need to implement it in your code respectively:

In the first, I have created some custom radio buttons to show animation transition types. and I have added a dependency in pubspec.yaml file for use custom radio button. using the below dependency.

pubspec. yaml:

custom_radio_grouped_button: any

Then add custom radio buttons.

CustomRadioButton(
enableShape: true,
elevation: 0,
defaultSelected: "Left",
enableButtonWrap: true,
width: 100,
autoWidth: false,
unSelectedColor: Theme.of(context).canvasColor,
buttonLables: [
"Left",
"Right",
"Top",
"Bottom",
"InOut",
"Side",

],
buttonValues: [
"Left",
"Right",
"Top",
"Bottom",
"InOut",
"Side",

],
radioButtonValue: (value) {
radioButtonItem=value.toString();
print("Value:$value");
print("radioButtonItem:$radioButtonItem");
},
selectedColor: Theme.of(context).accentColor,
),

Now implement SlideTransition Widget.

First, implement in your class with SingleTickerProviderStateMixin. to use an animation controller. Then the user needs to define the controller and animation using the below code.

Suppose you have two pages: The first page and the second page. You’re on the First page and you want to navigate to the Second page. Somewhere in the First, you will do:

AnimationController _controller;
Animation<Offset> _animation;

initState() will have a code sample as below:

@override
void initState() {
super.initState();
controller =
AnimationController(vsync:this, duration: Duration(seconds: 1));

offset = Tween<Offset>(begin: Offset.zero, end: Offset(0.0, 1.0))
.animate(controller);
}

Now final I have created a class that extends PageRoughtBuilder class.

First left to right animation implementations code sample are:

class SlideLeftRoute extends PageRouteBuilder {
final Widget widget;
SlideLeftRoute({required this.widget})
: super(
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
return widget;
},
transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
return new SlideTransition(
position: new Tween<Offset>(
begin: const Offset(-1.0, 0.0),
end: Offset.zero,
).animate(animation),
child: child,
);
}
);
}

The second right to left animation implementations code sample is:

class SlideRightRoute extends PageRouteBuilder {
final Widget widget;
SlideRightRoute({required this.widget})
: super(
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
return widget;
},
transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
return new SlideTransition(
position: new Tween<Offset>(
begin: const Offset(1.0, 0.0),
end: Offset.zero,
).animate(animation),
child: child,
);
}
);
}

The third top to bottom animation implementations code sample is:

class SlideTopRoute extends PageRouteBuilder {
final Widget widget;
SlideTopRoute({required this.widget})
: super(
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
return widget;
},
transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
return new SlideTransition(
position: new Tween<Offset>(
begin: const Offset(0.0, -1.0),
end: Offset.zero,
).animate(animation),
child: child,
);
}
);
}

The fourth bottom to top animation implementations code sample is:

class SlideBottomRoute extends PageRouteBuilder {
final Widget widget;
SlideBottomRoute({required this.widget})
: super(
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
return widget;
},
transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
return new SlideTransition(
position: new Tween<Offset>(
begin: Offset(0.0, 1.0),
end: Offset.zero,
).animate(animation),
child: child,
);
// transitionDuration:Duration(seconds: 1);
}
);
}

The fifth in and out animation implementations code samples are:class ScaleRoute extends PageRouteBuilder {
final Widget widget;

ScaleRoute({required this.widget})
: super(pageBuilder: (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return widget;
}, transitionsBuilder: (BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return new ScaleTransition(
scale: new Tween<double>(
begin: 0.0,
end: 1.0,
).animate(
CurvedAnimation(
parent: animation,
curve: Interval(
0.00,
0.50,
curve: Curves.linear,
),
),
),
child: ScaleTransition(
scale: Tween<double>(
begin: 1.5,
end: 1.0,
).animate(
CurvedAnimation(
parent: animation,
curve: Interval(
0.50,
1.00,
curve: Curves.linear,
),
),
),
child: child,
),
);
});
}

The six side animation implementations code sample.

class SlideSideMoveRoute extends PageRouteBuilder {
final Widget widget;
SlideSideMoveRoute({required this.widget})
: super(
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
return widget;
},
transitionDuration: Duration(seconds: 1),
transitionsBuilder: (BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
Animation<Offset> custom= Tween<Offset>(
begin:Offset(1.0,1.0),end: Offset(0.0,0.0)).animate(animation);
return SlideTransition(
position: custom,
child: child);
}
);
}

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the Explore, SlideTransition Widget in your flutter projects.

❤ ❤ 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.


GitHub Link:

find the source code of the Slide Transition:

GitHub – flutter-devs/slide_transition
Contribute to flutter-devs/slide_transition development by creating an account on GitHub.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 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.

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


RefreshIndicator In Flutter

0

In this blog, we will see the RefreshIndicator widget and its properties in the flutter. If something changes in data from API then it does not update in the app so we need to load the data again in our app. Flutter provides us a RefreshIndicator widget that can be used to update the data in the app. and We will see in this implementation of a demo program on the RefreshIndicator Widget.


Table Contents:

RefreshIndicator Widget

Code Implementation

Conclusion

GitHub Link


RefreshIndicator:

RefreshIndicator is a widget in a flutter. It is used to update the data in the app. RefreshIndicator will trigger a refresh when the list is over-scrolled. It is showing a circular progress indicator if you want something to happen, add a callback function with the onRefrence property.

This function is not given any parameters, but RefreshIndicator expects it to return a future. the even spinning indicator of refreshing will continue spinning as long as that future is pending. as the spinning end, it will call onRefresh.You can customize your callback function.

Demo Module :


Code Implementation:

How to implement code in the dart file:

First, we will create a _buildCardDesign() widget. In this widget, we will return a Container(). Inside, we will add margin and its child property, we will add ListView.builder(). We will add itemCount, shrinkWrap was true, scrollDirection was Axis. vertical and itemBuilder. In itemBuilder, we will pass BuildContext context, int index parameter, and return _buildCardView() method.

We will deeply define below the code.

Widget _buildCardDesign() {
return Container(
margin: EdgeInsets.all(5),
child: ListView.builder(
itemCount: itemCount,
shrinkWrap: true,
physics: const BouncingScrollPhysics(
parent: AlwaysScrollableScrollPhysics()),
scrollDirection: Axis.vertical,
itemBuilder: (BuildContext context, int index) {
return _buildCardView();
}),
);
}

We will define buildCardView() method:

We will create a _buildCardView() method. In this method, we will return Container. Inside, we will add a network image and wrap it on ClipRRect() widget. Also, we will add some text hardcoded and star icons.

Widget _buildCardView() {
return Container(
width: MediaQuery.of(context).size.width,
child: Container(
margin: EdgeInsets.all(10),
height: 100,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(20))),
child: Container(
//color: Colors.pinkAccent,
padding: EdgeInsets.fromLTRB(10, 20, 10, 20),
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: Image.network(
"https://s1.1zoom.me/big0/716/Brunette_girl_Hair_Glance_Model_Colored_background_593058_1365x1024.jpg",
height: 60.0,
width: 60.0,
fit: BoxFit.cover,
),
),
//SizedBox(width: 20,),
Container(
padding: EdgeInsets.only(left: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Text(
"Neelu Modanwal",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 16),
),
),
Container(
padding: EdgeInsets.only(top: 5),
child: Text(
"Your opinion matters!",
style: TextStyle(color: Colors.black, fontSize: 15),
),
),
Container(
padding: EdgeInsets.only(top: 5),
child: Text(
"Dev, do you have a moment?We'd love",
style: TextStyle(color: Colors.black, fontSize: 11),
),
),
],
),
),
Column(
children: [
Text(
"4:15 AM",
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
fontSize: 12),
),
SizedBox(
height: 22,
),
Container(
// height: 20,
// width: 20,
margin: EdgeInsets.only(left: 10),
//color: Colors.pinkAccent,
child: Icon(
Icons.star,
color: Colors.grey,
),
)
],
),
],
),
),
),
);
}

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

And the second one, I have implemented RefreshIndicator on the whole screen. When swiping the screen. it rendered the progress indicator and call the own propertyonRefresh.And I have increased the length of the list by one according to the number of swipes in the onRefresh function with the delay sometimes. The code snippet is given below.

RefreshIndicator(
displacement: 250,
backgroundColor: Colors.yellow,
color: Colors.red,
strokeWidth: 3,
triggerMode: RefreshIndicatorTriggerMode.onEdge,
onRefresh: () async {
await Future.delayed(Duration(milliseconds: 1500));
setState(() {
itemCount = itemCount + 1;
});
},
child: Scaffold(
backgroundColor: Color(0xff246df8),
appBar: AppBar(
title: Text('Refresh Indicator'),
backgroundColor: Color(0xff246df8),
),
body: _buildCardDesign(),
),
);

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

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the Explore, RefreshIndicator Widget in your flutter projects.

❤ ❤ 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.


GitHub Link:

find the source code of the RefreshIndicator Demo:

GitHub – flutter-devs/swipe_refresh_by_refreshIndicator
Contribute to flutter-devs/swipe_refresh_by_refreshIndicator development by creating an account on GitHub.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 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.

Related: SMS Using Twilio In Flutter

Related: Using SharedPreferences in Flutter

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


FractionallySizedBox In Flutter

0

In Flutter, when users need to the size of a widget relative to available space. For example, a user wants to set buttons width as 70% of the parent widget users or we have a Container that takes half of the available space Vertically, and Horizontally Fractionally Sized Box Widget is used. This article has a model that discloses why you need to do to use a fractionally sized box that can be used anyplace around the screen as long as it’s inside the parent widget.

In this article, we will explore the Fractionally Sized Box Widget In Flutter. We will see how to implement a demo program on FractionallySizedBox and show how to create it in your flutter applications.


Table Of Contents::

Introduction

Properties

Code Implement

Code File

Conclusion

GitHub Link


Introduction:

FractionallySizedBox Widget is a widget that sizes its child to a fraction of the total available space. To make it easy to understand how FractionallySizedBox works, for example, there is a container with a size of 200 x 100. Inside, there is a Raised button and we are going to set the size of the button relative to the size of the container.

Demo:


Properties :

There are some properties of the FractionallySizedBox Widget:

  • Key: The widget key, used to control if it’s should be replaced.
  • AligntmentGeometry alignment: How the child is aligned. Defaults to Alignment. center.
  • double widthFactor: Width fraction that will be applied to a child.
  • double heightFactor: Height fraction that will be applied to a child.
  • widget child: A widget that will be rendered whose size depends on widthFactor and heightFactor.

Code Implement:

How to implement code in dart file :

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

In the body, we will add a Column widget with their children. Then, we will add the constructor of FractionallySizedBox which wraps the widget inside the column widget. The FractionallySizedBox needs to be wrapped in a Flexible widget, “so it plays well with a row or a column”.

Container(
height: 24.0,
color: Colors.black,
child: Column(
children: [
Flexible(
child: FractionallySizedBox(
heightFactor: 1, widthFactor: 0.25,
child: Container(color: Colors.orange),
),
),
Fexible(
child: FractionallySizedBox(
heightFactor: 1, widthFactor: 0.15,
child: Container(color: Colors.green)),
),
Fexible(
child: FractionallySizedBox(
heightFactor: 1, widthFactor: 0.05,
child: Container(color: Colors.blue)
),
),
]
)
)

The below example sets the Container width to 50% of the parent container’s width. Since the heightFactor is not set, it uses the height constraint from its parent.

Container(
height: 200,
width: 300,
color: Colors.indigo,
child: FractionallySizedBox(
widthFactor: 0.5,
child: Container(
alignment: Alignment.center,
color: Colors.red,
child:
_buildTextWidget(text: "Demo Project", color: Colors.white),
),
),
),

The below example sets the button’s height to 75% of the container’s height. Since the widthFactor is not set, it uses the width constraint from its parent.

Container(
height: 100,
width: 180,
color: Colors.purpleAccent,
child: FractionallySizedBox(
heightFactor: 0.75,
child: RaisedButton(
color: Colors.white,
child: _buildTextWidget(text: 'Click', color: Colors.red),
onPressed: () {},
),
),
),

The below example describes how we can set the height and width of the containers wrapped in a row widget using FractionallySizedBox. It’s really important if we use FractinallySizedBox widget in row or column must be wrapped in flexible widget. Here, I try to explain to you that we can set the height and width of containers using different heightFactor and widthFactor.

Container(
height: 220,
width: double.infinity,
color: Colors.yellowAccent,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Flexible(
child: FractionallySizedBox(
heightFactor: 1,
widthFactor: 1,
child: Container(color: Colors.orange),
),
),
Flexible(
child: FractionallySizedBox(
heightFactor: 0.7,
widthFactor: 0.7,
child: Container(color: Colors.green)),
),
Flexible(
child: FractionallySizedBox(
heightFactor: 0.4,
widthFactor: 0.4,
child: Container(color: Colors.blue)),
),
]),
),

By Default, the Child is aligned at a Center. To change the position of the child wrapped in FractionallySizedBox we use alignment Property. Consider a code snippet as below:

Container(
height: 100,
width: 180,
color: Colors.purpleAccent,
child: FractionallySizedBox(
heightFactor: 0.6,
widthFactor: 0.5,
alignment: Alignment.bottomRight,
child: RaisedButton(
color: Colors.white,
child: _buildTextWidget(text: 'Click', color: Colors.red),
onPressed: () {},
),
),
),

Code File:

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

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

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white54,
appBar: AppBar(
title: Text('Fractionally Sized Box'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
height: 200,
width: 300,
color: Colors.indigo,
child: FractionallySizedBox(
widthFactor: 0.5,
child: Container(
alignment: Alignment.center,
color: Colors.red,
child:
_buildTextWidget(text: "Demo Project", color: Colors.white),
),
),
),
Flexible(
child: FractionallySizedBox(
heightFactor: 1,
widthFactor: 1,
child: Container(
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Flexible(
child: FractionallySizedBox(
widthFactor: 0.08,
child: _buildTextWidget(
text: 'Fractional', color: Colors.deepOrangeAccent),
)),
Flexible(
child: FractionallySizedBox(
widthFactor: 0.05,
child: _buildTextWidget(
text: 'Sized', color: Colors.indigoAccent),
)),
Flexible(
child: FractionallySizedBox(
widthFactor: 0.05,
child: _buildTextWidget(text: 'Box', color: Colors.black),
)),
],
),
),
),
),
Container(
height: 220,
width: double.infinity,
color: Colors.yellowAccent,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Flexible(
child: FractionallySizedBox(
heightFactor: 1,
widthFactor: 1,
child: Container(color: Colors.orange),
),
),
Flexible(
child: FractionallySizedBox(
heightFactor: 0.7,
widthFactor: 0.7,
child: Container(color: Colors.green)),
),
Flexible(
child: FractionallySizedBox(
heightFactor: 0.4,
widthFactor: 0.4,
child: Container(color: Colors.blue)),
),
]),
),
Container(
height: 100,
width: 180,
color: Colors.purpleAccent,
child: FractionallySizedBox(
heightFactor: 0.6,
widthFactor: 0.5,
alignment: Alignment.bottomRight,
child: RaisedButton(
color: Colors.white,
child: _buildTextWidget(text: 'Click', color: Colors.red),
onPressed: () {},
),
),
),
],
),
);
}

_buildTextWidget({
required String text,
required Color color,
}) {
return Text(
text,
style: TextStyle(color: color, fontWeight: FontWeight.bold, fontSize: 20),
);
}
}

Conclusion:

In the article, I have explained the FractionallySizedBox Widget’s basic structure in a flutter; you can modify this code according to your choice. This was a small introduction to the FractionallySizedBox 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 FractionallySizedBox Widget in your flutter projects. We will show you what the FractionallySizedBox Widget is?. Some FractionallySizedBox widget properties, make a demo program for working FractionallySizedBox Widget. 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.


GitHub Link:

find the source code of the FractionallySizedBox :

GitHub – flutter-devs/fractionallysizedbox
A new Flutter project. This project is a starting point for a Flutter application. A few resources to get you started…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 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.

Related: Dark Mode Implementation

Related: Handling Navigation Stacks

Related: Building AI-Powered Image, Voice & Text Features in Flutter: A Practical Blueprint

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


Material Banner In Flutter

0

Google, the search giant recently rolled out the new stable version of its Extensive Popular Cross-Platform UI Framework Flutter. Flutter 2.5 is out with 4600 closed issues and 3932 merged PRs. Flutter is release proceeds with a few significant performance and tooling improvements to find performance issues in your application.

MaterialBanner support to the ScaffoldMessenger. You may remember the ScaffoldMessenger from the Flutter 2.0 release announcement as a more robust way to show Snackbar at the bottom of the screen to provide users with notifications. In Flutter 2.5, you can now add a banner to the top of your scaffold that stays in place until the user dismisses it.

In this article, we will explore How to show a banner at the top of a screen in Flutter Applications. We will also implement a demo program that helps you to understand.


Table Of Contents::

Introduction

Properties

Code Implement

Code File

Conclusion

GitHub Link


Introduction:

The banner should be displayed at the top of the screen, below a top app bar. They’re persistent and nonmodal, allowing the user to either ignore them or interact with them at any time. Only one banner should be shown at a time.

A Material Design banner is a banner that displays an important, sufficient message, and provides actions for users to address (or dismiss the banner). A user action is required for it to be dismissed.

Demo:

Properties:

  • content: This property takes in a Text Widget as the object to show messages to the users in the banner.
  • leading: Show an image logo or Icons about the banner information eg: info, warning, success.
  • backgroundColor: Gives color to Material Banner.
  • actions(mandatory): It accepts an array of the widget when the user can interact to perform some event.
  • padding: The amount of space by which to insert the content.
  • forceActionBelow: If this is true, the actions will be placed below the content. If this is false, the actions will be placed on the trailing side of the content if the actions’ length is 1 and below the content if greater than 1.
  • contentTextStyle: This property is responsible for the styling of content text in the Material Banner widget. It takes in TexStyle class as the object.

Code Implement:

How to implement code in dart file :

If your flutter version is not upgraded first you need to update the flutter version, To update your flutter SDK version to 2.5 you just need to run a command on a Command Prompt or IDE Terminal.

flutter upgrade

Create a new dart file called home_screen.dart inside the lib folder to design the user interface and make sure we need to create a StatefulWidget.

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

final String title;

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

class _HomeScreenState extends State<HomeScreen> {
//Write your code inside...
}

In the body, I wrap the Elevated button and Text widget inside the column widget, and Material Banner is shown on the click event of the button. When the elevated button is pressed user defines method _showMaterialBanner is called which returns MaterialBanner.

MaterialBanner _showMaterialBanner(BuildContext context) {
return MaterialBanner(
//Write your code to design material banner)

Your app can get this behavior by calling the showMaterialBanner method of ScaffoldMessanger. The SnackBar API within the Scaffold is also handled by the ScaffoldMessanger, one of which is available by default within the context of a MaterialApp.

ElevatedButton(
child: const Text('Show MaterialBanner'),
onPressed: () => ScaffoldMessenger.of(context).showMaterialBanner(
//Wrap MaterialBanner Widget inside.);

The Flutter Material Banner according to its guidelines, The state of Banner should show only once to the user. If showMaterialBanner is called more than one time, then ScaffordMessenger will maintain a queue for the next banner to be shown.

Therefore when the previous banner(current active banner) is dismissed then-new banner that is in the queue will be shown. To do that we just need to call ..removeCurrentMaterialBanner() before invoking the new Material Banner in a flutter.

 ScaffoldMessenger.of(context)
..removeCurrentMaterialBanner()
..showMaterialBanner(_showMaterialBanner(context));

In MaterialBanner we can add content, leading, background colors, padding, and actions and you can also style the content using property contentTextStyle. MaterialBanner comes with multiple properties

In order to add content with style to the material banner, we need to do

content: Text('Hello, I am a Material Banner'),
contentTextStyle: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold, color: Colors.indigo),

In order to add Background color to the material banner, we need to do

backgroundColor: Colors.lightGreenAccent,

In order to add Icon at the leading position to material banner, we need to write

leading: Icon(Icons.error),

The set of actions that are displayed at the bottom or trailing side of the MaterialBanner. It accepts an array of the widget when the user can interact to perform some event.

actions: [
TextButton(
onPressed: () {},
child: Text(
'Agree',
style: TextStyle(color: Colors.purple),
),
),
TextButton(
onPressed: () {
ScaffoldMessenger.of(context).hideCurrentMaterialBanner();
},
child: Text(
'Cancel',
style: TextStyle(color: Colors.purple),
),
),
]

Code File:

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

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

final String title;

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

class _HomeScreenState extends State<HomeScreen> { MaterialBanner _showMaterialBanner(BuildContext context) {
return MaterialBanner(
content: Text('Hello, I am a Material Banner'),
leading: Icon(Icons.error),
padding: EdgeInsets.all(15),
backgroundColor: Colors.lightGreenAccent,
contentTextStyle: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold, color: Colors.indigo),
actions: [
TextButton(
onPressed: () {},
child: Text(
'Agree',
style: TextStyle(color: Colors.purple),
),
),
TextButton(
onPressed: () {
ScaffoldMessenger.of(context).hideCurrentMaterialBanner();
},
child: Text(
'Cancel',
style: TextStyle(color: Colors.purple),
),
),
]);
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button to see MaterialBanner:',
style:
TextStyle(color: Colors.indigo, fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
ElevatedButton(
onPressed: () {
ScaffoldMessenger.of(context)
..removeCurrentMaterialBanner()
..showMaterialBanner(_showMaterialBanner(context));
},
child: Text(
'Click Here',
style: TextStyle(color: Colors.purple),
),
style: ElevatedButton.styleFrom(
primary: Colors.lightGreenAccent,
),
),
],
),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the MaterialBanner Widget in your flutter projects. We will show you what the MaterialBanner Widget is?. Some MaterialBanner widget properties, make a demo program for working MaterialBanner Widget. 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.


GitHub Link:

find the source code of the MaterialBanner :

GitHub – flutter-devs/MaterialBanner
A new Flutter project. This project is a starting point for a Flutter application. A few resources to get you started…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 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.

Related: SMS Using Twilio In Flutter

Related: Using SharedPreferences in Flutter

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


Cupertino Picker In Flutter

0

If you are new to flutter then you would like to know about Cupertino. so I am introducing some summary of Cupertino.

Cupertino is a package that has all ios widgets. This package is designed for apps that run in iOS style and to make beautiful and high-fidelity widgets for the current iOS design.

  • Cupertino widgets respect platform differences and hence don’t support all features of Material widgets.
  • Using the Cupertino widgets is optional even when you’re building apps for only iOS devices.
  • Only some Cupertino widgets will work in a MaterialApp()/ Scaffold().

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


Table Contents:

Cupertino Picker

Cupertino Picker Types

Code Implementation

Conclusion

GitHub Link



Cupertino Picker:

Cupertino Picker is a simple dialog to show a list of items. Displays its children widgets on a wheel for selection and calls back when the currently selected item changes.

Domo module:


Cupertino Picker Types:

There are several modes of the picker listed here.

  • > Cupertino Picker
  • > Cupertino DatePicker
  • > Cupertino TimePicker

Code Implementation:

Let’s see How to implement the code

First I have created a screen with 3 buttons to show. Cupertino Picker, Cupertino DatePicker, and Cupertino TimePicker. Below is the code snippet.

Column(
children: [
Container(
height: 50,
width:MediaQuery.of(context).size.width ,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.pinkAccent
),
child: Center(
child: Text("Cupertino Picker",
style: TextStyle(
color: Colors.white
),),
),
),
Container(
padding: EdgeInsets.only(top: 8,bottom: 8),
child: Text("Set Picker",
//textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, ),),
),
],
),
), child: Column(
children: [
Container(
height: 50,
width:MediaQuery.of(context).size.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.blue
),
child: Center(
child: Text("Cupertino DatePicker",
style: TextStyle(
color: Colors.white
),),
),
),
Container(
padding: EdgeInsets.only(top: 8,bottom: 8),
child: Text("Set DatePicker",
style: TextStyle(
color: Colors.black
),),
),
],
),
), child: Column(
children: [
Container(
height: 50,
width:MediaQuery.of(context).size.width ,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.orange
),
child: Center(
child: Text("Cupertino TimePicker",
style: TextStyle(
color: Colors.white
),),
),
),
Container(
padding: EdgeInsets.only(top: 8,bottom: 8),
child: Text("Set TimePicker",
style: TextStyle(
color: Colors.black
),),
),
],
),
),

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

Home Screen

After that, I have created a method. In this method, I am fixing a container with height in the bottom and take a child widget SafeArea in which I am showing all the pickers. Below is the code snippet.

Widget _buildBottomPicker(Widget picker) {
return Container(
height: _kPickerSheetHeight,
padding: const EdgeInsets.only(top: 6.0),
color: CupertinoColors.white,
child: DefaultTextStyle(
style: const TextStyle(
color: CupertinoColors.black,
fontSize: 22.0,
),
child: GestureDetector(
// Blocks taps from propagating to the modal sheet and popping.
onTap: () {},
child: SafeArea(
top: false,
child: picker,
),
),
),
);
}

This first button is for the Cupertino picker. To click on this button I am open a Cupertino picker with the list of text items and set it on textview which I am selecting the item.

InkWell(
onTap: (){
showCupertinoModalPopup<void>(
context: context, builder: (BuildContext context){
return _buildBottomPicker(
_buildCupertinoPicker()
);
});
},
child: Column(
children: [
Container(
height: 50,
width:MediaQuery.of(context).size.width ,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.pinkAccent
),
child: Center(
child: Text("Cupertino Picker",
style: TextStyle(
color: Colors.white
),),
),
),
// SizedBox(height: 30,),
Container(
padding: EdgeInsets.only(top: 8,bottom: 8),
child: Text("$selectItem",style: TextStyle(
color: Colors.black,),),
),
],
),
),

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

Cupertino Picker

This second button is for the Cupertino Date picker. To click on this button I am showing a Cupertino Date picker with the list of dates and set it on textview which I am selecting the date.

InkWell(
onTap: (){
showCupertinoModalPopup<void>(
context: context, builder: (BuildContext context){
return _buildBottomPicker(
_buildDateTimePicker()
);
});
},
child: Column(
children: [
Container(
height: 50,
width:MediaQuery.of(context).size.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.blue
),
child: Center(
child: Text("Cupertino Date Picker",
style: TextStyle(
color: Colors.white
),),
),
),
Container(
padding: EdgeInsets.only(top: 8,bottom: 8),
child: Text("$dateTime",
style: TextStyle(
color: Colors.black
),),
),
],
),
),

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

Cupertino Date Picker

This third button is for the Cupertino Time picker. To click on this button I am showing a Cupertino Time picker with the list of times and set it on textview which I am selecting the time.

InkWell(
onTap: (){
showCupertinoModalPopup<void>(
context: context, builder: (BuildContext context){
return _buildBottomPicker(
timePicker()
);
});
},
child: Column(
children: [
Container(
height: 50,
width:MediaQuery.of(context).size.width ,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.orange
),
child: Center(
child: Text("Cupertino Time Picker",
style: TextStyle(
color: Colors.white
),),
),
),
Container(
padding: EdgeInsets.only(top: 8,bottom: 8),
child: Text("$time",
style: TextStyle(
color: Colors.black
),),
),
],
),
),

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

Cupertino Time Picker

Conclusion:

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

I hope this blog will provide you with sufficient information on Trying up the Explore, Cupertino Picker Widget in your flutter projects.

❤ ❤ 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.

GitHub Link:

find the source code of the Flutter Cupertino Picker Demo:

GitHub – flutter-devs/cupertino_picker_demo_app
Contribute to flutter-devs/cupertino_picker_demo_app development by creating an account on GitHub.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 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.

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

Flutter 2.0 Button Cheat Sheet

0

People who were used to the old ways of using buttons had been left with a new way to implement a button which was a bit confusing at the start, the change of the names and many parameters led to confusion, and people had to google multiple times, what previously had been written on the back of their hand.

So, to end the confusion once and for all and provide people with a way to easily use the new buttons, I’ve decided to write this Blog.



With the introduction of 2.0 the names of the buttons were changed:

a) FlatButton — The previously used FlatButton is now known as TextButton and uses the theme of TextButtonTheme.

b) RaisedButton — The previously used RaisedButton is now known as ElevatedButton and uses the theme of ElevatedButtonTheme.

c) OutlineButton — The previously used OutlineButton is now known as OutlinedButton(a pretty small change in name here) and uses the OutlinedButtonTheme.

NOTE: If your old project needs to migrate to the new way of using the button then it’s best to consult a migration guide for which more information can be found here.

Now, the API Changes on how to use these new buttons

A new object called ButtonStyle is introduced, just like how you can configure a Text widget with TextStyle, you can now configure the buttons using the new ButtonStyle widget

An example of using the new way:

TextButton(
onPressed: (){},
child: Text('Hello'),
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all(Colors.transparent),
overlayColor: MaterialStateProperty.resolveWith(
(Set<MaterialState> states) {
if (states.contains(MaterialState.hovered))
return Colors.red;
else if (states.contains(MaterialState.focused))
return Colors.green;
else if(states.contains(MaterialState.selected))
return Colors.blue;
else
return
Colors.black;
},
),
),

),

The MaterialStateProperty<Color> returns the value of the color you specify, in the forgroundColor we have given MaterialStateProperty.all and specified the name of the color there, if you leave it as null then it will take the widget’s default on its own.

However, there is another way to provide styling to a button, it’s called styleFrom, instead of specifying ButtonStyle, you can use <The name of the button>.styleFrom() like ElevatedButton.styleFrom().

An example of it would be :

TextButton(
onPressed: (){},
child: Text('Hello'),
style: TextButton.styleFrom()
),

Inside it, you can specify all the other properties like padding and color, etc.


Now, moving on we will be discussing how some of the new properties work.

Padding — the new way of providing padding with ButtonStyle is :

style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(EdgeInsets.zero)
),

The styleFrom method for the same would be:

style: TextButton.styleFrom(
padding: EdgeInsets.zero
)

Shape — the new way of providing shape with ButtonStyle is

style: ButtonStyle(
shape: MaterialStateProperty.all<
OutlinedBorder>(
RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(50),
side: BorderSide(color: Colors.red),
),
),
),

The styleFrom method for the same would be:

style: TextButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(50),
side: BorderSide(color: Colors.red),
),
)

Side — the new way of providing border side with Buttonstyle is:

TextButton(
onPressed: () {},
child: Text('Hello'),
style: ButtonStyle(
side: MaterialStateProperty.all<BorderSide>(BorderSide(
color: Colors.red
))
),
),

The styleFrom method for the same is:

TextButton(
onPressed: () {},
child: Text('Hello'),
style: TextButton.styleFrom(
side: BorderSide(
color: Colors.red
)
),
),

Alignment — the new way of providing alignment is quite simple(with ButtonStyle):

TextButton(
onPressed: () {},
child: Text('Hello'),
style: ButtonStyle(
alignment: Alignment.center,
),
),

The styleFrom method for it is the same:

TextButton(
onPressed: () {},
child: Text('Hello'),
style: TextButton.styleFrom(
alignment: Alignment.center,
),
),

Elevation — the new way to provide elevation with ButtonStyle is:

TextButton(
onPressed: () {},
child: Text('Hello'),
style: ButtonStyle(
elevation: MaterialStateProperty.all<double>(1.0)
),
),

The styleFrom method for the same is:

TextButton(
onPressed: () {},
child: Text('Hello'),
style: TextButton.styleFrom(
alignment: Alignment.center,
elevation: 1.0
),
),

TextStyle — you can provide textstyle in ButtonStyle this way:

TextButton(
onPressed: () {},
child: Text('Hello'),
style: ButtonStyle(
textStyle: MaterialStateProperty.all<TextStyle>(TextStyle(
color: Colors.red
)),

),
),

FixedSize — you can change the fixedStyle property of ButtonStyle this way:

TextButton(
onPressed: () {},
child: Text('Hello'),
style: ButtonStyle(
fixedSize: MaterialStateProperty.all<Size>(Size(200,300))

),
),

The styleFrom method for the same is:

TextButton(
onPressed: () {},
child: Text('Hello'),
style: TextButton.styleFrom(
fixedSize: Size.fromHeight(150)

),
),

Conclusion:

In the article, I have explained the common properties of Button styling in a flutter; you can modify this code according to your choice. This was a small introduction to the Flutter 2.0 Button cheat sheet On User Interaction from my side, and it’s working using Flutter.

I hope this blog will provide you with sufficient information on Trying up the Flutter 2.0 Button cheat sheet in your flutter projects. We will show you all properties in detail. In this blog, we have examined the Flutter 2.0 Button. I hope this blog will help you in the comprehension of the Flutter 2.0 Button in a better way. So please try it.

❤ ❤ Thanks for reading this article ❤❤

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

Clap 👏 If this article helps you.


From Our Parent Company Aeologic

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

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

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

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

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


Flutter App for Desktop

0

In Flutter 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 blog, we will understand how to run the flutter application on the desktop and what is the requirement to set up this?. We will see the step-by-step flow and create an app for understanding the Desktop app building process.


Table Contents:

Flutter

Flutter benefits

Flutter platform-specific criteria

Set Up for run application on desktop

Implementation

Conclusion

GitHub Link


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 is free and open-source. It was at first evolved from Google and is presently overseen by an ECMA standard. Flutter applications utilize the Dart programming language for making an application. The dart programming shares a few same highlights as other programming dialects, like Kotlin and Swift, and can be trans-arranged into JavaScript code.

Flutter benefits:

Flutter provides us to run the application on multiple platforms. like, Web, Desktop, Android / iOS. There are many languages in the market that run the application on multiple platforms. but flutter takes less time to run the application on different platforms as compared to other languages. because flutter does not use the mediator bridge to run the application as other languages do. So flutter is fast to run the application on different platforms. here is some key point below

  • Same UI and Business Logic in All Platforms.
  • Reduced Code and Development Time.
  • Similar to Native App Performance.
  • Custom, Animated UI is Available for any complex widget.
  • Own Rendering graphic Engine i.e. skia.
  • Simple Platform-Specific Logic Implementation.
  • The Potential Ability to Go Beyond Mobile.

Flutter platform-specific criteria:

  • Android Platform Specific
  • iOS Platform Specific
  • Web Platform Specific
  • Desktop Platform Specific

Set Up for run application on Desktop Platform Specific:

  1. First, you create your flutter project.

2- And then switch your channel to the Beta Flutter channel. because it covers desktop support Which is available in Beta release and for switching channels into beta using this command.

  • > flutter channel beta

Go to the flutter documentation and click on the window setup option and read the documentation.

https://flutter.dev/docs/get-started/install/windows#windows-setup

3- And then Enable your window using this command.

  • > flutter config — enable-windows-desktop

Check below documentation

https://flutter.dev/docs/get-started/install/windows#windows-setup

5- After enabling your window restart your Android studio.

6- After restarting android studio And now create windows support directory using the below command.

  • > flutter create.

7- Now install visual studio go to this link.

Download Visual Studio Tools – Install Free for Windows, Mac, Linux
Full-featured integrated development environment (IDE) for Android, iOS, Windows, web, and cloud Powerful IDE, free for…visualstudio.microsoft.com

8- After visual studio installation finally you can run your app for desktop. Select the Desktop device in your android studio and run the application.

Implementation:

Now I am designing a page for testing on the Desktop. You can make any app for a run on the desktop. I am showing only the last page code implementation of this app here is the code snippet. If you want to look full code then go to the Github link given below.

On this page, I am designing a courses list card with images and text for purchase courses list.

import 'package:e_learning_app/constants/constants.dart';
import 'package:e_learning_app/model/Courses_items_model.dart';
import 'package:e_learning_app/model/read_blog_model.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:io' show Platform;

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

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

class _ReadScreenViewState extends State<ReadScreenView> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: _buildBody(),
);
}

Widget _buildBody() {
return Container(
height: MediaQuery.of(context).size.height,
child: Stack(
children: [
Container(
height: MediaQuery.of(context).size.height,
//color: Colors.cyan,
child: Container(
margin: EdgeInsets.only(bottom: 350),
height: 250,
decoration: BoxDecoration(
color: Color(0xffff9b57),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(40),
bottomRight: Radius.circular(40))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(
left: 20,
right: 20,
top: 30),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap:(){
Navigator.pop(context);
},
child: Container(
//margin: EdgeInsets.only(right: 25,top: 10),
height: 30,
width: 30,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: Color(0xfff3ac7c),
),
child: Icon(
Icons.arrow_back,
color: Colors.white,
size: 20,
),
),
),
Container(
// margin: EdgeInsets.only(right: 25,top: 10),
height: 30,
width: 30,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: Color(0xfff3ac7c),
),
child: Icon(
Icons.menu,
color: Colors.white,
size: 20,
),
),
])),
Container(
padding: EdgeInsets.only(left: 20, right: 20, top: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Text(
"Purchase Courses",
style: TextStyle(
color: Colors.white,
fontSize: 20,
//fontWeight: FontWeight.bold
),
),
),
SizedBox(
height: 5,
),
Container(
child: Text(
"Categories",
style: TextStyle(
color: Colors.white,
fontSize: 12,
//fontWeight: FontWeight.bold
),
),
),
],
),
),
Container(
padding: EdgeInsets.only(left: 20, top: 16),
height: 140,
alignment: Alignment.center,
//color: Colors.orange,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: readBlogList.length,
itemBuilder: (BuildContext context, int index) {
return _buildCategorySection(readBlogList[index]);
}),
),
],
),
),
),
Positioned(
top: 260,
left: 0,
right: 0,
bottom: 0,
child: SizedBox(
height: MediaQuery.of(context).size.height - 260,
width: MediaQuery.of(context).size.width,
child: Container(
//color: Colors.yellow,
padding: EdgeInsets.only(left: 4, right: 4),
width: MediaQuery.of(context).size.width,
child: ListView.builder(
//physics: NeverScrollableScrollPhysics(),
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: readBlogList.length,
itemBuilder: (BuildContext context, int index) {
return _buildPurchaseCourses(readBlogList[index]);
}),
),
),
),
Positioned(
bottom: 0,
child: Container(
padding:
EdgeInsets.only(left: 20, right: 20, top: 10, bottom: 10),
height: 70,
width: MediaQuery.of(context).size.width,
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Purchase Courses",
style: TextStyle(
color: Colors.black,
fontSize: 14,
//fontWeight: FontWeight.bold
),
),
Text(
"5",
style: TextStyle(
color: Colors.red,
fontSize: 20,
//fontWeight: FontWeight.bold
),
),
],
),
Container(
height: 40,
width: 130,
margin: EdgeInsets.only(bottom: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Color(0xffdc4651)),
child: Container(
padding: EdgeInsets.only(left: 20, right: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Category",
style: TextStyle(color: Colors.white),
),
Icon(Icons.arrow_drop_down, color: Colors.white)
],
),
),
)
],
),
),
),
],
),
);
}

Widget _buildCategorySection(ReadBlogModel readBlogList) {
return Container(
height: 50,
width: 110,
child: Card(
color: Colors.white,
child: Column(
//mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: 90,
child: ClipRRect(
borderRadius: BorderRadius.only(topLeft: Radius.circular(5),topRight: Radius.circular(5)),
child: Image.network(
readBlogList.image!,
fit: BoxFit.fill,
height: 50,
width: 110,
),
)),
Container(
padding: EdgeInsets.all(5),
child: Text(
"Categories",
style: TextStyle(
color: Colors.black,
fontSize: 12,
//fontWeight: FontWeight.bold
),
),
),
],
),
),
);
}

Widget _buildPurchaseCourses(ReadBlogModel readBlogList) {
return Container(
margin: EdgeInsets.only(left: 10, right: 10),
//padding: EdgeInsets.only(left: 10,right: 20),
height: 80,
child: Card(
child: Container(
padding: EdgeInsets.only(left: 10, right: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: 40,
width: 40,
child: ClipRRect(
child: Image.network(
readBlogList.image!,
fit: BoxFit.fill,
),
borderRadius: BorderRadius.circular(8),
),
),
//SizedBox(width: 20,),
Container(
padding: EdgeInsets.only(right: 120),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
readBlogList.title!,
style: TextStyle(
fontSize: 12,
//fontWeight: FontWeight.bold
),
),
Text(
readBlogList.subTitle!,
style: TextStyle(
fontSize: 12,
//fontWeight: FontWeight.bold
),
),
],
),
),
// SizedBox(width: 130,),
Container(
height: 30,
width: 30,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Color(0xfffee8db),
),
child: Icon(
Icons.done,
color: Color(0xffdd8e8d),
size: 16,
),
)
],
),
),
));
}

}

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


Conclusion:

In this article, I have explained the setup for the Desktop applications in a flutter.

I hope this blog will provide you with sufficient information on Trying up the Explore, and explain in brief your flutter projects.

❤ ❤ 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.


GitHub Link:

find the source code of the Flutter E-learning Demo app

GitHub – flutter-devs/flutter_app_for_desktop: how to set up for run the application on desktop
Permalink Failed to load the latest commit information. A new Flutter project. This project is a starting point for a…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 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.

Related: Developing Web Apps Using Flutter

Related: Plugins in Flutter | Plugins created by FlutterDevs

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