Flutter how to Fix container on a top - flutter

I don't use navbar in my app I have created a custom navbar but the issue is it's not fixed. mean when i scroll page navbar also scroll down. I need to fix it so it can be stick on top.
My code
class HomeScreen extends StatefulWidget {
#override
_HomeScreenState createState() => _HomeScreenState();
}
enum BottomIcons { Home, Favorite, Search, Account }
class _HomeScreenState extends State<HomeScreen> {
double xOffset = 0;
double yOffset = 0;
double scaleFactor = 1;
bool isDrawerOpen = false;
int currentIndex = 0;
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
BottomIcons bottomIcons = BottomIcons.Home;
#override
Widget build(BuildContext context) {
double statusBarHeight = MediaQuery.of(context).padding.top;
double Height = MediaQuery.of(context).size.height;
double Width = MediaQuery.of(context).size.width;
var bottomNavigationBar;
return AnimatedContainer(
transform: Matrix4.translationValues(xOffset, yOffset, 0)
..scale(scaleFactor)
..rotateY(isDrawerOpen ? -0.5 : 0),
duration: Duration(milliseconds: 250),
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(isDrawerOpen ? 40 : 0.0)),
child: Scaffold(
bottomNavigationBar: Padding(
padding: const EdgeInsets.all(12.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
BottomBar(
onPressed: () {
setState(() {
bottomIcons = BottomIcons.Home;
});
},
bottomIcons:
bottomIcons == BottomIcons.Home ? true : false,
icons: EvaIcons.home,
text: "Home"),
BottomBar(
onPressed: () {
setState(() {
bottomIcons = BottomIcons.Favorite;
});
},
bottomIcons:
bottomIcons == BottomIcons.Favorite ? true : false,
icons: EvaIcons.heartOutline,
text: "Favorite"),
BottomBar(
onPressed: () {
setState(() {
bottomIcons = BottomIcons.Search;
});
},
bottomIcons:
bottomIcons == BottomIcons.Search ? true : false,
icons: EvaIcons.search,
text: "Search"),
BottomBar(
onPressed: () {
setState(() {
bottomIcons = BottomIcons.Account;
});
},
bottomIcons:
bottomIcons == BottomIcons.Account ? true : false,
icons: EvaIcons.personOutline,
text: "Account"),
],
),
),
body: SingleChildScrollView(
child: Column(
children: [
Container(
height: Height * 0.1,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/nav.png"),
fit: BoxFit.cover,
),
),
child: Padding(
padding: const EdgeInsets.only(top: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
isDrawerOpen
? Padding(
padding: const EdgeInsets.only(left: 10),
child: GestureDetector(
onTap: () {
setState(() {
xOffset = 0;
yOffset = 0;
scaleFactor = 1;
isDrawerOpen = false;
});
},
child: Container(
height: Height * 0.03,
width: Width * 0.06,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/ross.png"),
),
),
),
),
)
: Padding(
padding: const EdgeInsets.only(left: 10),
child: GestureDetector(
onTap: () {
setState(() {
xOffset = 280;
yOffset = 150;
scaleFactor = 0.6;
isDrawerOpen = true;
});
},
child: Container(
height: Height * 0.03,
width: Width * 0.06,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/ic.png"),
),
),
),
),
),
Container(
width: Width * 0.25,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/logo.png"),
),
),
),
Row(
children: [
Container(
height: Height * 0.03,
width: Width * 0.06,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/i2.png"),
),
),
),
SizedBox(
width: Width * 0.04,
),
Container(
height: Height * 0.03,
width: Width * 0.06,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/i1.png"),
),
),
),
SizedBox(
width: Width * 0.06,
),
],
)
],
),
),
),
Container(
padding: EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
RichText(
text: new TextSpan(
// Note: Styles for TextSpans must be explicitly defined.
// Child text spans will inherit styles from parent
style: new TextStyle(
fontSize: 14.0,
color: Colors.black,
),
children: <TextSpan>[
new TextSpan(
text: 'Popular ',
style: new TextStyle(
fontWeight: FontWeight.bold,
fontSize: 22)),
new TextSpan(
text: 'Categories',
style: TextStyle(fontSize: 18)),
],
),
),
Container(
width: Width * 0.1,
height: Height * 0.05,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/more.png"),
),
),
),
],
),
),
Container(
color: Color(0xffECF0F1),
padding: EdgeInsets.all(0),
child: GridView(
padding: EdgeInsets.all(0),
shrinkWrap: true,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisSpacing: 1.5,
mainAxisSpacing: 1.5,
crossAxisCount: 4,
),
children: <Widget>[
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat1.png'),
),
SizedBox(
height: Height * 0.008,
),
Text(
'Computer Hardware',
textAlign: TextAlign.center,
)
],
),
),
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat2.png'),
),
SizedBox(
height: Height * 0.008,
),
Text('Computer Software',
textAlign: TextAlign.center)
],
),
),
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat3.png'),
),
SizedBox(
height: Height * 0.008,
),
Text('Internet', textAlign: TextAlign.center)
],
),
),
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat4.png'),
),
SizedBox(
height: Height * 0.008,
),
Text('Mobile / Table & iPad',
textAlign: TextAlign.center)
],
),
),
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat5.png'),
),
SizedBox(
height: Height * 0.008,
),
Text(
'Printer & Scanner',
textAlign: TextAlign.center,
)
],
),
),
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat6.png'),
),
SizedBox(
height: Height * 0.008,
),
Text('CCTV Cameras', textAlign: TextAlign.center)
],
),
),
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat7.png'),
),
SizedBox(
height: Height * 0.008,
),
Text('Smart TV/Home Theater',
textAlign: TextAlign.center)
],
),
),
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat8.png'),
),
SizedBox(
height: Height * 0.008,
),
Text('E-Learning', textAlign: TextAlign.center)
],
),
),
],
),
),
SizedBox(
height: Height * 0.015,
),
CarouselSlider(
options: CarouselOptions(
autoPlay: true,
aspectRatio: 2,
enlargeCenterPage: true,
enlargeStrategy: CenterPageEnlargeStrategy.height,
),
items: imageSliders,
),
Container(
padding: EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
RichText(
text: new TextSpan(
// Note: Styles for TextSpans must be explicitly defined.
// Child text spans will inherit styles from parent
style: new TextStyle(
fontSize: 14.0,
color: Colors.black,
),
children: <TextSpan>[
new TextSpan(
text: 'Service ',
style: new TextStyle(
fontWeight: FontWeight.bold,
fontSize: 22)),
new TextSpan(
text: 'Deals',
style: TextStyle(fontSize: 18)),
],
),
),
Container(
width: Width * 0.1,
height: Height * 0.05,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/see.png"),
),
),
),
],
),
),
Container(
width: double.infinity,
child: CarouselSlider(
options: CarouselOptions(
disableCenter: true,
enableInfiniteScroll: false,
viewportFraction: 0.7,
enlargeCenterPage: false,
height: Height * 0.21,
),
items: list
.map((item) => Container(
child: Image.asset(item),
))
.toList(),
)),
],
),
)));
}
}
This is my code I am using a simple column for the whole screen but the issue is in the column I need to fixed the container and scroll the other container.

