how to show ListView.builder items in expansion tile - flutter

I am trying to show the list of items using ListView.builder in ```expansion tile, but it is not showing anything, nor giving any error.
here is the code of expansion tile
customExpansionTile(context, "Additional discount", true,
Icon(Icons.add_task, color: HexColor("#5344ed")), <Widget>[
Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: MediaQuery.of(context).size.width * 0.9,
child: Row(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.022,
),
textformfieldCustomwithouticon(
context,
TextInputType.number,
MediaQuery.of(context).size.width * 0.4,
quantity,
"Enter the quantity",
"Quantity ",
55.0),
SizedBox(
width: MediaQuery.of(context).size.width * 0.03,
),
textformfieldCustomwithouticon(
context,
TextInputType.number,
MediaQuery.of(context).size.width * 0.42,
discountPercentage,
"Enter the discount",
"Discount",
55.0),
],
),
),
SizedBox20(),
customButton(context, "Add", () {},
MediaQuery.of(context).size.width * 0.85, 55.0),
SizedBox20(),
// here i'm using Listview.builder
Flexible(
fit: FlexFit.loose,
child: Container(
width:MediaQuery.of(context).size.width * 0.9,
height:MediaQuery.of(context).size.height*0.5,
child: ListView.builder(
itemCount: books.length,
itemBuilder: (context, index) {
final book = books[index];
return buildDiscount(book);
},
),
)),
],
),
SizedBox10()
]),
buildDiscount code:
Widget buildDiscount(Book book) => Card(
elevation: 0.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(10),
),
),
child: ListTile(
trailing: SizedBox(
height: 100,
child: Column(
children: [
InkWell(
onTap: () {
_getVariantRowInfo(book.id, book.id, book.id);
},
child: Icon(Icons.edit, color: HexColor("#7367f0")),
),
SizedBox(
height: 5,
),
InkWell(
onTap: () {},
child: Icon(Icons.delete, color: HexColor("#7367f0")),
),
],
),
),
title: Padding(
padding: const EdgeInsets.fromLTRB(0, 10, 15, 0),
child: Text(
" Quantity: 90",
style: GoogleFonts.montserrat(
fontSize: 15, fontWeight: FontWeight.bold,color: Colors.red),
),
),
horizontalTitleGap: 10,
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
" Discount %: " + "10%",
style: GoogleFonts.montserrat(fontSize: 15),
),
Text(
" Discounted Price: " + "90",
style: GoogleFonts.montserrat(fontSize: 15),
),
SizedBox(
height: 10,
)
],
),
));
output
please help, where i'm doing wrong.
customExpansionTile
Widget customExpansionTile(context, text,initiallyExpanded,leading,childern) {
return GestureDetector(
child: Container(
width:MediaQuery.of(context).size.width*0.9,
// height: 400,
decoration: BoxDecoration(
border: Border.all(color: HexColor("#6e6b7b")),
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(10),
),
),
child: ExpansionTile(
title: Text(
text,
style: GoogleFonts.montserrat(
fontSize: 18.0,
fontWeight: FontWeight.bold,
color: HexColor("#5344ed")),
),
initiallyExpanded:initiallyExpanded,
leading:leading,
children: childern,
),
),
);
}

if you use Container with width and height u needn't Flexible widget like Expanded and Flexible at parent, remove Flexible, also you can add shrinkWrap: true to ListView.builder
Flexible( /// <--- remove this parent or remove Container if you get flexible ListView.builder
fit: FlexFit.loose,
child: Container(
width:MediaQuery.of(context).size.width * 0.9,
height:MediaQuery.of(context).size.height*0.5,
child: ListView.builder(
itemCount: books.length,
itemBuilder: (context, index) {
final book = books[index];
return buildDiscount(book);
},
),
)),
or
Try to use Expanded something like
Expanded:
child customExpansionTile(context, "Additional discount", true,
Icon(Icons.add_task, color: HexColor("#5344ed")), [
Expanded: child:
Column(
mainAxisSize: MainAxisSize.min,
.....

Related

How to avoid overlap in widget inside GridView?

The widget inside the gridView overlap each other , the bottom portion of the widget is overlapped by another widget , How to avoid overlap in widget inside GridView?I want to avoid the overlap amoung the widget.
Here is my codes
It contain a gridview builder containing the widget, the widget is made by stack , position.fill
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables
import 'package:flutter/material.dart';
import 'package:iconsax/iconsax.dart';
class WorkshopsCloseToYouPage extends StatelessWidget {
const WorkshopsCloseToYouPage({super.key});
#override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: GridView.builder(
itemCount: 6,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, crossAxisSpacing: 4.0, mainAxisSpacing: 4.0),
itemBuilder: (BuildContext context, int index) {
return workshopCard();
},
),
),
);
}
Stack workshopCard() {
return Stack(
clipBehavior: Clip.none,
children: [
Container(
width: 200,
height: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
image: DecorationImage(
image: AssetImage('assets/workshop_image.png'),
fit: BoxFit.cover,
),
),
),
Positioned.fill(
bottom: -100,
child: Align(
alignment: Alignment.bottomCenter,
child: Card(
margin: const EdgeInsets.all(5),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Pottery Throwing Taster Class",
style: TextStyle(fontWeight: FontWeight.bold),
),
SizedBox(
height: 5,
),
Row(
children: [
SizedBox(
width: 100,
child: Column(
children: [
Row(
children: [
Icon(
Iconsax.location5,
size: 16,
color: Color(0xFF083AA9),
),
SizedBox(
width: 2,
),
Text(
"Honslow",
// style: TextStyle(fontSize: 8),
)
],
),
SizedBox(
height: 5,
),
Row(
children: [
Icon(
Iconsax.profile_2user,
size: 16,
color: Color(0xFF083AA9),
),
SizedBox(
width: 2,
),
Text("1 to 15")
],
),
SizedBox(
height: 5,
),
Row(
children: [
Icon(
Iconsax.tag_right,
size: 16,
color: Color(0xFF083AA9),
),
SizedBox(
width: 2,
),
Text("1 to 15")
],
),
SizedBox(
height: 5,
),
Row(
children: [
Icon(
Iconsax.star,
size: 16,
color: Color(0xFF083AA9),
),
SizedBox(
width: 2,
),
Text("5(37)")
],
),
],
),
),
ElevatedButton(
onPressed: () {},
style: TextButton.styleFrom(
minimumSize: const Size(70, 35),
maximumSize: const Size(70, 35),
backgroundColor: Color(0xFF0c3cac),
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20))),
child: Row(
children: [
Padding(
padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
child: Text(
"Join",
style: TextStyle(
color: Colors.white,
fontSize: 12,
),
),
),
Icon(size: 5, Icons.arrow_forward_ios),
Icon(
color: Color.fromARGB(255, 231, 227, 227),
size: 5,
Icons.arrow_forward_ios),
Icon(
color: Color.fromARGB(255, 181, 180, 180),
size: 5,
Icons.arrow_forward_ios),
],
)),
],
),
],
),
)),
),
)
],
);
}
}
Output page showing the widget overlap

Row not showing in listtile

I am trying to make a listview for a forum page but for the row under trailing and under the row where forumdata.getnop and the other data cannot be displayed under the list tile how do I fix this? there is no error with the class as removing the sized box with height 19 will just make it have an overflow error.
image of current app : -
Code : -
Container(
margin: const EdgeInsets.symmetric(vertical: 20.0),
height: 900.0,
child: ListView.separated(
physics: NeverScrollableScrollPhysics(),
itemCount: forumdata.getfLength(),
separatorBuilder: (BuildContext context, int index) =>
const Divider(),
itemBuilder: (BuildContext context, int index) {
return ListTile(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => ThreadPageScreen(
index: index,
)),
);
},
visualDensity: VisualDensity(vertical: 4),
leading: CircleAvatar(
backgroundColor:
Color(forumdata.getfcolor(index)),
child: Icon(
forumdata.getIcon(index),
color: Color(forumdata.geticolor(index)),
),
),
trailing: SizedBox(
width: 300,
height: 300,
child: Padding(
padding:
EdgeInsets.only(left: 20),
child: Column(
children: [
Container(
child: Align(
alignment: Alignment.centerLeft,
child: Text(
forumdata.getTitle(index),
maxLines: 1,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15,
color: Colors.blue),
),
),
),
Container(
child: Align(
alignment: Alignment.centerLeft,
child: Text(
forumdata.getDesc(index),
maxLines: 2,
),
),
),
Padding(
padding: EdgeInsets.only(left: 20),
child: SizedBox(
width: 300,
height: 19,
child: Row(
children: [
Container(
child: Padding(
padding:
EdgeInsets.only(
bottom: 20),
child: Row(
children: [
Text(
forumdata
.getnop(
index)
.toString() +
" posts " +
" ",
style:
TextStyle(
color: Colors
.grey,
fontSize: 3,
),
),
CircleAvatar(
child: Image
.network(
userdata.getProfileIcon(
forumdata
.getuser(index)),
),
),
Text(
" " +
forumdata
.getDateTime(
index),
style:
TextStyle(
color: Colors
.grey,
),
),
],
),
),
),
],
),
),
),
],
),
),
),
);
On a quick view, From this section of code:
SizedBox(
width: 300,
height: 19,
child: Row(children: [
Container(
child:
Padding(padding: EdgeInsets.only(bottom: 20),
child: Row(
Height of the SizedBox is 19 and the padding above second Row is 20. Thus the bottom padding completely hide the row.
trailing: SizedBox(
width: 300,
height: 300,
child: Padding(
/// replace with this
title: SizedBox(
width: MediaQuery.of(context).size.width,
child: Padding(

Google Map behaving Weird in Scrollable Widget (inside ListView.builder)

I need to show Google Map in ListView.builder. in Ios its behaving weird. the App Header and Bottom App Bar got scrolled with White Space. GoogleMap get freeze as well.
SingleChildScrollView(
child: Container(
margin: EdgeInsets.all(10.0),
child: ListView.separated(
itemCount: state.products.length,
separatorBuilder:
(BuildContext context, int index) => SizedBox(
height: 10,
),
physics: NeverScrollableScrollPhysics(),
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemBuilder: (context, position) {
return PharmaciesItemWidget(
pharmacies: state.products[position],
remove: true,
removeBottom: true,
onTap: () {
BlocProvider.of<PharmaciesCubit>(context)
.deletePharmacy(
state.products[position].uuid);
},
);
// return Text("$position");
},
),
),
)
/// List Item Class
class PharmaciesItemWidget extends StatefulWidget {
final PharmaciesData pharmacies;
final VoidCallback onTap;
final bool remove;
final bool removeBottom;
const PharmaciesItemWidget({
Key key,
#required this.pharmacies,
this.onTap,
this.remove = false,
this.removeBottom = false,
}) : super(key: key);
#override
_PharmaciesItemWidgetWidgetState createState() =>
_PharmaciesItemWidgetWidgetState();
}
class _PharmaciesItemWidgetWidgetState extends State<PharmaciesItemWidget> {
#override
Widget build(BuildContext context) {
return
// Card(
// clipBehavior: Clip.antiAliasWithSaveLayer,
// elevation: 2,
// margin: EdgeInsets.all(10.0),
// shape: RoundedRectangleBorder(
// // side: BorderSide(color: AppColor.primaryColor, width: 2),
// borderRadius: BorderRadius.circular(15),
// ),
ClipRRect(
clipBehavior: Clip.antiAliasWithSaveLayer,
// elevation: 2,
// margin: EdgeInsets.all(10.0),
borderRadius: BorderRadius.all(Radius.circular(10)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
color: AppColor.primaryColor,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
flex: 1,
child: SvgPicture.asset(
AppImages.pharmacies,
color: AppColor.backgroundWhite,
width: 40,
height: 40,
),
),
SizedBox(
width: 5,
),
Expanded(
flex: 5,
child: Text(
widget.pharmacies.name ?? "",
// overflow: TextOverflow.fade,
maxLines: 2,
// softWrap: false,
style: GoogleFonts.comfortaa(
color: Colors.white, fontSize: 18),
),
),
Spacer(),
Expanded(
flex: 1,
child: GestureDetector(
onTap: () {
widget.onTap();
},
child: widget.remove
? Icon(
Icons.remove_circle_outline,
color: AppColor.backgroundWhite,
size: 40,
)
: SvgPicture.asset(
AppImages.right_arrow_circle,
color: AppColor.backgroundWhite,
width: 40,
height: 40,
),
),
),
],
),
),
),
Container(
height: 5,
color: AppColor.secondaryColor,
),
Container(
padding: EdgeInsets.all(5.0),
color: AppColor.primaryBackground,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 5,
height: 5,
),
Text(widget.pharmacies.addressLine1 ?? "",
style: GoogleFonts.comfortaa(
color: AppColor.primaryColor, fontSize: 14)),
Row(
children: [
Text(widget.pharmacies.city + ", ",
style: GoogleFonts.comfortaa(
color: AppColor.primaryColor,
fontSize: 14)),
Text(widget.pharmacies.stateCode + " ",
style: GoogleFonts.comfortaa(
color: AppColor.primaryColor,
fontSize: 14)),
Text(widget.pharmacies.zip,
style: GoogleFonts.comfortaa(
color: AppColor.primaryColor,
fontSize: 14)),
],
),
SizedBox(
width: 5,
height: 5,
),
// widget.pharmacies.telecom !=null ? GestureDetector(
// onTap: () => dialNo(widget.pharmacies.telecom),
// child: Row(
// children: [
// Text(
// widget.pharmacies.telecom,
//
// style: TextStyle(fontSize: 16,color: AppColor.primaryColor,),
// ),
//
// SvgPicture.asset(
// AppImages.call_text,
// height: 20,
// color: AppColor.primaryColor,
// ),
// ],
// ),
// ) : SizedBox(),
phoneNoWidget(
widget.pharmacies.telecom,
AppColor.primaryColor,
),
enableMessageDebugging
? Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"UUID:",
textAlign: TextAlign.end,
style: TextStyle(
color: AppColor.primaryColor,
fontSize: 16),
),
SizedBox(
width: 10,
),
Text(
widget.pharmacies.uuid,
style: TextStyle(fontSize: 16),
)
],
)
: SizedBox(),
widget.removeBottom
? SizedBox(
height: 0,
)
: Column(
children: [
SizedBox(
height: 5,
),
Container(
height: 5,
color: AppColor.primaryColor,
),
SizedBox(
height: 5,
),
Padding(
padding: const EdgeInsets.all(5.0),
child: Row(
children: [
Text(
widget.pharmacies.distanceInMiles
.toStringAsFixed(1) +
" Miles Away",
style: GoogleFonts.comfortaa(
fontSize: 18,
color: AppColor.secondaryColor),
),
Spacer(),
// Text(
// Strings.delivery_partner,
// style: GoogleFonts.comfortaa(fontSize: 18),
// )
Image.asset(
AppImages.lyft_logo,
width: 25,
height: 17,
alignment: Alignment.bottomRight,
)
],
),
)
],
)
],
),
),
Container(
height: 5,
color: AppColor.primaryColor,
),
Container(
// decoration: BoxDecoration(
// image: DecorationImage(
// image: AssetImage(AppImages.map), fit: BoxFit.cover),
// ),
height: MediaQuery.of(context).size.height / 4,
width: MediaQuery.of(context).size.width,
child: SafeArea(
child: Container(
color: Colors.blueGrey.withOpacity(.8),
child: Center(
child: Column(
children: [
Container(
height: MediaQuery.of(context).size.height / 4,
width: MediaQuery.of(context).size.width,
child: GoogleMap(
initialCameraPosition: CameraPosition(target: LatLng(widget.pharmacies.latitude,widget.pharmacies.longitude), zoom: 15),
markers: <Marker>{
Marker(
markerId: MarkerId("location"),
position: LatLng(
widget.pharmacies.latitude,
widget.pharmacies.longitude,
),
infoWindow: InfoWindow(
title: "location",
snippet: '*',
),
),
},
mapType: MapType.normal,
// onMapCreated: _onMapCreated,
myLocationButtonEnabled: false,
),
) ,
],
),
),
),
),
),
Container(
height: 5,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(10.0),
bottomRight: Radius.circular(10.0),
),
color: AppColor.primaryColor,
),
)
],
),
],
));
}
}
these are the some pictures of the issues
above is the ss of actual screen, adding ss for issues when we scroll it
I get to know today. Using Clip.antiAliasWithSaveLayer is costly.
There are enum property which define what it cost.
After investing many days i got to know antiAliasWithSaveLayer is very expensive to use.
hardEdge, which is the fastest clipping, but with lower fidelity.
antiAlias, which is a little slower than hardEdge, but with smoothed edges.
antiAliasWithSaveLayer, which is much slower than antiAlias, and should rarely be used.
Visit here for more information

Display list of datas from sharedprefrence to text widget flutter?

I am saving some list of data to Sharedprefrence and tried to call the data from saved sharedprefrence and it returs all the values i have saved,then i tried to show data from sharedprefrence to a text widget but it shows null,
i need something like,if i have t text widgets how do pass data to those two widget let's say ₹575 and TWA Cap
Retrieving the data from sharedprfrence
List<String> listdata=[];
void initState() {
super.initState();
SharedPrefrence().getCartItem().then((data) async{
listdata = data;
print(listdata);
});
}
this what i am geting from the sharedprefrence
[TWA Cap, ₹575, M, Red]
trying to shows te data to text widget (Whole widget)
Widget CoupensLists() {
return SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
child: Container(
child: ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: 1,
itemBuilder: (BuildContext context, int index) {
return Row(
children: <Widget>[
Expanded(
child: Card(
elevation: 10,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: GestureDetector(
onTap: () {
},
child: Container(
height: 150,
width: 350,
child: Row(
children: <Widget>[
Column(
children: <Widget>[
Padding(
padding:
const EdgeInsets.symmetric(vertical: 5),
child: Container(
height: 50,
width: 80,
child: Image.network("image"),
/* decoration: BoxDecoration(
image: DecorationImage(
image: Image.,
fit: BoxFit.fill,
),
),*/
),
),
SizedBox(
height: 5,
),
Text(
"Prodcut name",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold),
),
Text("Prodcut name",
style: TextStyle(fontSize: 12)),
SizedBox(
height: 10,
),
Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(
vertical: 4),
child: Container(
width: 80,
child: Stack(
children: <Widget>[
SvgPicture.asset(
'assets/images/bg_price_btn_black.svg',
),
Padding(
padding: const EdgeInsets.all(5),
child: Text(
"Price"
style: TextStyle(
color: Colors.white,
fontSize: 12),
),
)
],
),
),
),
Stack(
children: <Widget>[
SvgPicture.asset(
'assets/images/bg_boon_btn_red.svg',
),
Padding(
padding: const EdgeInsets.all(5),
child: Text(
"Book Now",
style: TextStyle(
color: Colors.white,
fontSize: 12),
),
)
],
),
],
),
],
),
],
),
),
),
),
),
],
);
},
),
),
);
}
Try this:
List<String> listdata=[];
void initState() {
super.initState();
SharedPrefrence().getCartItem().then((data) async{
setState(() {
listdata = data;
});
});
}
You're getting this because you didn't upated your screen after changing the listdata variable
use in initail function
setState(() {
listdata = data;
});
then
Widget CoupensLists() {
return SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
child: Container(
child: ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: 1,
itemBuilder: (BuildContext context, int index) {
return Row(
children: <Widget>[
Expanded(
child: Card(
elevation: 10,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: GestureDetector(
onTap: () {
},
child: Container(
height: 150,
width: 350,
child: Row(
children: <Widget>[
Column(
children: <Widget>[
Padding(
padding:
const EdgeInsets.symmetric(vertical: 5),
child: Container(
height: 50,
width: 80,
child: Image.network("image"),
/* decoration: BoxDecoration(
image: DecorationImage(
image: Image.,
fit: BoxFit.fill,
),
),*/
),
),
SizedBox(
height: 5,
),
Text(
listdata.length!=0? listdata[0]:"",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold),
),
Text( listdata.length!=0? listdata[1]:"",
style: TextStyle(fontSize: 12)),
SizedBox(
height: 10,
),
Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(
vertical: 4),
child: Container(
width: 80,
child: Stack(
children: <Widget>[
SvgPicture.asset(
'assets/images/bg_price_btn_black.svg',
),
Padding(
padding: const EdgeInsets.all(5),
child: Text(
listdata.length!=0? listdata[2]:"",
style: TextStyle(
color: Colors.white,
fontSize: 12),
),
)
],
),
),
),
Stack(
children: <Widget>[
SvgPicture.asset(
'assets/images/bg_boon_btn_red.svg',
),
Padding(
padding: const EdgeInsets.all(5),
child: Text(
listdata.length!=0? listdata[3]:"",
style: TextStyle(
color: Colors.white,
fontSize: 12),
),
)
],
),
],
),
],
),
],
),
),
),
),
),
],
);
},
),``
),
);
}

How to ensure button is always pinned to bottom of slide up panel - Flutter

I have the following view.
I would like the "confirm" button to always appear at the bottom of the slide up panel no matter what device is being used. If I position at the bottom correctly using padding or empty containers it is cut off on smaller screen size. Or if I position correctly on a smaller screen I am now running into issues with white space at the bottom. I am using the safe area widget which I thought ensured all widgets stay within the SafeArea?
Here is my code so far:
class ChooseAppointmentView extends StatefulWidget {
#override
_ChooseAppointmentViewState createState() => _ChooseAppointmentViewState();
}
class _ChooseAppointmentViewState extends State<ChooseAppointmentView> {
final List<Appointment> appointmentList = [
Appointment("Monday", DateTime.now(), DateTime.now(), "AM"),
Appointment("Tuesday", DateTime.now(), DateTime.now(), "AM"),
Appointment("Wednesday", DateTime.now(), DateTime.now(), "PM"),
Appointment("Thursday", DateTime.now(), DateTime.now(), "AM"),
Appointment("Friday", DateTime.now(), DateTime.now(), "PM"),
];
DateTime _dateSelected = DateTime.now();
DateTime _initialiseDate = DateTime.now();
#override
Widget build(BuildContext context) {
BorderRadiusGeometry radius = BorderRadius.only(
topLeft: Radius.circular(24.0),
topRight: Radius.circular(24.0),
);
return BaseView<ConfirmDetailsViewModel>(
builder: (context, model, child) => Scaffold(
backgroundColor: AppColours.primaryColour,
body: SafeArea(
child: WillPopScope(
onWillPop: () async {
return false;
},
child: SlidingUpPanel(
maxHeight: MediaQuery.of(context).size.height * .80,
minHeight: 75.0,
parallaxEnabled: true,
parallaxOffset: .5,
panel: Stack(
children: <Widget>[
Center(
child: Column(
children: <Widget>[
Container(
height: MediaQuery.of(context).size.height * 0.02),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: 30,
height: 5,
decoration: BoxDecoration(
color: Colors.grey[300],
borderRadius:
BorderRadius.all(Radius.circular(12.0))),
),
],
),
Container(
height: MediaQuery.of(context).size.height * 0.02),
Container(
child: Text(
"Select a date in here.",
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 24.0,
),
),
),
Container(
height: MediaQuery.of(context).size.height * 0.05),
Container(
height: 200,
child: CupertinoDatePicker(
mode: CupertinoDatePickerMode.date,
minimumDate: _initialiseDate,
maximumDate: _initialiseDate.add(Duration(days: 7)),
initialDateTime: _initialiseDate,
onDateTimeChanged: (dateSelected) {
setState(() {
_dateSelected = dateSelected;
});
},
),
),
Container(
height: MediaQuery.of(context).size.height * 0.05),
Container(
height: 50.0,
width: MediaQuery.of(context).size.width - 50,
child: RaisedButton(
onPressed: () async {
//await model.submit();
Navigator.push(
context,
SizeRoute(
page: ChooseAppointmentView(),
),
);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25.0),
),
child: Text('Confirm'),
color: AppColours.primaryLightColour,
textColor: Colors.white,
padding: EdgeInsets.fromLTRB(9, 9, 9, 9),
),
),
],
),
),
],
),
collapsed: Center(
child: Column(
children: <Widget>[
Container(
height: MediaQuery.of(context).size.height * 0.02),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: 30,
height: 5,
decoration: BoxDecoration(
color: Colors.grey[300],
borderRadius:
BorderRadius.all(Radius.circular(12.0))),
),
],
),
Container(
height: MediaQuery.of(context).size.height * 0.02),
Container(
decoration: BoxDecoration(
color: Colors.white, borderRadius: radius),
child: Center(
child: Text(
"Select a different date",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
fontSize: 20.0,
),
),
),
),
],
),
),
body: Container(
decoration: BoxDecoration(color: Colors.white),
child: ListView.builder(
padding: EdgeInsets.only(bottom: 100.0),
itemCount: appointmentList.length,
itemBuilder: (BuildContext context, int index) =>
buildAppointmentCards(context, index),
),
),
borderRadius: radius,
),
),
),
),
);
}
Widget buildAppointmentCards(BuildContext context, int index) {
final appointment = appointmentList[index];
return Padding(
padding: const EdgeInsets.all(10.0),
child: Material(
color: Colors.white.withOpacity(0.0),
child: InkWell(
splashColor: Colors.red,
onTap: () {
print('card tapped');
},
child: new Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset: Offset(0, 3), // changes position of shadow
),
],
gradient: LinearGradient(
colors: [
AppColours.primaryColour,
AppColours.primaryLightColour,
AppColours.primaryLighterColour,
//add more colors for gradient
],
begin: Alignment.topLeft, //begin of the gradient color
end: Alignment.bottomRight, //end of the gradient color
stops: [0, 0.2, 0.5] //stops for individual color
//set the stops number equal to numbers of color
),
borderRadius: BorderRadius.circular(10),
),
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Container(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 4.0, bottom: 4.0),
child: Row(
children: <Widget>[
Text(
appointment.day,
style:
TextStyle(fontSize: 30.0, color: Colors.white),
),
Spacer(),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 4.0, bottom: 80.0),
child: Row(
children: <Widget>[
Text(
"${DateFormat('hh:mm').format(appointment.date).toString()} - ${DateFormat('hh:mm').format(appointment.date).toString()}",
style:
TextStyle(fontSize: 20.0, color: Colors.white),
),
Spacer(),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
child: Row(
children: <Widget>[
Text(
DateFormat(
'dd/MM/yyyy',
).format(appointment.date).toString(),
style:
TextStyle(fontSize: 20.0, color: Colors.white),
),
Spacer(),
Text(
appointment.ampm,
style:
TextStyle(fontSize: 20.0, color: Colors.white),
),
],
),
)
],
),
),
),
),
),
),
);
}
}
[enter link description here][2]
I think you can use the Align widget for positioning your widget in Stack. For more information can see in this link in this link you will see examples including explanation in the video.