How to marge two list tile in flutter? - flutter

I am facing this issue while reading data from my real time data base but. I am storing the check in time in a list and check out time in another list but while scrolling i want to scroll them together to see the particular check in and check out time beside each other.
here is my code
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
// ignore: prefer_const_literals_to_create_immutables
children: [
SizedBox(
height: 40,
),
Text(
// textAlign: TextAlign.center,
"Check In Time",
style: GoogleFonts.ubuntu(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.white70,
),
),
Expanded(
child: FirebaseAnimatedList(
query: ref,
itemBuilder:
(context, snapshot, animation, index) {
return ListTile(
leading: const Icon(Icons.flutter_dash_sharp),
title: Text(
textAlign: TextAlign.center,
snapshot.child('time').value.toString(),
style: GoogleFonts.ubuntu(
fontSize: 16,
color: Colors.white,
),
),
);
},
),
),
],
),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
// ignore: prefer_const_literals_to_create_immutables
children: [
// ignore: prefer_const_constructors
SizedBox(
height: 40,
),
Text(
"Check Out Time",
style: GoogleFonts.ubuntu(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.white70,
),
),
Expanded(
child: FirebaseAnimatedList(
query: ref2,
itemBuilder:
(context, snapshot, animation, index) {
return ListTile(
title: Text(
textAlign: TextAlign.center,
snapshot.child('time').value.toString(),
style: GoogleFonts.ubuntu(
fontSize: 16,
color: Colors.white,
),
),
);
},
),
),
],
),
)
],
),
),
),
please help me to marge this animated list together.
I have tried to marge the list tile and animated list both separately but did't work. Is there any problem related with real time database as i am storing the check in and check out in separate list in the database.

Related

how to Differentiate Expansion Title title from the rest dropdown content, I want title to have different background color than the dropdown content

I attached the Images in this post. to gives you detail information of what I want to achieve??? I Trying to achieve like the image below.
Is it possible to add a shadow to title to make it above the dropdown Content????
I am try to make the dropdown content is looks below the Title how I can achieve that??? if there is any way to make the title look above the dropdown content it have please help me??
body: ListView.builder(
itemCount: Family.length,
itemBuilder: (context, index) {
return ExpansionTile(
backgroundColor: Colors.blueGrey,
collapsedBackgroundColor: Colors.red,
title: Text(
"HEADER HERE",
style: TextStyle(
//color: isExpanded ? Colors.pink : Colors.teal,
),
),
children: <Widget>[
ListTile(
// color: HexColor("FFF1CC93"),
title: Row(
children: <Widget>[
Container(
width: 50,
height: 50,
child: Image.asset(imageList[index]),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
Family[index],
style: TextStyle(
fontSize: 18,
color: Colors.teal.shade900,
fontWeight: FontWeight.bold,
),
),
SizedBox(
height: 10,
),
Container(
width: width,
child: Text(
Family[index],
style: TextStyle(
fontSize: 13,
color: Colors.grey[500],
),
),
),
],
),
)
],
)),
],
);
}),
please test this below code, i think you should use Theme on parent of ExpansionTile widget
body: ListView.builder(
itemCount: Family.length,
itemBuilder: (context, index) {
return Theme(
data: Theme.of(context).copyWith(cardColor: Colors.red),
child: ExpansionTile(
backgroundColor: Colors.blueGrey,
collapsedBackgroundColor: Colors.red,
title: Text(
"HEADER HERE",
style: TextStyle(
//color: isExpanded ? Colors.pink : Colors.teal,
),
),
children: <Widget>[
ListTile(
// color: HexColor("FFF1CC93"),
title: Row(
children: <Widget>[
Container(
width: 50,
height: 50,
child: Image.asset(imageList[index]),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
Family[index],
style: TextStyle(
fontSize: 18,
color: Colors.teal.shade900,
fontWeight: FontWeight.bold,
),
),
SizedBox(
height: 10,
),
Container(
width: width,
child: Text(
Family[index],
style: TextStyle(
fontSize: 13,
color: Colors.grey[500],
),
),
),
],
),
)
],
)),
],
),
);
}),

How to create simple Listview with image Flutter