The custom AppBar was a child of the SingleChildScrollView itself. Hence, it scrolled. Now, it is a child of a stack which persistently sticks to the top, hence won't scroll.
class HomeScreen extends StatefulWidget {
#override
_HomeScreenState createState() => _HomeScreenState();
}
enum BottomIcons { Home, Favorite, Search, Account }
class _HomeScreenState extends State<HomeScreen> {
double xOffset = 0;
double yOffset = 0;
double scaleFactor = 1;
bool isDrawerOpen = false;
int currentIndex = 0;
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
BottomIcons bottomIcons = BottomIcons.Home;
#override
Widget build(BuildContext context) {
double statusBarHeight = MediaQuery.of(context).padding.top;
double Height = MediaQuery.of(context).size.height;
double Width = MediaQuery.of(context).size.width;
var bottomNavigationBar;
return AnimatedContainer(
transform: Matrix4.translationValues(xOffset, yOffset, 0)
..scale(scaleFactor)
..rotateY(isDrawerOpen ? -0.5 : 0),
duration: Duration(milliseconds: 250),
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(isDrawerOpen ? 40 : 0.0)),
child: Scaffold(
bottomNavigationBar: Padding(
padding: const EdgeInsets.all(12.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
BottomBar(
onPressed: () {
setState(() {
bottomIcons = BottomIcons.Home;
});
},
bottomIcons:
bottomIcons == BottomIcons.Home ? true : false,
icons: EvaIcons.home,
text: "Home"),
BottomBar(
onPressed: () {
setState(() {
bottomIcons = BottomIcons.Favorite;
});
},
bottomIcons:
bottomIcons == BottomIcons.Favorite ? true : false,
icons: EvaIcons.heartOutline,
text: "Favorite"),
BottomBar(
onPressed: () {
setState(() {
bottomIcons = BottomIcons.Search;
});
},
bottomIcons:
bottomIcons == BottomIcons.Search ? true : false,
icons: EvaIcons.search,
text: "Search"),
BottomBar(
onPressed: () {
setState(() {
bottomIcons = BottomIcons.Account;
});
},
bottomIcons:
bottomIcons == BottomIcons.Account ? true : false,
icons: EvaIcons.personOutline,
text: "Account"),
],
),
),
body: Stack(
children: [
Positioned.fill(
child: SingleChildScrollView(
child: Column(
children: [
Container(
padding: EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
RichText(
text: new TextSpan(
// Note: Styles for TextSpans must be explicitly defined.
// Child text spans will inherit styles from parent
style: new TextStyle(
fontSize: 14.0,
color: Colors.black,
),
children: <TextSpan>[
new TextSpan(
text: 'Popular ',
style: new TextStyle(
fontWeight: FontWeight.bold,
fontSize: 22)),
new TextSpan(
text: 'Categories',
style: TextStyle(fontSize: 18)),
],
),
),
Container(
width: Width * 0.1,
height: Height * 0.05,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/more.png"),
),
),
),
],
),
),
Container(
color: Color(0xffECF0F1),
padding: EdgeInsets.all(0),
child: GridView(
padding: EdgeInsets.all(0),
shrinkWrap: true,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisSpacing: 1.5,
mainAxisSpacing: 1.5,
crossAxisCount: 4,
),
children: <Widget>[
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat1.png'),
),
SizedBox(
height: Height * 0.008,
),
Text(
'Computer Hardware',
textAlign: TextAlign.center,
)
],
),
),
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat2.png'),
),
SizedBox(
height: Height * 0.008,
),
Text('Computer Software',
textAlign: TextAlign.center)
],
),
),
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat3.png'),
),
SizedBox(
height: Height * 0.008,
),
Text('Internet', textAlign: TextAlign.center)
],
),
),
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat4.png'),
),
SizedBox(
height: Height * 0.008,
),
Text('Mobile / Table & iPad',
textAlign: TextAlign.center)
],
),
),
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat5.png'),
),
SizedBox(
height: Height * 0.008,
),
Text(
'Printer & Scanner',
textAlign: TextAlign.center,
)
],
),
),
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat6.png'),
),
SizedBox(
height: Height * 0.008,
),
Text('CCTV Cameras', textAlign: TextAlign.center)
],
),
),
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat7.png'),
),
SizedBox(
height: Height * 0.008,
),
Text('Smart TV/Home Theater',
textAlign: TextAlign.center)
],
),
),
Container(
color: Colors.white,
child: Column(
children: [
SizedBox(
height: Height * 0.01,
),
Container(
height: Height * 0.04,
child: Image.asset('images/cat8.png'),
),
SizedBox(
height: Height * 0.008,
),
Text('E-Learning', textAlign: TextAlign.center)
],
),
),
],
),
),
SizedBox(
height: Height * 0.015,
),
CarouselSlider(
options: CarouselOptions(
autoPlay: true,
aspectRatio: 2,
enlargeCenterPage: true,
enlargeStrategy: CenterPageEnlargeStrategy.height,
),
items: imageSliders,
),
Container(
padding: EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
RichText(
text: new TextSpan(
// Note: Styles for TextSpans must be explicitly defined.
// Child text spans will inherit styles from parent
style: new TextStyle(
fontSize: 14.0,
color: Colors.black,
),
children: <TextSpan>[
new TextSpan(
text: 'Service ',
style: new TextStyle(
fontWeight: FontWeight.bold,
fontSize: 22)),
new TextSpan(
text: 'Deals',
style: TextStyle(fontSize: 18)),
],
),
),
Container(
width: Width * 0.1,
height: Height * 0.05,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/see.png"),
),
),
),
],
),
),
Container(
width: double.infinity,
child: CarouselSlider(
options: CarouselOptions(
disableCenter: true,
enableInfiniteScroll: false,
viewportFraction: 0.7,
enlargeCenterPage: false,
height: Height * 0.21,
),
items: list
.map((item) => Container(
child: Image.asset(item),
))
.toList(),
)),
],
),
),
),
Positioned(top: 0,left: 0, child: Container(
height: Height * 0.1,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/nav.png"),
fit: BoxFit.cover,
),
),
child: Padding(
padding: const EdgeInsets.only(top: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
isDrawerOpen
? Padding(
padding: const EdgeInsets.only(left: 10),
child: GestureDetector(
onTap: () {
setState(() {
xOffset = 0;
yOffset = 0;
scaleFactor = 1;
isDrawerOpen = false;
});
},
child: Container(
height: Height * 0.03,
width: Width * 0.06,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/ross.png"),
),
),
),
),
)
: Padding(
padding: const EdgeInsets.only(left: 10),
child: GestureDetector(
onTap: () {
setState(() {
xOffset = 280;
yOffset = 150;
scaleFactor = 0.6;
isDrawerOpen = true;
});
},
child: Container(
height: Height * 0.03,
width: Width * 0.06,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/ic.png"),
),
),
),
),
),
Container(
width: Width * 0.25,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/logo.png"),
),
),
),
Row(
children: [
Container(
height: Height * 0.03,
width: Width * 0.06,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/i2.png"),
),
),
),
SizedBox(
width: Width * 0.04,
),
Container(
height: Height * 0.03,
width: Width * 0.06,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/i1.png"),
),
),
),
SizedBox(
width: Width * 0.06,
),
],
)
],
),
),
),),
],
)));
}
}

