Extra Spacing Inside My Text Widget In Flutter Application - flutter

I have created a mobile application and I was using a font family called Baloo Paaji 2 from google and I have faced an issue of extra spacing created between my 2 text widgets. Below you can see the image of the view.
The text I am talking about is the Welcome! Lakshya Jain. The space between the 2 is way too much. There is no SizedBox or Padding added to the text widget. I tried using 2 different methods to see if the method was the problem. The 2 different methods are shown below.
Method 1
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Welcome !",
style: TextStyle(
color: Colors.white,
fontFamily: "BalooPaaji",
fontSize: 18.0,
fontWeight: FontWeight.w600,
),
),
Text(
userData.fullName,
style: TextStyle(
color: Colors.white,
fontFamily: "BalooPaaji",
fontSize: 24.0,
fontWeight: FontWeight.w900,
),
),
],
),
Method 2
Text.rich(
TextSpan(
text: "Welcome !\n",
style: TextStyle(
color: Colors.white,
fontFamily: "BalooPaaji",
fontSize: 18.0,
fontWeight: FontWeight.w600,
),
children: [
TextSpan(
text: userData.fullName,
style: TextStyle(
color: Colors.white,
fontFamily: "BalooPaaji",
fontSize: 24.0,
fontWeight: FontWeight.w900,
),
),
],
),
),
Now I used another method which fixed this issue but created another one.
The Method 3 Screenshot is as follows.
Now the spacing issue is fixed but it created as the text has moved down a little. I want it to be center without the huge gap.
The code for this method is as followed.
Stack(
alignment: Alignment.topLeft,
clipBehavior: Clip.none,
children: [
Text(
"Welcome !",
style: TextStyle(
color: Colors.white,
fontFamily: "BalooPaaji",
fontSize: 18.0,
fontWeight: FontWeight.w600,
),
),
Positioned(
top: 20.0,
child: Text(
userData.fullName,
style: TextStyle(
color: Colors.white,
fontFamily: "BalooPaaji",
fontSize: 24.0,
fontWeight: FontWeight.w900,
),
),
),
],
),
The full code for the whole header is as followed
class HomeHeader extends StatelessWidget {
#override
Widget build(BuildContext context) {
// Get User UID
final user = Provider.of<MyAppUser>(context);
return Stack(
clipBehavior: Clip.none,
children: [
Container(
padding: EdgeInsets.symmetric(horizontal: 15.0),
width: MediaQuery.of(context).size.width,
height: 230.0,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color.fromRGBO(255, 18, 54, 1.0),
Color.fromRGBO(255, 164, 29, 1.0),
],
),
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(59.0),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
StreamBuilder(
stream: DatabaseService(uid: user.uid).userData,
builder: (context, snapshot) {
UserDataCustomer userData = snapshot.data;
return Row(
children: [
ClipOval(
child: CachedNetworkImage(
height: 70,
width: 70,
imageUrl: userData.profilePicture,
),
),
SizedBox(
width: 10.0,
),
Stack(
alignment: Alignment.topLeft,
clipBehavior: Clip.none,
children: [
Text(
"Welcome !",
style: TextStyle(
color: Colors.white,
fontFamily: "BalooPaaji",
fontSize: 18.0,
fontWeight: FontWeight.w600,
),
),
Positioned(
top: 20.0,
child: Text(
userData.fullName,
style: TextStyle(
color: Colors.white,
fontFamily: "BalooPaaji",
fontSize: 24.0,
fontWeight: FontWeight.w900,
),
),
),
],
),
// Column(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// "Welcome !",
// style: TextStyle(
// color: Colors.white,
// fontFamily: "BalooPaaji",
// fontSize: 18.0,
// fontWeight: FontWeight.w600,
// ),
// ),
// Text(
// userData.fullName,
// style: TextStyle(
// color: Colors.white,
// fontFamily: "BalooPaaji",
// fontSize: 24.0,
// fontWeight: FontWeight.w900,
// ),
// ),
// ],
// ),
// Text.rich(
// TextSpan(
// text: "Welcome !\n",
// style: TextStyle(
// color: Colors.white,
// fontFamily: "BalooPaaji",
// fontSize: 18.0,
// fontWeight: FontWeight.w600,
// ),
// children: [
// TextSpan(
// text: userData.fullName,
// style: TextStyle(
// color: Colors.white,
// fontFamily: "BalooPaaji",
// fontSize: 24.0,
// fontWeight: FontWeight.w900,
// ),
// ),
// ],
// ),
// ),
],
);
},
),
StreamBuilder(
stream: FirebaseFirestore.instance
.collection("Users Database")
.doc(user.uid)
.collection("Cart")
.snapshots(),
builder: (context, snapshot) {
int totalItems = 0;
if (snapshot.connectionState == ConnectionState.active) {
List documents = snapshot.data.docs;
totalItems = documents.length;
}
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CartScreen(),
),
);
},
child: Container(
height: 40.0,
width: 40.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(
10.0,
),
),
child: Center(
child: Text(
"$totalItems" ?? "0",
style: TextStyle(
fontSize: 20.0,
fontFamily: "BalooPaaji",
fontWeight: FontWeight.w600,
color: Colors.black,
),
),
),
),
);
},
),
],
),
),
Positioned(
top: 200.0,
child: SearchBar(
width: MediaQuery.of(context).size.width * 0.83,
hintText: "Location",
),
),
],
);
}
}
Someone please help me and fix this issue as soon as possible.

