Flutter Flexible does not take entire space - flutter

I have this chat item similar to what you see on WhatsApp.
This is what I have so far.
ListView(
physics: BouncingScrollPhysics(),
children: [
Dismissible(
key: Key(""),
background: Container(color: Colors.grey[200]),
direction: DismissDirection.endToStart,
child: InkWell(
highlightColor: Colors.transparent,
onTap: () {},
child: Column(
children: [
Container(
child: Padding(
padding: EdgeInsets.all(16),
child: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.fromLTRB(0, 0, 12, 0),
child: CircleAvatar(
backgroundColor: Colors.blue,
radius: 30,
),
),
],
),
),
Flexible(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.fromLTRB(0, 0, 0, 4),
child: Text(
"John Doe",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 16,
),
),
),
Text(
"Lorem ipsum, or something idk about this",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.grey[800]
),
),
],
),
),
Flexible(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Padding(
// padding: EdgeInsets.fromLTRB(0, 0, 0, 4),
// child: Text(
// "John Doe",
// maxLines: 1,
// overflow: TextOverflow.ellipsis,
// style: TextStyle(
// fontSize: 16,
// ),
// ),
// ),
Container(
alignment: Alignment.topRight,
child: Text(
"12:02",
maxLines: 2,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.right,
style: TextStyle(
color: Colors.grey[800],
fontSize: 12,
),
),
),
],
),
),
],
),
padding: const EdgeInsets.all(0.0),
alignment: Alignment.center,
),
),
),
Divider(
color: Colors.grey[300],
height: 1,
indent: 90,
),
],
),
),
),
],
),
The list view is part of the body of a scaffold.
Currently only the middle part of this is the issue. And by issue I mean it is not flexing all the way. The right hand side where it says 12:02 should only expand if it has to otherwise minimum size should be applied. I am extremely lost.
Thanks for any help!
I have added this image to show what it looks like so far.

Try Expanded Widget
ListView(
physics: BouncingScrollPhysics(),
children: [
Dismissible(
key: Key(""),
background: Container(color: Colors.grey[200]),
direction: DismissDirection.endToStart,
child: InkWell(
highlightColor: Colors.transparent,
onTap: () {},
child: Column(
children: [
Container(
child: Padding(
padding: EdgeInsets.all(16),
child: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.fromLTRB(0, 0, 12, 0),
child: CircleAvatar(
backgroundColor: Colors.blue,
radius: 30,
),
),
],
),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.fromLTRB(0, 0, 0, 4),
child: Text(
"John Doe",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 16,
),
),
),
Text(
"Lorem ipsum, or something idk about this",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: Colors.grey[800]),
),
],
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
// Padding(
// padding: EdgeInsets.fromLTRB(0, 0, 0, 4),
// child: Text(
// "John Doe",
// maxLines: 1,
// overflow: TextOverflow.ellipsis,
// style: TextStyle(
// fontSize: 16,
// ),
// ),
// ),
Container(
alignment: Alignment.topRight,
child: Text(
"12:02",
maxLines: 2,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.right,
style: TextStyle(
color: Colors.grey[800],
fontSize: 12,
),
),
),
],
),
),
),
],
),
padding: const EdgeInsets.all(0.0),
),
),
),
Divider(
color: Colors.grey[300],
height: 1,
indent: 90,
),
],
),
),
),
],
),

Seems like there really isn't a good none hacky solution. It seems to work quite well with positions and a stack.
Here is the code.
Dismissible(
key: Key(""),
background: Container(color: Colors.grey[200]),
direction: DismissDirection.endToStart,
child: InkWell(
highlightColor: Colors.transparent,
onTap: () {},
child: Column(
children: [
Container(
child: Padding(
padding: EdgeInsets.fromLTRB(16, 16, 16, 12),
child: Container(
child: Stack(
children: [
Positioned(
top: 0,
right: 0,
child: Text(
"Mon",
style: TextStyle(
fontSize: 14,
color: Colors.grey[600]
),
),
),
Positioned(
bottom: 0,
right: 0,
child: Container(
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.all(Radius.circular(100))
),
child: Padding(
padding: EdgeInsets.fromLTRB(8, 4, 8, 4),
child: Text(
"123",
style: TextStyle(
color: Colors.white,
fontSize: 14,
),
),
),
),
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.fromLTRB(0, 0, 12, 0),
child: CircleAvatar(
backgroundColor: Colors.blue,
radius: 30,
),
),
],
),
),
Flexible(
flex: 4,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.fromLTRB(0, 0, 0, 4),
child: Text(
"John Doe",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 16,
),
),
),
Text(
"Lorem ipsumahskhdk ashkda ",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: Colors.grey[800]),
),
],
),
),
SizedBox(
width: 60,
),
],
)
],
),
),
),
),
Divider(
color: Colors.grey[300],
height: 1,
indent: 90,
),
],
),
),
),