Related

how to add horizontal list view in flutter with multiple containers

I want to add horizonal list view like image showing below. how can I do that. below I have addded my code so far. .............. ............. .......... ........... ................. ............. ........... ...... ......... ........ .......... ...................................................................
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:carousel_slider/carousel_slider.dart';
class GetStarted extends StatelessWidget {
final List<String> imagesList = [
'asset/images/canada3.jpg',
'asset/images/canada1.jpg',
'asset/images/canada2.jpg',
];
#override
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return Scaffold(
body: Stack(
children: [
Container(
height: size.height,
width: size.width,
child: CarouselSlider(
options: CarouselOptions(
viewportFraction: 1,
autoPlay: true,
height: size.height,
autoPlayInterval: Duration(seconds: 3),
),
items: imagesList
.map(
(item) => Center(
child: Image.asset(
item,
fit: BoxFit.cover,
width: size.width,
height: size.height,
),
),
)
.toList(),
),
),
Container(
width: size.width,
height: size.height,
color: Colors.black.withOpacity(0.3),
),
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// EndBar(textWhite),
// ],
// ),
Positioned(
top: size.height * 0.9,
left: size.width * 0.08,
child: const Text(
'Login',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w800,
fontSize: 15,
),
)),
Positioned(
top: size.height * 0.9,
right: size.width * 0.08,
child: const Text(
'Skip',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w800,
fontSize: 15,
),
)),
Positioned(
top: size.height * 0.6,
left: size.width * 0.08,
child: const Text(
'Get matched with local pros for\nyour next home project',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w800,
fontSize: 20,
),
)),
],
),
);
}
}
Please replace your build method with this,
#override
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return Scaffold(
body: Stack(
children: [
Container(
height: size.height,
width: size.width,
child: CarouselSlider(
options: CarouselOptions(
viewportFraction: 1,
autoPlay: true,
height: size.height,
autoPlayInterval: Duration(seconds: 3),
),
items: imagesList
.map(
(item) => Center(
child: Image.asset(
item,
fit: BoxFit.cover,
width: size.width,
height: size.height,
),
),
)
.toList(),
),
),
Container(
width: size.width,
height: size.height,
color: Colors.black.withOpacity(0.3),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
padding: EdgeInsets.symmetric(horizontal: 12),
child: Text(
'Get matched with local pros for\nyour next home project',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w800,
fontSize: 20,
),
),
),
SizedBox(height: 16,),
Container(
height: 250,
child: ListView.separated(
separatorBuilder: (context, index){return SizedBox(width: 20,);},
scrollDirection: Axis.horizontal,
itemCount: containerImages.length,
itemBuilder: (context, index) {
return Container(
width: 200,
height: 200,
child: Image.asset(containerImages[index]),
);
},
),
),
Padding(
padding: EdgeInsets.fromLTRB(12, 16, 12, 16),
child: Row(
children: [
const Text(
'Login',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w800,
fontSize: 15,
),
),
Spacer(),
const Text(
'Skip',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w800,
fontSize: 15,
),
)
],
),
)
],
),
],
),
);
}
It will result like,
Container(
height: size.height,
width: size.width,
child: ListView.builder(
itemCount: imagesList.length,
shrinkWrap: true,
scrollDirection: Axis.horizontal,
physics: AlwaysScrollableScrollPhysics(),
itemBuilder: (context, index) {
return Image.asset(
imagesList[index],
fit: BoxFit.cover,
width: size.width,
height: size.height,
);
},
),
)