I guess you are trying to reduce gap / padding between the 2 lines. If that is so, then the easiest way is to wrap them inside container and give it a fixed height. Check below.
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 20, // assign height as per your choice
child: Text(
"Welcome !",
style: TextStyle(
color: Colors.white,
fontFamily: "BalooPaaji",
fontSize: 18.0,
fontWeight: FontWeight.w600,
),
),
),
Container(
height: 26, // assign height as per your choice
child: Text(
userData.fullName,
style: TextStyle(
color: Colors.white,
fontFamily: "BalooPaaji",
fontSize: 24.0,
fontWeight: FontWeight.w900,
),
),
),
],
),
NOTE: you can also give height inside the Text widget
Text(
userData.fullName,
style: TextStyle(
color: Colors.white,
fontFamily: "BalooPaaji",
fontSize: 24.0,
fontWeight: FontWeight.w900,
height: 1.2, // assign height to fontSize ratio as per your choice
),
),

Try to change :
This : fontWeight: FontWeight.w600,
To : fontWeight: FontWeight.w500,

Related

Fixing sides of a Card in a Flutter Project

I am trying to fix the sides of the card as on 1 side it is touching the boarder and on the other it is very far from it. I have tried several options but it is not solving my issue. I have also tried to shorten the width of the TextField but I was not able to do it.
Here is the messed outcome that I have:
Here is the code for the card:
Card(
elevation: 4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
color: const Color(0xFFF4F6FD),
margin:
const EdgeInsets.symmetric(horizontal: 5, vertical: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
FutureBuilder<List<Article_details_Model>>(
future: futureArticle_details,
builder: (BuildContext context,
AsyncSnapshot<List<Article_details_Model>> snapshot) {
if (snapshot.hasData) {
return Column(
children: List.generate(
snapshot.data!.length,
(index) => Column(
children: [
const Gap(10),
Text(
snapshot.data![index].name,
textAlign: TextAlign.start,
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const Gap(10),
Table(
children: [
const TableRow(children: [
Text(
'No.',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
Text(
'Counts',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
Text(
'Last Order',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
Text(
'New Counts',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
Text(
'New Order',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
),
)
]),
// Iterate over the sequences list and display the sequence information
for (var sequence
in snapshot.data![index].sequences)
TableRow(children: [
Text(
'${sequence.no}',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
Text(
'${sequence.counts}',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
Text(
'${sequence.order}',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
TextField(
keyboardType:
TextInputType.number,
decoration: InputDecoration(),
),
TextField(
keyboardType:
TextInputType.number,
decoration: InputDecoration(),
),
])
],
),
],
),
),
);
} else if (snapshot.hasError) {
print(snapshot.error);
return Text('${snapshot.error}');
}
return const CircularProgressIndicator();
},
),
],
),
),
My question
How can I fix the sides of the card so that it can have a little space and how can I decrease the width of the textfield.
Use padding :
Card(
elevation: 4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
color: const Color(0xFFF4F6FD),
margin:
const EdgeInsets.symmetric(horizontal: 5, vertical: 5),
child:
Padding(
padding: const EdgeInsets.all(18.0), //change here
child :Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
FutureBuilder<List<Article_details_Model>>(
future: futureArticle_details,
builder: (BuildContext context,
AsyncSnapshot<List<Article_details_Model>> snapshot) {
if (snapshot.hasData) {
return Column(
children: List.generate(
snapshot.data!.length,
(index) => Column(
children: [
const Gap(10),
Text(
snapshot.data![index].name,
textAlign: TextAlign.start,
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const Gap(10),
Table(
children: [
const TableRow(children: [
Text(
'No.',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
Text(
'Counts',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
Text(
'Last Order',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
Text(
'New Counts',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
Text(
'New Order',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
),
)
]),
// Iterate over the sequences list and display the sequence information
for (var sequence
in snapshot.data![index].sequences)
TableRow(children: [
Text(
'${sequence.no}',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
Text(
'${sequence.counts}',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
Text(
'${sequence.order}',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
TextField(
keyboardType:
TextInputType.number,
decoration: InputDecoration(),
),
TextField(
keyboardType:
TextInputType.number,
decoration: InputDecoration(),
),
])
],
),
],
),
),
);
} else if (snapshot.hasError) {
print(snapshot.error);
return Text('${snapshot.error}');
}
return const CircularProgressIndicator();
},
),
],
),)
),

How to Dynamically Resize List View Height with content having expansion tiles/expandable

Here i want to create screen like this
Instead what i created like this, my listview (under campaign period) is inside container with fixed height, so when i expand the section is overflowed and when its collapsed its give some blank space. What i ask is how i can create my listview size height change based on its content.
Here is my code
FixedTimeline.tileBuilder(
theme: TimelineThemeData(
nodePosition: 0,
indicatorPosition: 0,
indicatorTheme: IndicatorThemeData(
position: 0,
size: 20.0,
),
connectorTheme: ConnectorThemeData(
thickness: 2.5,
),
),
builder: TimelineTileBuilder.connected(
connectionDirection: ConnectionDirection.before,
itemCount: listPeriode.length,
contentsBuilder: (_, index) {
return Container(
padding: EdgeInsets.only(left: 8.0, bottom: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(
"${listPeriode[index]['label']}",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w400,
color: dashboardgrey,
),
),
),
Visibility(
visible: index == 0 &&
brandDealsDetailModel.arDeal.startDate != null,
child: Text(
"${DateFormat("dd MMM", context.locale.languageCode).format(brandDealsDetailModel.arDeal.regStartDate)} - ${DateFormat("dd MMM", context.locale.languageCode).format(brandDealsDetailModel.arDeal.regEndDate)}",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w700,
fontFamily: "NeutrifPro",
color: monoDoff,
),
),
),
Visibility(
visible: index == 2,
child: Text(
"${DateFormat("dd MMM", context.locale.languageCode).format(brandDealsDetailModel.arDeal.paymentStartDate)} - ${DateFormat("dd MMM", context.locale.languageCode).format(brandDealsDetailModel.arDeal.paymentEndDate)}",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w700,
fontFamily: "NeutrifPro",
color: monoDoff,
),
),
),
],
),
Visibility(
visible: index == 1,
child: Container(
height:
200, // I want height that dynamic with expandable
child: ListView.custom(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
childrenDelegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
final taskData =
brandDealsDetailModel.arTask[index];
return ExpandablePanel(
header: Row(
children: [
Text(
taskData.sowName,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
fontFamily: "NeutrifPro",
color: monoDoff,
),
),
],
),
collapsed: Container(),
expanded: Container(
height: 50.0 *
brandDealsDetailModel.arTask.length,
child: FixedTimeline.tileBuilder(
theme: TimelineThemeData(
nodePosition: 0,
indicatorPosition: 0,
// color: Color(0xff989898),
indicatorTheme: IndicatorThemeData(
position: 0,
size: 20.0,
),
connectorTheme: ConnectorThemeData(
thickness: 2.5,
),
),
builder: TimelineTileBuilder.connected(
indicatorBuilder: (_, index) {
return Container(
width: 8,
height: 8,
padding: EdgeInsets.all(2),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(50),
color: borderDE,
),
);
},
connectorBuilder: (_, index, ___) =>
DashedLineConnector(
thickness: 2,
color: borderDE,
),
itemCount: 4,
contentsAlign:
ContentsAlign.alternating,
contentsBuilder:
(context, ListTaskIndex) {
return Container(
margin: EdgeInsets.symmetric(
// vertical: 8,
),
child: Column(
mainAxisSize:
MainAxisSize.min,
children: [
if (taskData.isDrafting)
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
"Drafting Submission",
style: TextStyle(
fontSize: 12,
fontWeight:
FontWeight
.w500,
fontFamily:
"NeutrifPro",
color: monoDoff,
),
),
Text(
"${DateFormat("dd MMM", context.locale.languageCode).format(taskData.draftingStartDate)} - ${DateFormat("dd MMM", context.locale.languageCode).format(taskData.draftingEndDate)}",
style: TextStyle(
fontSize: 14,
fontWeight:
FontWeight
.w700,
fontFamily:
"NeutrifPro",
color: monoDoff,
),
),
],
),
if (taskData.isPosting)
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
"Posting Period",
style: TextStyle(
fontSize: 12,
fontWeight:
FontWeight
.w500,
fontFamily:
"NeutrifPro",
color: monoDoff,
),
),
Text(
"${DateFormat("dd MMM", context.locale.languageCode).format(taskData.postingStartDate)} - ${DateFormat("dd MMM", context.locale.languageCode).format(taskData.postingEndDate)}",
style: TextStyle(
fontSize: 14,
fontWeight:
FontWeight
.w700,
fontFamily:
"NeutrifPro",
color: monoDoff,
),
),
],
),
if (taskData.isSubmitPow)
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
"Submit Proof of Work",
style: TextStyle(
fontSize: 12,
fontWeight:
FontWeight
.w500,
fontFamily:
"NeutrifPro",
color: monoDoff,
),
),
Text(
"${DateFormat("dd MMM", context.locale.languageCode).format(taskData.postUrlStartDate)} - ${DateFormat("dd MMM", context.locale.languageCode).format(taskData.postUrlEndDate)}",
style: TextStyle(
fontSize: 14,
fontWeight:
FontWeight
.w700,
fontFamily:
"NeutrifPro",
color: monoDoff,
),
),
],
),
if (taskData
.isSubmitInsight)
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
"Submit Insight Proof",
style: TextStyle(
fontSize: 12,
fontWeight:
FontWeight
.w500,
fontFamily:
"NeutrifPro",
color: monoDoff,
),
),
Text(
"${DateFormat("dd MMM", context.locale.languageCode).format(taskData.reportInsightStartDate)} - ${DateFormat("dd MMM", context.locale.languageCode).format(taskData.reportInsightEndDate)}",
style: TextStyle(
fontSize: 14,
fontWeight:
FontWeight
.w700,
fontFamily:
"NeutrifPro",
color: monoDoff,
),
),
],
),
],
),
);
}),
),
),
);
},
childCount: brandDealsDetailModel.arTask.length,
)),
),
)
],
),
);
},
indicatorBuilder: (_, index) {
return Container(
width: 14,
height: 14,
padding: EdgeInsets.all(2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: tiger,
),
);
},
connectorBuilder: (_, index, ___) => DashedLineConnector(
thickness: 2,
color: borderDE,
),
),
),