I was wondering how I could achieve something similar or close to this
image instead of using cards
any example code would be highly appreciated
Try this code
ListView.builder(
itemCount: 2,
itemBuilder: (BuildContext context, int index) {
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Row(
children: <Widget>[
SizedBox(width: 10.0),
Image.asset(
'Your Asset',
height: 100,
),
SizedBox(width: 20.0),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
'Title Here',
style: TextStyle(
color: Colors.black,
fontSize: 18.0,
fontWeight: FontWeight.w500,
),
),
SizedBox(width: 6.0),
Text(
'Subtitle Here',
style: TextStyle(
color: Colors.black,
fontSize: 15.0,
fontWeight: FontWeight.w300,
),
),
],
),
),
],
),
Divider(
color: Colors.black,
thickness: 1.5,
),
],
);
},
),

Flutter layout with listview and column

I am new to flutter, and I'm facing some layout errors that I cannot understand. Does someone knows why this error occurs? I know that Column widget cannot contain the Listview widget so I tried to wrap Listview widget with the Expanded, I cannot understand why the Expanded widget doens't work.
Here is my code. _buildBody function is not the part that error occurs so I will not write it.
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"공지",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w700,
fontFamily: "AppleSDGothicNeo",
fontStyle: FontStyle.normal,
fontSize: 16.0),
),
SizedBox(width: 5),
StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('Announcement')
.where('concertname', isEqualTo: widget.replay.title)
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return CircularProgressIndicator();
return Text(
snapshot.data.docs.length.toString(),
style: TextStyle(
color: Colors.black26,
fontWeight: FontWeight.w500,
fontFamily: "AppleSDGothicNeo",
fontStyle: FontStyle.normal,
fontSize: 14.0),
);
},
),
],
),
SizedBox(
height: 5,
),
_buildBody(context),
],
),
),
Divider(
height: 30,
thickness: 6,
color: Color(0xffecedf4),
),
Padding(
padding: const EdgeInsets.only(left: 20, right: 20),
child: Column(
children: [
Container(
height: 50,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"팬 피드",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w700,
fontFamily: "AppleSDGothicNeo",
fontStyle: FontStyle.normal,
fontSize: 16.0),
),
Spacer(),
Text("최신순",
style: const TextStyle(
color: Colors.black26,
fontWeight: FontWeight.w300,
fontFamily: "AppleSDGothicNeo",
fontStyle: FontStyle.normal,
fontSize: 12.0),
textAlign: TextAlign.right),
SizedBox(
child: Icon(
UniconIcon.iconchart,
color: Colors.black26,
),
),
],
),
),
Expanded(
child: ListView(
children: [
CircleAvatar(
backgroundImage: NetworkImage(
"https://lh3.googleusercontent.com/-5L9kDOItRJw/AAAAAAAAAAI/AAAAAAAAAAA/AMZuucmTNvDI3AljkDx1LMhuDaypX57yhA/s96-c/photo.jpg"),
),
CircleAvatar(
backgroundImage: NetworkImage(
"https://lh3.googleusercontent.com/-5L9kDOItRJw/AAAAAAAAAAI/AAAAAAAAAAA/AMZuucmTNvDI3AljkDx1LMhuDaypX57yhA/s96-c/photo.jpg"),
),
CircleAvatar(
backgroundImage: NetworkImage(
"https://lh3.googleusercontent.com/-5L9kDOItRJw/AAAAAAAAAAI/AAAAAAAAAAA/AMZuucmTNvDI3AljkDx1LMhuDaypX57yhA/s96-c/photo.jpg"),
),
],
)),
],
),
),
],
);
}
The problem is that you have two Column widgets here and the first passes unconstrained bounds to its children, hence, despite you using Expanded in the ListView that is inside the second Column (which is correct) you need also to wrap your second Column in a Expanded as well so it knows its constraints.
However, by looking at your code, looks like you are not using the second Column as advantage to nothing and if its because of the Padding just apply it to the first instead, so I recommend you to remove it at all and it should work as well.
Use shrinkWrap:true inside ListView

flutter Error when using color swatch inside PopupMenuItem