Related

How to expand column inside a row

I'm apologise to do this question again but I was reading similar ones and try to solve my problen and Iwasn't able to fix it.
I need my column(blue one) inside row expands vertically to and have the max heigth.
Here is my code
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Card(
color: Colors.amber,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
child: ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 40),
title: AutoSizeText('text',
maxLines: 1,
style: Theme.of(context).textTheme.bodyText1),
subtitle: AutoSizeText(
'subText',
maxLines: 1,
style: Theme.of(context).textTheme.subtitle1!.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w500),
),
)),
Column(
children: [
Container(
padding: EdgeInsets.zero,
margin: EdgeInsets.zero,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
color: Colors.blue,
),
child: FaIcon(
FontAwesomeIcons.locationDot,
),
),
],
),
],
),
),
],
),
Edited: Added expected output
remove following line from the column widget
mainAxisSize: MainAxisSize.min
Try below code and replace my widget code to your
Container(
height: 70,
color: Colors.amber,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
child: ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 40),
title: Text('text',
maxLines: 1,
style: Theme.of(context).textTheme.bodyText1),
subtitle: Text(
'subText',
maxLines: 1,
style: Theme.of(context).textTheme.subtitle1!.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w500),
),
),
),
Column(
children: [
Container(
height: 70,
width: 70,
padding: EdgeInsets.zero,
margin: EdgeInsets.zero,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
color: Colors.blue,
),
child: Icon(
Icons.add,
),
),
],
),
],
),
),
Result->

Text not resizing when using AutoSizeText