Reduce space between specific children in column widget

What is this space in between and how do I remove/reduce it?
Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
'assets/weather/cloudy-night.svg',
width: 300,
),
Text(
'Temperature',
style: GoogleFonts.inter(
fontSize: 75,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
Text(
'Datetime',
style: GoogleFonts.inter(
fontSize: 30,
color: Colors.white,
),
),
],
),
)
Add height to text
Text(
'Temperature',
style: GoogleFonts.inter(
fontSize: 75,
fontWeight: FontWeight.bold,
color: Colors.white,
height: 1,
),
),

Flutter: A RenderFlex overflowed by 7.0 pixels on the bottom

I'm trying to fix this padding issue, but it still occur. And i want a gap below the buttons too. please help how to fix it.
Error:
A RenderFlex overflowed by 7.0 pixels on the bottom.
The relevant error-causing widget was
Column
Error is pointing on ListTile's leading and trailing Column.
Here is my code
var appointmentCards = Column(
children: [
SizedBox100(),
SizedBox20(),
ListView.builder(
itemCount: category.length,
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
// return upcomingAppointmentCard(context);
return Container(
margin: EdgeInsets.symmetric(horizontal: 25, vertical: 7),
child: Card(
elevation: 10,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
child: Column(
children: [
ListTile(
leading: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"08:30",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 18,
fontFamily: fontFamily),
),
Text(
"Thurday",
style: TextStyle(
color: Colors.black,
fontSize: 12,
fontFamily: fontFamily),
),
Text(
"9 March 2021",
style: TextStyle(
color: Colors.black,
fontSize: 12,
fontFamily: fontFamily),
),
],
),
trailing: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"Dr. Maria",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 18,
fontFamily: fontFamily),
),
Text(
"Thurday",
style: TextStyle(
color: Colors.black,
fontSize: 12,
fontFamily: fontFamily),
),
Text(
"9 March 2021",
style: TextStyle(
color: Colors.black,
fontSize: 12,
fontFamily: fontFamily),
),
],
),
),
// Row(
// mainAxisAlignment: MainAxisAlignment.start,
// children: [
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: const [
// Text(
// "08:30",
// style: TextStyle(
// fontWeight: FontWeight.bold,
// color: Colors.black,
// fontSize: 18,
// fontFamily: fontFamily),
// ),
// Text(
// "Thurday",
// style: TextStyle(
// color: Colors.black,
// fontSize: 12,
// fontFamily: fontFamily),
// ),
// Text(
// "9 March 2021",
// style: TextStyle(
// color: Colors.black,
// fontSize: 12,
// fontFamily: fontFamily),
// ),
// ],
// ),
// SizedBox(
// width: MediaQuery.of(context).size.width * 0.2,
// ),
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: const [
// Text(
// "Dentist",
// style: TextStyle(
// fontWeight: FontWeight.bold,
// color: Colors.black,
// fontSize: 18,
// fontFamily: fontFamily),
// ),
// Text(
// "Dentist",
// style: TextStyle(
// color: Colors.black,
// fontFamily: fontFamily),
// ),
// Text(
// "Jinnah",
// style: TextStyle(
// color: Colors.black,
// fontFamily: fontFamily),
// ),
// ],
// ),
// // SizedBoxWidth10(),
// ],
// ),
SizedBox20(),
appointmentTile == 'Upcoming'
? Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
customButtonWithWhiteBg(
context,
Text(
"Cancel",
style: TextStyle(
fontSize: 15,
fontFamily: fontFamily,
fontWeight: FontWeight.w400),
),
MediaQuery.of(context).size.height * 0.05,
() {}),
customButtonWithWhiteBg(
context,
Text(
"Reschedule",
style: TextStyle(
fontSize: 15,
fontFamily: fontFamily,
fontWeight: FontWeight.w400),
),
MediaQuery.of(context).size.height * 0.05,
() {}),
],
)
: Padding(padding: EdgeInsets.zero)
],
),
),
);
},
),
SizedBox10(),
],
);
Try this..
Container(
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("08:30",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 18)),
Text("Thurday ",
style:
TextStyle(color: Colors.black, fontSize: 12)),
Text("9 March 2021",
style:
TextStyle(color: Colors.black, fontSize: 12)),
],
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text("Dr. Maria",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 18)),
Text("Thurday",
style:
TextStyle(color: Colors.black, fontSize: 12)),
Text("9 March 2021",
style:
TextStyle(color: Colors.black, fontSize: 12)),
],
),
),
],
),
),
Try to wrap your Text Widgets inside Expanded or Flexible Widget.
Card(
elevation: 10,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
child: Column(
children: [
ListTile(
leading: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
"08:30",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 18,
),
),
),
Expanded(
child: Text(
"Thurday",
style: TextStyle(
color: Colors.black,
fontSize: 12,
),
),
),
Expanded(
child: Text(
"9 March 2021",
style: TextStyle(
color: Colors.black,
fontSize: 12,
),
),
),
],
),
trailing: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: Text(
"Dr. Maria",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 18,
),
),
),
Expanded(
child: Text(
"Thurday",
style: TextStyle(
color: Colors.black,
fontSize: 12,
),
),
),
Expanded(
child: Text(
"9 March 2021",
style: TextStyle(
color: Colors.black,
fontSize: 12,
),
),
),
],
),
),
],
),
),
Result Screen->