How can I make my Slidable Container same height as the container in my List Item in flutter?

I am using the Flutter slidable package in my app. I discovered the Container I used in the secondaryAction list of the Slidable Widget has a different height from the list item. For better understanding are two images of the app. Before sliding the list item and after sliding.
Please how can i make that container with black color be same height as the container with green color.
Below is the code implemented for the list design in flutter.
Code for the List Item Design
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// import 'meal_model.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
class MealWidget extends StatelessWidget {
final Widget image;
final String title, subtitle, price;
MealWidget(
{required this.image,
required this.title,
required this.subtitle,
required this.price});
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
double height = size.height;
double width = size.width;
double height2 = height * 0.17;
return Slidable(
actionPane: SlidableDrawerActionPane(),
actionExtentRatio: 0.25,
secondaryActions: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Container(
margin: EdgeInsets.only(top: 0),
height: height * 0.17,
width: width * 0.3,
child: Container(
height: height2 * 0.02,
width: height2 * 0.02,
decoration: BoxDecoration(
color: Color(0xFFF54749), shape: BoxShape.circle),
),
decoration: BoxDecoration(
color: Color(0xFF100B18),
borderRadius: BorderRadius.circular(20)),
),
),
],
child: Container(
height: height2,
width: width,
margin: EdgeInsets.only(bottom: 30),
decoration: BoxDecoration(
color: Colors.green, borderRadius: BorderRadius.circular(20)),
child: Row(
children: [
ClipPath(
clipper: BackgroundClipper(),
child: Container(
height: height * 0.17,
width: width * 0.5,
decoration: BoxDecoration(color: Colors.white),
child: image,
),
),
Expanded(
child: Container(
padding: EdgeInsets.only(right: 10, top: 15, bottom: 15),
width: width * 0.5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text(title,
style: TextStyle(
fontSize: 26,
fontFamily: 'Fira',
fontWeight: FontWeight.w600)),
Text(subtitle,
style: TextStyle(
fontSize: 18,
fontFamily: 'Fira',
fontWeight: FontWeight.w500)),
Text(price,
style: TextStyle(
fontSize: 22,
fontFamily: 'Fira',
fontWeight: FontWeight.bold))
],
),
),
)
],
),
),
);
}
}
class BackgroundClipper extends CustomClipper<Path> {
#override
Path getClip(Size size) {
var roundnessFactor = 20.0;
var path = Path();
path.moveTo(0, 20);
path.lineTo(0, size.height - roundnessFactor);
path.quadraticBezierTo(0, size.height, roundnessFactor, size.height);
path.lineTo(size.width - roundnessFactor, size.height);
path.quadraticBezierTo(
size.width, size.height, size.width, size.height - roundnessFactor);
path.lineTo(size.width * 0.8, 10);
path.quadraticBezierTo(size.width * 0.78, 0, size.width * 0.75, 0);
path.lineTo(roundnessFactor, 0);
path.quadraticBezierTo(0, 0, 0, roundnessFactor);
return path;
}
#override
bool shouldReclip(covariant CustomClipper<Path> oldClipper) {
return true;
}
}
Code for where the list item is implemented in a ListView
import 'package:clip/profile_image.dart';
import 'package:flutter/material.dart';
import 'meal.dart';
import 'meal_model.dart';
import 'dropdown.dart';
class MenuPage extends StatefulWidget {
const MenuPage({Key? key}) : super(key: key);
#override
_MenuPageState createState() => _MenuPageState();
}
class _MenuPageState extends State<MenuPage> {
int selectedIndex = 0;
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
double height = size.height;
double width = size.width;
return GestureDetector(
onTap: () {
FocusNode isCurrentFocusNode = FocusScope.of(context);
if (!isCurrentFocusNode.hasPrimaryFocus) {
isCurrentFocusNode.unfocus();
}
},
child: Scaffold(
backgroundColor: Color(0xFFF7F7F7),
appBar: AppBar(
toolbarHeight: height * 0.09,
backgroundColor: Colors.white,
elevation: 0,
title: Center(child: LocationDropdown()),
actions: [
ProfileImage(),
SizedBox(
width: width * 0.05,
),
],
iconTheme: IconThemeData(color: Colors.black),
),
drawer: Drawer(),
body: Container(
padding: EdgeInsets.symmetric(
vertical: height * 0.02, horizontal: width * 0.05),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Hello, Jenny',
style: TextStyle(fontSize: 32),
),
RichText(
text: TextSpan(
text: 'Best Food for ',
style: TextStyle(
fontSize: 36,
color: Colors.black,
fontWeight: FontWeight.bold),
children: [
TextSpan(
text: 'you', style: TextStyle(color: Color(0xFFF54749)))
])),
SizedBox(
height: height * 0.04,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Material(
elevation: 1,
borderRadius: BorderRadius.circular(10),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
width: width * 0.7,
height: height * 0.05,
child: TextField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.search),
labelText: 'Search',
labelStyle: TextStyle(fontSize: 22),
border: OutlineInputBorder(
borderSide: BorderSide.none)),
),
),
),
Material(
elevation: 1,
borderRadius: BorderRadius.circular(10),
child: Container(
width: width * 0.12,
height: height * 0.05,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'images/filter.png',
)),
borderRadius: BorderRadius.circular(10),
color: Color(0xFFF54749),
),
),
)
],
),
SizedBox(
height: height * 0.05,
),
Container(
height: height * 0.06,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: meals.length,
itemBuilder: (BuildContext context, int index) =>
GestureDetector(
onTap: () {
setState(() {
selectedIndex = index;
});
},
child: Container(
margin: EdgeInsets.only(right: 15),
height: height * 0.06,
padding: EdgeInsets.symmetric(horizontal: 20),
decoration: BoxDecoration(
color: selectedIndex == index
? Color(0xFFF54749)
: Color(0xFFEBEBEB),
borderRadius: BorderRadius.circular(10)),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Container(
height: height * 0.03,
width: height * 0.03,
child: meals[index].mealIcon,
),
SizedBox(
width: width * 0.03,
),
Text(
meals[index].mealCategory,
style: TextStyle(
fontSize: 22,
fontWeight: selectedIndex == index
? FontWeight.bold
: null,
color: selectedIndex == index
? Colors.white
: null),
)
],
)),
)),
),
SizedBox(
height: height * 0.05,
),
Expanded(
child: ListView.builder(
physics: BouncingScrollPhysics(),
shrinkWrap: true,
itemCount: meal.length,
itemBuilder: (context, index) => MealWidget(
image: meal[index].mealImage,
title: meal[index].mealName,
subtitle: meal[index].mealType,
price: meal[index].mealAmount,
)),
),
],
),
),
),
);
}
}