I'm new to developing in Flutter and I'm having an issue when using AutoSizeText isn't working as i thought it would. You can see on the screen grab that my date text is overflowing.
My code for reference. If anyone could point me in the right direction of where i'm going wrong i would be gladly appreciate it!
body: SafeArea(
child: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Stack(
children: [
Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0x76168183),
FlutterFlowTheme.of(context).primaryColor
],
stops: [0, 1],
begin: AlignmentDirectional(0, -1),
end: AlignmentDirectional(0, 1),
),
),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(10, 10, 10, 0),
child: Container(
decoration: BoxDecoration(
color:
FlutterFlowTheme.of(context).secondaryBackground,
borderRadius: BorderRadius.circular(5),
border: Border.all(
color: Color(0xFF168183),
width: 1,
),
),
child: Stack(
children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
OrderdateWidget(),
],
),
Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AutoSizeText(
dateTimeFormat(
'MMMMEEEEd',
getCurrentTimestamp,
locale: FFLocalizations.of(context)
.languageCode,
),
textAlign: TextAlign.center,
style: FlutterFlowTheme.of(context)
.bodyText1
.override(
fontFamily: 'SharpSans',
color: Color(0xFF222F3A),
fontSize: 32,
fontWeight: FontWeight.w800,
useGoogleFonts: GoogleFonts.asMap()
.containsKey(
FlutterFlowTheme.of(context)
.bodyText1Family),
),
),
],
),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AutoSizeText(
FFLocalizations.of(context).getText(
'yump08wx' /* Delivery address */,
),
style: FlutterFlowTheme.of(context)
.bodyText1
.override(
fontFamily: 'SharpSans',
color: Color(0xFF222F3A),
fontSize: 16,
fontWeight: FontWeight.w600,
useGoogleFonts: GoogleFonts.asMap()
.containsKey(
FlutterFlowTheme.of(context)
.bodyText1Family),
),
),
],
),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
AutoSizeText(
FFAppState().deliveryAddressName,
textAlign: TextAlign.center,
style: FlutterFlowTheme.of(context)
.bodyText1
.override(
fontFamily: 'SharpSans',
fontSize: 22,
fontWeight: FontWeight.w800,
useGoogleFonts: GoogleFonts.asMap()
.containsKey(
FlutterFlowTheme.of(context)
.bodyText1Family),
),
),
],
),
],
),
],
),
),
),
Expanded(
child: Container(
height: 100,
decoration: BoxDecoration(),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0, 5, 0, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
10, 0, 10, 0),
child: Container(
width:
MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: FlutterFlowTheme.of(context)
.primaryBtnText,
borderRadius:
BorderRadius.circular(5),
border: Border.all(
color: FlutterFlowTheme.of(context)
.primaryColor,
),
),
child: AutoSizeText(
FFLocalizations.of(context).getText(
'61jj7cic' /* Please select point of service... */,
),
textAlign: TextAlign.center,
maxLines: 1,
style: FlutterFlowTheme.of(context)
.bodyText1
.override(
fontFamily: 'SharpSans',
color: Color(0xFF222F3A),
fontSize: 18,
fontWeight: FontWeight.w600,
useGoogleFonts: GoogleFonts
.asMap()
.containsKey(
FlutterFlowTheme.of(
context)
.bodyText1Family),
),
),
),
),
),
],
),
),
Expanded(
child: Container(
height: 100,
decoration: BoxDecoration(),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
5, 10, 5, 10),
child: Builder(
builder: (context) {
final posGroup =
FFAppState().posGroupJson.toList();
return GridView.builder(
padding: EdgeInsets.zero,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
crossAxisSpacing: 0,
mainAxisSpacing: 10,
childAspectRatio: 3,
),
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: posGroup.length,
itemBuilder: (context, posGroupIndex) {
final posGroupItem =
posGroup[posGroupIndex];
return Padding(
padding:
EdgeInsetsDirectional.fromSTEB(
20, 0, 20, 10),
child: Material(
color: Colors.transparent,
elevation: 3,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(5),
),
child: Container(
width: 100,
height: 100,
decoration: BoxDecoration(
color: Color(0xFF168183),
borderRadius:
BorderRadius.circular(5),
border: Border.all(
color: FlutterFlowTheme.of(
context)
.primaryBtnText,
),
),
child: InkWell(
child: InkWell(
onTap: () async {
setState(() =>
FFAppState()
.posGroupName =
getJsonField(
posGroupItem,
r'''$..posGroupName''',
).toString());
setState(() =>
FFAppState()
.posGroupId =
getJsonField(
posGroupItem,
r'''$..posGroupId''',
).toString());
await Navigator.push(
context,
PageTransition(
type:
PageTransitionType
.fade,
duration: Duration(
milliseconds: 0),
reverseDuration:
Duration(
milliseconds:
0),
child:
PointOfServiceWidget(
parmPOSGroupId:
getJsonField(
posGroupItem,
r'''$..posGroupId''',
).toString(),
),
),
);
},
child: Column(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.center,
children: [
AutoSizeText(
getJsonField(
posGroupItem,
r'''$..posGroupName''',
).toString(),
style: FlutterFlowTheme
.of(context)
.bodyText1
.override(
fontFamily:
'SharpSans',
color: Colors
.white,
fontSize: 20,
fontWeight:
FontWeight
.w500,
useGoogleFonts: GoogleFonts
.asMap()
.containsKey(
FlutterFlowTheme.of(context)
.bodyText1Family),
),
),
],
),
),
),
),
),
);
},
);
},
),
),
),
),
],
),
),
),
],
),
),
],
),
),
),
);
wrap AutoSizeText with Expanded:
Expanded(
child: AutoSizeText(/*...*/),
),

Align children to top of row in Flutter?