Popup Menu Button inside Gesture Button not working in Flutter

I am Making a PopUp menu inside Gesture Button but on clicking that button the menu does not show up. Nothing is happening on clicking the button. What should I do to make it visible on clicking the button?
I also used Focused Menu Button but the same happened with it as well. I cannot figure out the problem.
I am making a Screen like this:
I want to show these menus on clicking button:
My code for Screen is this:
import 'package:epicare/NavigBar.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:focused_menu/focused_menu.dart';
import 'package:focused_menu/modals.dart';
import 'AddMedicineScreen.dart';
class MedicinesRecord extends StatefulWidget {
#override
_MedicinesRecordState createState() => _MedicinesRecordState();
}
class _MedicinesRecordState extends State<MedicinesRecord>
with TickerProviderStateMixin {
TabController _tabController;
var _selectedIndex = 0;
#override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this)
..addListener(() {
setState(() {
_selectedIndex = _tabController.index;
});
});
}
#override
void dispose() {
super.dispose();
_tabController.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: const Color(0xffE5E0A1),
elevation: 0,
centerTitle: true,
title: Text(
"Medicine",
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
fontFamily: 'Montserrat',
fontWeight: FontWeight.normal,
),
),
leading: IconButton(
icon: Icon(
Icons.arrow_back,
color: Colors.black,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return Homepage();
},
),
);
},
),
),
body: Column(
children: [
// give the tab bar a height [can change height to preferred height]
Container(
margin: EdgeInsets.only(top: 32, right: 45, left: 45),
height: 45,
decoration: BoxDecoration(
color: const Color(0xffE5E0A1),
borderRadius: BorderRadius.circular(
17.0,
),
border: Border.all(width: 1.0, color: const Color(0xff2f363d)),
),
child: TabBar(
controller: _tabController,
// give the indicator a decoration (color and border radius)
indicator: BoxDecoration(
borderRadius: BorderRadius.circular(
17.0,
),
color: Colors.black,
),
labelColor: const Color(0xffd4d411),
unselectedLabelColor: Colors.black,
tabs: [
// first tab [you can add an icon using the icon property]
Tab(
child: Text(
'Medicines',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 16,
//color: const Color(0xffd4d411),
letterSpacing: 0.48,
),
textAlign: TextAlign.left,
),
),
// second tab [you can add an icon using the icon property]
Tab(
child: Text(
'History',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 16,
//color: const Color(0xffd4d411),
letterSpacing: 0.48,
),
textAlign: TextAlign.left,
),
),
],
),
),
// tab bar view her
Expanded(
child: TabBarView(
controller: _tabController,
children: [
// Container(
//padding: EdgeInsets.symmetric(vertical: 25, horizontal: 32),
//height: 50,
//child:
Medicine(),
//),
// second tab bar view widget
MedHistory(),
],
),
),
],
),
floatingActionButton: _selectedIndex > 0
? Container()
: FloatingActionButton(
child: Icon(
Icons.add,
size: 40,
),
backgroundColor: const Color(0xffd4d411),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return AddMedicine();
},
),
);
},
),
);
}
Widget Medicine() {
Size size = MediaQuery.of(context).size;
return ListView(
children: [
Container(
margin: EdgeInsets.only(top: 25, left: 32, right: 32),
width: size.width * 0.80,
height: 54,
padding: EdgeInsets.symmetric(vertical: 11, horizontal: 20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(9.0),
color: Colors.white,
boxShadow: [
BoxShadow(
color: const Color(0x29000000),
offset: Offset(0, 3),
blurRadius: 6,
),
],
),
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Panadol',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 12,
fontWeight: FontWeight.w500,
color: const Color(0xff232425),
),
textAlign: TextAlign.left,
),
Text(
'Thrice a day',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 10,
color: const Color(0x80232425),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
],
),
Container(
width: size.width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
'50 mg',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 10,
fontWeight: FontWeight.w600,
color: const Color(0x80515559),
),
textAlign: TextAlign.left,
),
GestureDetector(
onTap: () {
myPopMenu();
// FocusedMenuHolder(
// menuBoxDecoration: BoxDecoration(
// color: const Color(0xFFD9D9D9),
// ),
// animateMenuItems: false,
// duration: Duration(milliseconds: 500),
// blurBackgroundColor: Colors.white,
// blurSize: 2,
// menuWidth: size.width * 0.5,
// onPressed: () {},
// menuItems: <FocusedMenuItem>[
// FocusedMenuItem(
// title: Text(
// "Edit",
// style: TextStyle(
// fontFamily: 'Montserrat',
// fontWeight: FontWeight.w600,
// fontSize: 14,
// color: const Color(0xff000000),
// ),
// textAlign: TextAlign.center,
// ),
// onPressed: () {}),
// FocusedMenuItem(
// title: Text(
// "Delete",
// style: TextStyle(
// fontFamily: 'Montserrat',
// fontWeight: FontWeight.w600,
// fontSize: 14,
// color: const Color(0xff000000),
// ),
// textAlign: TextAlign.center,
// ),
// onPressed: () {})
// ],
// );
},
child: Icon(
Icons.more_horiz,
size: 20,
),
)
],
),
),
],
),
),
],
);
}
Widget MedHistory() {
Size size = MediaQuery.of(context).size;
return ListView(
children: [
Container(
margin: EdgeInsets.only(top: 25, left: 32, right: 32),
width: size.width * 0.80,
height: 50,
padding: EdgeInsets.symmetric(vertical: 11, horizontal: 20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(9.0),
color: Colors.white,
boxShadow: [
BoxShadow(
color: const Color(0x29000000),
offset: Offset(0, 3),
blurRadius: 6,
),
],
),
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Panadol',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 12,
fontWeight: FontWeight.w500,
color: const Color(0xff232425),
),
textAlign: TextAlign.left,
),
Text(
'From: 1 Jan,2021',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 10,
color: const Color(0x80232425),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
],
),
Container(
width: size.width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
'50 mg',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 10,
fontWeight: FontWeight.w600,
color: const Color(0x80515559),
),
textAlign: TextAlign.left,
),
Text(
'Ongoing',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 10,
fontWeight: FontWeight.w600,
color: const Color(0x80232425),
),
textAlign: TextAlign.left,
),
],
),
),
],
),
),
Container(
margin: EdgeInsets.only(top: 25, left: 32, right: 32),
width: size.width * 0.80,
height: 50,
padding: EdgeInsets.symmetric(vertical: 11, horizontal: 20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(9.0),
color: Colors.white,
boxShadow: [
BoxShadow(
color: const Color(0x29000000),
offset: Offset(0, 3),
blurRadius: 6,
),
],
),
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Calpol',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 12,
fontWeight: FontWeight.w500,
color: const Color(0xff232425),
),
textAlign: TextAlign.left,
),
Text(
'As needed',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 10,
color: const Color(0x80232425),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
],
),
Container(
width: size.width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
'250 mg',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 10,
fontWeight: FontWeight.w600,
color: const Color(0x80515559),
),
textAlign: TextAlign.left,
),
Text(
'Ended: 20 Jan, 2021',
style: TextStyle(
fontFamily: 'Montserrat',
fontSize: 10,
fontWeight: FontWeight.w600,
color: const Color(0x80232425),
),
textAlign: TextAlign.left,
),
],
),
),
],
),
),
],
);
}
Widget myPopMenu() {
return PopupMenuButton(
color: Colors.white,
onSelected: (value) {
Fluttertoast.showToast(
msg: "You have selected " + value.toString(),
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: Colors.black,
textColor: Colors.white,
fontSize: 16.0);
},
itemBuilder: (context) => [
PopupMenuItem(
value: 1,
child: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(2, 2, 8, 2),
child: Icon(Icons.print),
),
Text('Print')
],
)),
PopupMenuItem(
value: 2,
child: Row(
children: <Widget>[
Text(
"Edit",
style: TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.w600,
fontSize: 14,
color: const Color(0xff000000),
),
textAlign: TextAlign.center,
),
],
),
),
PopupMenuItem(
value: 3,
child: Row(
children: <Widget>[
Text(
"Delete",
style: TextStyle(
fontFamily: 'Montserrat',
fontWeight: FontWeight.w600,
fontSize: 14,
color: const Color(0xff000000),
),
textAlign: TextAlign.center,
),
],
)),
]);
}
}
P.S: I am new to Flutter. Please help me out