NeverScrollableScrollPhysics() is not working in flutter and need advise about tab padding/margin

#1. I was making a tab menus using tabcontroller, and I wanted to stop it's tab scrolling ability, and wanted to select tab using tab menu click.
I was trying with physics: NeverScrollableScrollPhysics(), but failed.
As a newbie, I don't understand what is the problem or what I am missing!
Here is A GIF file to illustrate my scenario --> here
#2. In this Scenario, the "Places", means the first tab is maintains a padding, how can I remove it and push it to the left, from where the body started?
Thanks in Advance :)
My Code -->
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'dart:math' as math;
void main() => runApp(StartPage());
class StartPage extends StatelessWidget {
static const String _title = 'TravelApp';
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: _title,
home: Scaffold(body: StartPage1()),
);
}
}
class StartPage1 extends StatelessWidget {
#override
Widget build(BuildContext context) {
dynamic screenHeight = MediaQuery.of(context).size.height;
dynamic screenwidth = MediaQuery.of(context).size.width;
return Scaffold(
body: Container(
height: screenHeight,
width: screenwidth,
padding: EdgeInsets.symmetric(
horizontal: screenwidth * 0.03,
vertical: screenHeight * 0.02,
),
child: Container(
// Places BAr
height: screenHeight * 0.20,
child: MaterialApp(
debugShowCheckedModeBanner: false,
home: DefaultTabController(
length: 3,
child: Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(screenHeight * 0.076607387),
child: new Container(
child: SafeArea(
child: Column(
children: <Widget>[
Expanded(
child: Container(),
),
Container(
height: screenHeight * 0.05,
margin: EdgeInsets.fromLTRB(
0,
0,
0,
screenHeight * 0.02,
),
alignment: Alignment.centerLeft,
child: TabBar(
indicator: CircleTabIndicator(
color: Color(0xFF7675E0),
radius: 4,
),
isScrollable: true,
labelColor: Color(0xFF7675E0),
unselectedLabelColor: Colors.grey,
physics: NeverScrollableScrollPhysics(),
tabs: <Widget>[
Align(
alignment: Alignment.centerLeft,
child: Text(
"Placess",
style: GoogleFonts.sniglet(),
),
),
Tab(
child: Text(
"Activities",
style: GoogleFonts.sniglet(),
),
),
Tab(
child: Text(
"Hotels",
style: GoogleFonts.sniglet(),
),
),
],
),
)
],
),
),
),
),
body: TabBarView(
children: <Widget>[
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
width: screenwidth * 0.18,
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(
0,
0,
0,
9,
),
child: ClipOval(
child: Material(
child: InkWell(
splashColor: Color(0xFF7675E0),
child: SizedBox(
width: screenwidth * 0.136253041,
height: screenHeight * 0.076607387,
child: Image(
image:
AssetImage('assets/1002.png'),
),
),
onTap: () {},
),
),
),
),
Text(
"Mountain",
style: GoogleFonts.sniglet(
color: Colors.black45,
),
),
],
),
),
Container(
width: screenwidth * 0.18,
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(
0,
0,
0,
9,
),
child: ClipOval(
child: Material(
child: InkWell(
splashColor: Color(0xFF7675E0),
child: SizedBox(
width: screenwidth * 0.136253041,
height: screenHeight * 0.076607387,
child: Image(
image:
AssetImage('assets/1017.png'),
),
),
onTap: () {},
),
),
),
),
Text(
"Beach",
style: GoogleFonts.sniglet(
color: Colors.black45,
),
),
],
),
),
Container(
width: screenwidth * 0.18,
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(
0,
0,
0,
9,
),
child: ClipOval(
child: Material(
child: InkWell(
splashColor: Color(0xFF7675E0),
child: SizedBox(
width: screenwidth * 0.136253041,
height: screenHeight * 0.076607387,
child: Image(
image:
AssetImage('assets/1013.png'),
),
),
onTap: () {},
),
),
),
),
Text(
"Location",
style: GoogleFonts.sniglet(
color: Colors.black45,
),
),
],
),
),
Container(
width: screenwidth * 0.18,
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(
0,
0,
0,
screenHeight * 0.012311902,
),
child: ClipOval(
child: Material(
child: InkWell(
splashColor: Color(0xFF7675E0),
child: SizedBox(
width: screenwidth * 0.136253041,
height: screenHeight * 0.076607387,
child: Image(
image:
AssetImage('assets/1002.png'),
),
),
onTap: () {},
),
),
),
),
Text(
"More",
style: GoogleFonts.sniglet(
color: Colors.black45,
),
),
],
),
),
],
),
),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
width: screenwidth * 0.18,
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(
0,
0,
0,
9,
),
child: ClipOval(
child: Material(
child: InkWell(
splashColor: Color(0xFF7675E0),
child: SizedBox(
width: screenwidth * 0.136253041,
height: screenHeight * 0.076607387,
child: Image(
image:
AssetImage('assets/1004.png'),
),
),
onTap: () {},
),
),
),
),
Text(
"Mountain",
style: GoogleFonts.sniglet(
color: Colors.black45,
),
),
],
),
),
Container(
width: screenwidth * 0.18,
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(
0,
0,
0,
9,
),
child: ClipOval(
child: Material(
child: InkWell(
splashColor: Color(0xFF7675E0),
child: SizedBox(
width: screenwidth * 0.136253041,
height: screenHeight * 0.076607387,
child: Image(
image:
AssetImage('assets/1013.png'),
),
),
onTap: () {},
),
),
),
),
Text(
"Beach",
style: GoogleFonts.sniglet(
color: Colors.black45,
),
),
],
),
),
Container(
width: screenwidth * 0.18,
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(
0,
0,
0,
9,
),
child: ClipOval(
child: Material(
child: InkWell(
splashColor: Color(0xFF7675E0),
child: SizedBox(
width: screenwidth * 0.136253041,
height: screenHeight * 0.076607387,
child: Image(
image:
AssetImage('assets/1017.png'),
),
),
onTap: () {},
),
),
),
),
Text(
"Location",
style: GoogleFonts.sniglet(
color: Colors.black45,
),
),
],
),
),
Container(
width: screenwidth * 0.18,
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(
0,
0,
0,
9,
),
child: ClipOval(
child: Material(
child: InkWell(
splashColor: Color(0xFF7675E0),
child: SizedBox(
width: screenwidth * 0.136253041,
height: screenHeight * 0.076607387,
child: Image(
image:
AssetImage('assets/1004.png'),
),
),
onTap: () {},
),
),
),
),
Text(
"More",
style: GoogleFonts.sniglet(
color: Colors.black45,
),
),
],
),
),
],
),
),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
width: screenwidth * 0.18,
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(
0,
0,
0,
9,
),
child: ClipOval(
child: Material(
child: InkWell(
splashColor: Color(0xFF7675E0),
child: SizedBox(
width: screenwidth * 0.136253041,
height: screenHeight * 0.076607387,
child: Image(
image:
AssetImage('assets/1002.png'),
),
),
onTap: () {},
),
),
),
),
Text(
"Mountain",
style: GoogleFonts.sniglet(
color: Colors.black45,
),
),
],
),
),
Container(
width: screenwidth * 0.18,
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(
0,
0,
0,
9,
),
child: ClipOval(
child: Material(
child: InkWell(
splashColor: Color(0xFF7675E0),
child: SizedBox(
width: screenwidth * 0.136253041,
height: screenHeight * 0.076607387,
child: Image(
image:
AssetImage('assets/1013.png'),
),
),
onTap: () {},
),
),
),
),
Text(
"Beach",
style: GoogleFonts.sniglet(
color: Colors.black45,
),
),
],
),
),
Container(
width: screenwidth * 0.18,
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(
0,
0,
0,
9,
),
child: ClipOval(
child: Material(
child: InkWell(
splashColor: Color(0xFF7675E0),
child: SizedBox(
width: screenwidth * 0.136253041,
height: screenHeight * 0.076607387,
child: Image(
image:
AssetImage('assets/1017.png'),
),
),
onTap: () {},
),
),
),
),
Text(
"Location",
style: GoogleFonts.sniglet(
color: Colors.black45,
),
),
],
),
),
Container(
width: screenwidth * 0.18,
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(
0,
0,
0,
9,
),
child: ClipOval(
child: Material(
child: InkWell(
splashColor: Color(0xFF7675E0),
child: SizedBox(
width: screenwidth * 0.136253041,
height: screenHeight * 0.076607387,
child: Image(
image:
AssetImage('assets/1004.png'),
),
),
onTap: () {},
),
),
),
),
Text(
"More",
style: GoogleFonts.sniglet(
color: Colors.black45,
),
),
],
),
),
],
),
),
],
),
),
),
),
),
),
);
}
}
For the tabbar scrolling issue: you will need to set the NeverScrollableScrollPhysics() in TabBarView's physics property, and not in the TabBar's physics property.