after I write my posts in my application, my photo and date center the text. I need to pin the photo and date to the beginning. What should I do for this?
............................................................................................................................................................................................
child: Row( children: [
Padding(
padding: EdgeInsets.only(top: 15),
child: CircleAvatar(
radius: 20,
backgroundImage: NetworkImage(
userData['photoUrl'],
),
),
),
Expanded(
child: Padding(
padding:
EdgeInsets.only(left: 8, top: 20),
child: Container(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
userData['username'],
style: TextStyle(
fontWeight:
FontWeight.bold),
),
Container(
width: double.infinity,
padding: const EdgeInsets.only(
top: 8,
),
child: RichText(
text: TextSpan(
style: const TextStyle(
color: primaryColor),
children: [
TextSpan(
text:
' ${(snap.data()! as dynamic)['description']}',
),
],
),
),
),
],
),
),
),
),
Container(
padding:
EdgeInsets.symmetric(vertical: 4),
child: Text(
DateFormat.yMd().format(
(snap.data()!
as dynamic)['datePublished']
.toDate(),
),
style: const TextStyle(
fontSize: 15,
color: secondaryColor,
),
),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
In your Row, set crossAxisAlignment: CrossAxisAlignment.start. This will cause the Row's children to be aligned at the top of the row.

Flutter - cannot use Flexible inside Padding for text wrapping purpose

In my flutter app, I want to have a card and four boxes aligned horizontally with equal width and height inside it. Code follows ;
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Container(
padding: EdgeInsets.fromLTRB(20,10,10,0),
height: 220,
width: double.maxFinite,
child: Card(
elevation: 5,
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: Container(
height:25,
color:Color(0xff6898F7),
child: Text('Online Pharmacy',
style:TextStyle(color: Color(0xffffffff)))
)
)
],
),
Row(
children: <Widget>[
Expanded(
flex: 1,
child: Container(
height: 150,
padding: EdgeInsets.only(top:40),
color: Colors.red,
child: Column(
children: <Widget>[
Image.asset("images/medicine.jpg"),
Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding:EdgeInsets.only(top:25),
child:Flexible(
child:Text('Medicine', style: TextStyle(color: Colors.white)),
),
),
],
),
),
],
)
),
),
],
),
],
),
The reason I used Flexible is that I wanted the text to be wrapped in multiple lines where necessary.
But I get this error :
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building Container(padding: EdgeInsets(0.0, 40.0, 0.0, 0.0), bg: BoxDecoration(color: MaterialColor(primary value: Color(0xfff44336))), constraints: BoxConstraints(0.0<=w<=Infinity, h=150.0)):
Incorrect use of ParentDataWidget.
Flexible widgets must be placed directly inside Flex widgets.
Flexible(no depth, flex: 1, dirty) has a Flex ancestor, but there are other widgets between them:
- Padding(padding: EdgeInsets(0.0, 25.0, 0.0, 0.0))
These widgets cannot come between a Flexible and its Flex.
The ownership chain for the parent of the offending Flexible was:
Padding ← Row ← Center ← Column ← Padding ← DecoratedBox ← ConstrainedBox ← Container ← Expanded ← Row ← ⋯
So how can I wrap the text properly ? Without the wrapping issue, code works well.
EDIT:
My intended layout seems to be like the image below :
Edit2:
Let me give you a more precise idea about the layout:
Edit3:
After getting a solution ( see here ) in chat room from pskink , I had the following layout. See that the red marked part does not get the text aligned in a centered fashion. How to align text in a centered way ?
try textAlign: TextAlign.center, inside text Widget
Please try this...
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Card(
margin: EdgeInsets.all(10),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
color: Colors.blue,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Online Pharmacy",
style: TextStyle(fontSize: 16, color: Colors.white),
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
Container(
margin:
EdgeInsets.symmetric(vertical: 10, horizontal: 10),
width: 2,
height: 70,
color: Colors.grey,
),
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
Container(
margin:
EdgeInsets.symmetric(vertical: 10, horizontal: 10),
width: 2,
height: 70,
color: Colors.grey,
),
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
],
)
],
),
),
Card(
margin: EdgeInsets.all(10),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
color: Colors.blue,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Online Pharmacy",
style: TextStyle(fontSize: 16, color: Colors.white),
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
Container(
margin:
EdgeInsets.symmetric(vertical: 10, horizontal: 10),
width: 2,
height: 70,
color: Colors.grey,
),
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
Container(
margin:
EdgeInsets.symmetric(vertical: 10, horizontal: 10),
width: 2,
height: 70,
color: Colors.grey,
),
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
],
)
],
),
),
Card(
margin: EdgeInsets.all(10),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
color: Colors.blue,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Online Pharmacy",
style: TextStyle(fontSize: 16, color: Colors.white),
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
Container(
margin:
EdgeInsets.symmetric(vertical: 10, horizontal: 10),
width: 2,
height: 70,
color: Colors.grey,
),
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
Container(
margin:
EdgeInsets.symmetric(vertical: 10, horizontal: 10),
width: 2,
height: 70,
color: Colors.grey,
),
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
],
)
],
),
),
Card(
margin: EdgeInsets.all(10),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
color: Colors.blue,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Online Pharmacy",
style: TextStyle(fontSize: 16, color: Colors.white),
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
Container(
margin:
EdgeInsets.symmetric(vertical: 10, horizontal: 10),
width: 2,
height: 70,
color: Colors.grey,
),
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
Container(
margin:
EdgeInsets.symmetric(vertical: 10, horizontal: 10),
width: 2,
height: 70,
color: Colors.grey,
),
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
],
)
],
),
),
Card(
margin: EdgeInsets.all(10),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
color: Colors.blue,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Online Pharmacy",
style: TextStyle(fontSize: 16, color: Colors.white),
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
Container(
margin:
EdgeInsets.symmetric(vertical: 10, horizontal: 10),
width: 2,
height: 70,
color: Colors.grey,
),
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
Container(
margin:
EdgeInsets.symmetric(vertical: 10, horizontal: 10),
width: 2,
height: 70,
color: Colors.grey,
),
Expanded(
child: Container(
child: Center(
child: Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
FlutterLogo(
size: 50,
),
SizedBox(
height: 10,
),
//Image.asset("images/medicine.jpg"),
Text('Picture of your Prescription',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black, fontSize: 14)),
],
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
),
),
),
),
),
),
],
)
],
),
),
],
),
)));
}
Just copy paste code and see what happening...
May this will help you.
Padding(
padding: const EdgeInsets.all(8.0),
child: Material(
elevation: 5.0,
child: Container(
// height: 220,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(horizontal: 8.0),
height: 25,
color: Color(0xff6898F7),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
'Online Pharmacy',
style: TextStyle(
color: Color(0xffffffff),
),
),
Text(
'your hidden text lol',
style: TextStyle(
color: Color(0xffffffff),
),
),
],
),
),
Container(
height: 150.0,
child: Row(
children: <Widget>[
Expanded(
child: Container(
padding: EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// you could use icon instead of image
// Container(
// height: 80,
// child: Image.asset(
// "images/medicine.jpg",
// fit: BoxFit.fill,
// ),
// ),
Icon(
Icons.touch_app,
size: 40.0,
),
SizedBox(height: 10.0),
Flexible(
child: Text(
'Browse Through Database',
textAlign: TextAlign.center,
))
],
),
),
),
Expanded(
child: Container(
padding: EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// you could use icon instead of image
// Container(
// height: 80,
// child: Image.asset(
// "images/medicine.jpg",
// fit: BoxFit.fill,
// ),
// ),
Icon(
Icons.input,
size: 40.0,
),
SizedBox(height: 10.0),
Flexible(
child: Text(
'Type your own medicine',
textAlign: TextAlign.center,
))
],
),
),
),
Expanded(
child: Container(
padding: EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// you could use icon instead of image
// Container(
// height: 80,
// child: Image.asset(
// "images/medicine.jpg",
// fit: BoxFit.fill,
// ),
// ),
Icon(
Icons.image,
size: 40.0,
),
SizedBox(height: 10.0),
Flexible(
child: Text(
'Picture of your prescription',
textAlign: TextAlign.center,
))
],
),
),
),
],
),
),
],
)),
),
)
That my approach to what you need:

TextOverFlow.ellipsis in Widget Text not work

my widget text Wrap inside Expanded, row, and Column
return Container(
child: Expanded(
flex: 9,
child: GestureDetector(
onTap: () {
// .......
},
child: Container(
color: Colors.transparent,
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 15, bottom: 15),
child: Container(
width: 2,
color: Color(0XFF2B9FDC),
)),
Padding(
padding: EdgeInsets.only(left: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text( item.name,
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
Text(item.catgeory),
Text(item.price,
style: TextStyle(color: Colors.red),
),
],
),
),
],
),
),
),
),
);
I got error : Another exception was thrown: A RenderFlex overflowed by 7.3 pixels on the right.
AnyOne can help?
Just wrap your container with Expanded and use flex property as per your design and let me know its working or not
return Expanded(
child: Container(
child: GestureDetector(
onTap: () {
// .......
},
child: Container(
color: Colors.transparent,
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 15, bottom: 15),
child: Container(
width: 2,
color: Color(0XFF2B9FDC),
)),
Padding(
padding: EdgeInsets.only(left: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text( item.name,
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
Text(item.catgeory),
Text(item.price,
style: TextStyle(color: Colors.red),
),
],
),
),
],
),
),
),
),
);
Change this:
Text(
item.name,
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
into this:
Text(
item.name,
softWrap : true,
maxLines: 2,
),
softWrap → bool
Whether the text should break at soft line breaks