I have the following code:
class _StandardCardState extends State<StandardCard> {
#override
Widget build(BuildContext context) {
return Container(
child: Card(
margin: EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 0.0),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Row(
children: <Widget>[
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Row(
children: <Widget>[
Text(
'L*: ',
style: TextStyle(
fontSize: 18.0, color: Colors.grey[600]),
),
Text(
widget.standard.L.toString(),
style: TextStyle(
fontSize: 18.0, color: Colors.grey[600]),
),
],
),
SizedBox(height: 6.0),
Row(
children: <Widget>[
//some children
],
),
SizedBox(height: 6.0),
Row(
children: <Widget>[
//some children
],
),
],
),
),
PopupMenuButton<WhyFarther>(
onSelected: (WhyFarther result) {
setState(() {
var _selection = result;
});
},
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<WhyFarther>>[
const PopupMenuItem<WhyFarther>(
value: WhyFarther.harder,
child: Text(
'Working a lot harder',
style: TextStyle(fontSize: 18.0, color: Colors.grey[600]),
),
),
const PopupMenuItem<WhyFarther>(
value: WhyFarther.smarter,
child: Text(
'Being a lot smarter',
style: TextStyle(fontSize: 18.0, color: Colors.grey[600]),
),
),
const PopupMenuItem<WhyFarther>(
value: WhyFarther.selfStarter,
child: Text(
'Being a self-starter',
style: TextStyle(fontSize: 18.0, color: Colors.grey[600]),
),
),
const PopupMenuItem<WhyFarther>(
value: WhyFarther.tradingCharter,
child: Text(
'Placed in charge of trading charter',
style: TextStyle(fontSize: 18.0, color: Colors.grey[600]),
),
),
],
)
],
),
),
),
);
}
}
which is then still called through another function by a ListView.builder. when I try to use Swatches to change the Text Style inside a popupMenuItem, I get the error ´'Invalid constant value'´.
Why does this throw an error while the text widget above doesn't? And how can I avoid that and how do I use swatches inside PopupMenuButtons then?
i only had to remove the ´const´ before the PopupMenuItem... Sometimes reading when copycoding helps a lot.

Vertically align text in Card widget in Flutter

For some reason the text in the Cards are displaying slightly lower than the vertical center of each Card. It becomes more noticeable as more cards are added.
I have tried wrapping the Text widget in a Center widget. I have tried placing mainAxisAlignment and crossAxisAlignment in what I felt was appropriate placing, but still no difference.
Worth noting: I am using AutoSizeText widget where normal Text widget would be. But even with the normal Text widget, I encounter the same issue.
return new Container(
padding: new EdgeInsets.all(20.0),
child: Column(
children: <Widget>[
Expanded(
flex: 2,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
'Happy with this text',
style: new TextStyle(fontSize: 20.0),
),
new Text(
'Happy with this text',
style: new TextStyle(fontSize: 20.0),
),
],
),
),
Expanded(
flex: 8,
child: Row(
// mainAxisAlignment: MainAxisAlignment.center, // does not make any noticeable difference
// crossAxisAlignment: CrossAxisAlignment.center, // does not make any noticeable difference
children: <Widget>[
Expanded(
child: Card(
color: Colors.white70,
child: Container(
child: ListTile(
title: Center(
child: AutoSizeText(
'Not happy with this text',
style: TextStyle(
fontWeight: FontWeight.w500, fontSize: 30),
minFontSize: 12.0,
),
),
leading: Icon(
Icons.question_answer,
color: Colors.blue[500],
),
),
),
)),
Expanded(
child: Column(
children: <Widget>[
Expanded(
child: InkWell(
onTap: () {
print("Card 1 Clicked");
},
child: Card(
color: Colors.white70,
child: Container(
child: ListTile(
title: Center(
child: AutoSizeText(
'Not happy with this text',
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 12),
minFontSize: 12.0,
),
)),
),
))),
Expanded(
child: InkWell(
onTap: () {
print("Card 2 Clicked");
},
child: Card(
color: Colors.white70,
child: Container(
child: ListTile(
title: Center(
child: AutoSizeText(
'Not happy with this text',
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: fontSize),
minFontSize: 12.0,
),
)),
),
))),
Expanded(
child: InkWell(
onTap: () {
print("Card 3 Clicked");
},
child: Card(
color: Colors.white70,
child: Container(
child: ListTile(
title: Center(
child: AutoSizeText(
'A nocturnal ',
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: fontSize),
minFontSize: 12.0,
),
)),
),
))),
Expanded(
child: InkWell(
onTap: () {
print("Card 4 Clicked");
},
child: Card(
color: Colors.white70,
child: Container(
child: ListTile(
title: Center(
child: AutoSizeText(
'A nocturnal ',
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: fontSize),
minFontSize: 12.0,
),
)),
),
))),
],
),
),
],
),
),
],
),
);
Container(
child: Card(
margin: EdgeInsets.all(20.0),
elevation: 10.0,
//color: Colors.blue,
child:Align(
child: ListTile(
title: Text(
"CIL",
style: TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
alignment: Alignment.center,
),
),
),
Removing ListTile fixed the issue, though I assume a better way would be to override whatever defaults ListTile has which causes this.