using reusable Widget how can i pass state to that widget

in this widget there is call to setState but it gives me error because this is a global widget where i am just passing the required data i also want to pass the state so it can access the setState method how can i achieve that ??
Thanks in Advance....
Widget postWidget(Map<dynamic,dynamic> homeMap,index,context){
return Padding(
padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.02),
child: Card(
elevation: 4.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: Stack(children: <Widget>[
Column(crossAxisAlignment: CrossAxisAlignment.start, children: <
Widget>[
SizedBox(
height: 1,
),
commonProfileData(homeMap, index),
SizedBox(
height: height * 0.005,
),
homeMap['homeModelDataList'][index].description != ""
? Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).size.height * 0.008,
left: MediaQuery.of(context).size.height * 0.025,
right: MediaQuery.of(context).size.height * 0.025),
child: Text(
homeMap['homeModelDataList'][index].description,
textAlign: TextAlign.justify,
),
)
: SizedBox(
height: 0,
),
SizedBox(
height: height * 0.005,
),
homeMap['homeModelDataList'][index].photo != ""
? Container(
margin: EdgeInsets.only(
right: MediaQuery.of(context).size.height * 0.02,
left: MediaQuery.of(context).size.height * 0.02),
child: Container(
clipBehavior: Clip.antiAlias,
height: MediaQuery.of(context).size.height * 0.25,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.red,
),
child: Image.network(
homeMap['homeModelDataList'][index].photo,
fit: BoxFit.fill),
),
)
: SizedBox(
height: 0,
),
//////////////////////////// ICON BUTTON //////////////////////////////////
commonButtons(homeMap, index),
openCommentBox &&
postId ==
homeMap['homeModelDataList'][index].postId.toString()
? Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(children: <Widget>[
Container(
margin: EdgeInsets.only(
left:
MediaQuery.of(context).size.height * 0.015,
),
height: MediaQuery.of(context).size.height * 0.05,
width: MediaQuery.of(context).size.height * 0.25,
child: TextFormField(
minLines: 1,
maxLines: 1,
controller: commentDataController,
focusNode: commentDescriptionFocus,
onFieldSubmitted: (value) {
commentDescriptionFocus.unfocus();
},
decoration: InputDecoration(
hintText: "Add Comment",
hintStyle: TextStyle(
color: isCommentDescriptionEmpty
? Colors.red
: Colors.grey),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(
MediaQuery.of(context).size.width *
0.03)),
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Colors.grey),
borderRadius: BorderRadius.circular(
MediaQuery.of(context).size.width *
0.03))),
),
),
Container(
clipBehavior: Clip.antiAlias,
width: MediaQuery.of(context).size.width * 0.3,
height: MediaQuery.of(context).size.width * 0.1,
margin: EdgeInsets.only(
right:
MediaQuery.of(context).size.height * 0.01,
left: MediaQuery.of(context).size.height *
0.01),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(10)),
child: RaisedButton(
child: Text("Add Comment",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 12.2)),
onPressed: () async {
if (commentDataController.text
.trim()
.length ==
0) {
isCommentDescriptionEmpty = true;
print("i am here");
} else {
isCommentDescriptionEmpty = false;
//progressDialog.show();
await sendCommentDataToServer(
commentDataController.text);
//progressDialog.hide();
(commentInfoMap["status"] == "Success")
? toast.showToastMessage(
message:
"Comment posted Successfully !")
: toast.showToastMessage(
message: "Comment post Failed !");
}
}),
)
]),
InkWell(
child: Padding(
padding: EdgeInsets.only(
top:
MediaQuery.of(context).size.height * 0.01,
left: MediaQuery.of(context).size.height *
0.018,
bottom: MediaQuery.of(context).size.height *
0.015,
),
child: RichText(
text: TextSpan(
style: TextStyle(
fontSize: 13, color: Colors.black),
children: [
TextSpan(
text: showPostCommentsBox
? "Hide "
: "Show ",
style: TextStyle(
color: Colors.blueAccent,
),
),
TextSpan(
text: "Comments",
style: TextStyle(color: Colors.black),
),
])),
),
onTap: () {
setState(() {
showPostCommentsBox = !showPostCommentsBox;
});
print(
"button pressed state : $showPostCommentsBox");
}),
],
),
)
: SizedBox(
height: 0,
),
showPostCommentsBox &&
postId ==
homeMap['homeModelDataList'][index].postId.toString()
? Container(
// color: Colors.red,
margin: EdgeInsets.only(
right: MediaQuery.of(context).size.height * 0.01,
left: MediaQuery.of(context).size.height * 0.01),
height: height * 0.15,
child: Column(
children: <Widget>[
Expanded(
child: ListView.builder(
physics: BouncingScrollPhysics(),
itemCount: listOfComment.length,
itemBuilder:
(BuildContext context, int position) {
return Padding(
padding: EdgeInsets.only(
right: height * 0.01,
left: height * 0.003,
),
child: Card(
color: Colors.grey[100],
child: ListTile(
title: Text(listOfComment[position][4]
.toString()),
trailing: Text("temp")),
),
);
}),
)
],
),
)
: Container(),
]
)
])),
);
}
in this widget there is call to setState but it gives me error because this is a global widget where i am just passing the required data i also want to pass the state so it can access the setState method how can i achieve that ??
Thanks in Advance....
okay for passing state you have to pass this to the global widget.
For example:
Calling from stateful class:
userDrawer(this);
This is global class:
userDrawer(var state){
return Container(
child: RaisedButton(
child: Text("Click"),
onPressed:(){
state.setState(() {
value = newValue;
}) }
)
pass a function which executes when the button is pressed
userDrawer((){setState(){});
in the global class
userDrawer(Function onPressed){
return FlatButton(onPressed: onPressed, child: Text('Click'));
}
or if you want set a value
userDrawer(Function onPressed){
return FlatButton(onPressed: (){
value = newValue;
onPressed();
}, child: Text('Click'));
}

Can i add radius button in singlechild scroll view?

I am using Stack widget in which I have 2 widgets one is just an image and the other is Singlechildscrollview.
I need to add a button on the footer of the screen and fix this (not moveable). Need to be fixed on screen when the Singlechildscrollview scroll or not I need to fix this button. I am not sure how can I do this because if I out the button in Singlechildscrollview then it will show only when I scroll. I need to fix when I scroll or not button should appear.
Here is my code:
Stack(
children: <Widget>[
Container(
padding: EdgeInsets.only(top: statusBarHeight * 0.8),
height: height * 0.4,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/place2.jpg',
),
fit: BoxFit.fill,
),
),
),
SingleChildScrollView(
child: Padding(
padding: EdgeInsets.only(top: height * 0.3),
child: SingleChildScrollView(
child: ClipRRect(
borderRadius: BorderRadius.only(
topRight: Radius.circular(30),
topLeft: Radius.circular(30)),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: height * 0.05,
),
Container(
width: width,
margin: EdgeInsets.only(left: width * 0.03),
child: Text(
'NYC Food Festival',
textAlign: TextAlign.left,
style: TextStyle(fontSize: 30),
),
),
SizedBox(
height: height * 0.02,
),
Container(
margin: EdgeInsets.only(left: width * 0.03),
child: Row(
children: <Widget>[
Icon(
Icons.calendar_today,
size: 20,
color: Color(0xff808080),
),
SizedBox(width: width * 0.02), // give it width
Column(
children: <Widget>[
Text(
'Sat, May 25, 2020',
style: TextStyle(
color: Color(0xff000000),
fontWeight: FontWeight.bold,
fontSize: 15),
),
],
)
],
),
),
SizedBox(
height: height * 0.02,
),
Container(
margin: EdgeInsets.only(left: width * 0.03),
child: Row(
children: <Widget>[
Icon(
Icons.attach_money,
size: 20,
color: Color(0xff808080),
),
SizedBox(width: width * 0.02), // give it width
Column(
children: <Widget>[
Text(
'25,000 PKR',
style: TextStyle(
color: Color(0xff000000),
fontWeight: FontWeight.bold,
fontSize: 15),
),
],
)
],
),
),
SizedBox(
height: height * 0.02,
),
SizedBox(
height: height * 0.02,
),
Container(
width: width,
margin: EdgeInsets.only(left: width * 0.03),
child: Text(
'Snaps',
textAlign: TextAlign.left,
style: TextStyle(fontSize: 25),
),
),
SizedBox(
height: height * 0.02,
),
Container(
child: Column(
children: <Widget>[
CarouselSlider(
options: CarouselOptions(
autoPlay: true,
aspectRatio: 2.0,
enlargeCenterPage: true,
),
items: imageSliders,
),
],
)),
SizedBox(
height: height * 0.02,
),
Container(
width: width,
margin: EdgeInsets.only(left: width * 0.03),
child: Text(
'About',
textAlign: TextAlign.left,
style: TextStyle(fontSize: 25),
),
),
SizedBox(
height: height * 0.02,
),
Container(
padding: EdgeInsets.only(
right: width * 0.03, left: width * 0.03),
child: DescriptionTextWidget(
text:
"Flutter is Google’s mobile UI framework for crafting high-quality native interfaces on iOS and Android in record time. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source.")
),
SizedBox(
height: height * 0.02,
),
Container(
width: width,
margin: EdgeInsets.only(left: width * 0.03),
child: Text(
'Included',
textAlign: TextAlign.left,
style: TextStyle(fontSize: 25),
),
),
SizedBox(
height: height * 0.02,
),
Included(),
SizedBox(
height: height * 0.01,
),
Included(),
SizedBox(
height: height * 0.01,
),
Included(),
SizedBox(
height: height * 0.01,
),
],
),
),
),
),
),
)
],
)
Here is the output of current view:
This is what I want:
You can achieve this look with relative ease.
Here is an example:
class BottomFadeButton extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
title: Text("Bottom Fade Button"),
),
body: Container(
// height: 500,
color: Colors.amberAccent,
child: Stack(
children: <Widget>[
Container(
child: ListView.builder(
itemCount: 100,
itemBuilder: (context, index) {
return ListTile(
title: Text("Hello "),
);
}),
),
// Bottom Button
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Container(
height: 100,
decoration: BoxDecoration(
// color: Color.fromARGB(110, 255, 255, 255),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
gradient: LinearGradient(
colors: [
Color.fromARGB(30, 255, 255, 255),
Color.fromARGB(255, 255, 255, 255),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: Center(
child: InkWell(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 100,
vertical: 20,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Colors.blueAccent,
),
child: Text(
"BUY TICKETS",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.white),
),
),
onTap: () {
return print("Tap");
},
),
),
),
),
],
),
),
),
);
}
}
Output:
yes you can add the button in stack and then wrap with align widget with alignment.bottom_center