Flutter Flexible in Card - flutter

i'm having problems using flexible widget in card. I used Constrained Box but i'd like to use a widget without setting width. But if i use Flexible widget, card doesn't show up anymore.
My goal is to make text use all the available space without setting a constant width
Here is my code:
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:wemaind_mobile_app/pages/tasks/tasks_page.dart';
import 'package:wemaind_mobile_app/theme/colors.dart';
import 'board_entity.dart';
import 'task_counter.dart';
class BoardWidget extends StatelessWidget {
final BoardEntity board;
static const colors = WemaindColors();
BoardWidget(this.board);
#override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return ConstrainedBox(constraints: BoxConstraints(maxWidth: 500, minWidth: 280, minHeight: 300),
child:GestureDetector(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context)
{return TasksPage(board: board);
}));
},
child:
Container(
height: MediaQuery.of(context).size.height * 0.2,
child: Card(margin: EdgeInsets.only(top: 0, bottom: 16, left: 16, right: 16),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Column(mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic,
children: [
Flexible(
child: Text(board.name,
style: theme.textTheme.headline2,
)),
if (board.bookmarked) Icon(Icons.star, color: colors.orange),
],
),
Row(children:[
Flexible(
child: Text(board.role.toUpperCase(),style: theme.textTheme.headline4,overflow: TextOverflow.ellipsis,)),
]),
]),
Column(mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start,children: [
Row(mainAxisAlignment: MainAxisAlignment.start, children: [
Text(board.tasks.all.toString(), style: theme.textTheme.headline1),
Icon(Icons.more_vert, color: colors.blue.shade800, size: 32),
]),
Row(mainAxisAlignment: MainAxisAlignment.start, children: [
Text('TASK'.toUpperCase(), style: theme.textTheme.headline5),
])
]),
]),
Table(
children: [
TableRow(children: [
TaskCounter('PRIORITARI', Icons.bolt, colors.orange, board.tasks.prioritized),
TaskCounter('IN SCADENZA', Icons.alarm, colors.red, board.tasks.expiring),
Container(),
]),
TableRow(children: [
TaskCounter('MIEI', Icons.person, theme.accentColor, board.tasks.owned),
TaskCounter('DEL TEAM', Icons.group, theme.accentColor, board.tasks.teamOwned),
TaskCounter('IN AVVIO', Icons.calendar_today, theme.accentColor, board.tasks.starting),
])
]
),
],
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min,
),
),
),
)
)
);
}
}
Hope someone can help me :)

try to use the space smarter. this code will save you from your problems
class BoardWidget extends StatelessWidget {
// final BoardEntity board;
// static const colors = WemaindColors();
// BoardWidget(this.board);
#override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
body: SafeArea(
child: GestureDetector(
// onTap: () {
// Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context)
// {return TasksPage(board: board);
// }));
// },
child:
Container(
height: 300,
width: 400,
child: Card(margin: EdgeInsets.only(top: 0, bottom: 16, left: 16, right: 16),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
Expanded(
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Expanded(
child: Column(mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic,
children: [
Expanded(
child: Text("board.name",
),
),
if (true) Icon(Icons.star, color: Colors.orange),
],
),
),
Expanded(
child: Row(children:[
Expanded(child: Text("board.role.toUpperCase()", overflow: TextOverflow.ellipsis,)),
]),
),
]),
),
Expanded(
child: Column(mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start,children: [
Expanded(
child: Row(mainAxisAlignment: MainAxisAlignment.start, children: [
Expanded(child: Text("board.tasks.all.toString()")),
Icon(Icons.more_vert, color: Colors.blue.shade800, size: 32),
]),
),
Expanded(
child: Row(mainAxisAlignment: MainAxisAlignment.start, children: [
Text('TASK'.toUpperCase()),
]),
)
]),
),
]),
),
Table(
children: [
TableRow(children: [
Container(child: Icon(Icons.bolt)),
Container(child: Icon(Icons.alarm)),
Container(),
]),
TableRow(children: [
Container(child: Icon(Icons.person),),
Container(child: Icon(Icons.group),),
Container(child: Icon(Icons.calendar_today),),
])
]
),
],
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min,
),
),
),
)
),
),
);
}
}

Related

How can I manage alignment with multiple rows and columns?

I'm trying to make a card with some elements.
However it is hard to locate elements in right place with multiple rows and columns.
I tried with mainAxisAlignment, crossAxisAlignment, SizedBox, Expanded and so on.
Especially using Expanded make my widget disappear unlike my expectation.
How can I locate element to right place?
What I did
What I want
child: Container(
padding: EdgeInsets.all(10),
child: Column(
children:[
Text('1'),
Container(
child: Row(
children:[
ClipRRect(
borderRadius: BorderRadius.circular(50),
child: Container(
width: 70,
height: 70,
color: Color(0xffD9D9D9),
),
),
Column(
children:[
Row(
children:[
Text('2'),
Text('3'),
Text('4'),
],
),
Row(
children:[
Text('5'),
Text('6')
]
),
Row(
children:[
Text('7'),
Text('8'),
Text('9'),
Text('10'),
],
),
],
),
],
),
),
],
),
),
Here you go, this should be work as you wanted. i've tried to run it and yep it work
Container(
padding: const EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Text('1'),
Row(
children: [
Flexible(
child: ClipRRect(
borderRadius: BorderRadius.circular(100),
child: Container(
width: 70,
height: 70,
color: const Color(0xffD9D9D9),
),
),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
PaddingText(text: "2"),
PaddingText(text: "3")
],
),
Row(
children: [
PaddingText(text: "4"),
],
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
PaddingText(text: "5"),
PaddingText(text: "6")
],
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
PaddingText(text: "7"),
PaddingText(text: "8")
],
),
Row(
children: [
PaddingText(text: "9"),
PaddingText(text: "10")
],
),
],
),
],
),
),
],
),
],
),
),
and dont forget to add this to your project
class PaddingText extends StatelessWidget {
PaddingText({Key? key, required this.text}) : super(key: key);
String text;
#override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 5.0),
child: Text(text),
);
}
}
This must work
Container(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children:[
Text('1'),
Container(
child: Row(
children:[
ClipRRect(
borderRadius: BorderRadius.circular(50),
child: Container(
width: 70,
height: 70,
color: Color(0xffD9D9D9),
),
),
Expanded(
child: Column(
children:[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children:[
Expanded(
child: Row(
children: [
Text('2'),
Text('3'),
],
),
),
Expanded(child: Row(
children: [
Text('4')
],
)),
],
),
Row(
children:[
Text('5'),
Text('6')
]
),
Row(
children:[
Expanded(child: Row(
children: [
Text('7'),
Text('8'),
],
)),
Expanded(child: Row(
children: [
Text('9'),
Text('10'),
],
))
],
),
],
),
),
],
),
),
],
),
)

Listview inside a row not working in Flutter

I need a listview inside a row.
class Profiles extends StatelessWidget {
const Profiles({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
body: Row(
children: [
SideBar(),
Expanded(
child: ListView(
children: [
Wrap(
children: [
Padding(
padding: const EdgeInsets.only(top: 40.0, left: 45),
child: Container(
width: MediaQuery.of(context).size.width / 1.75,
decoration: BoxDecoration(
border: Border.all(color: Color(0xffEBEBEB)),
color: Color(0xfffbfbfa),
),
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Positioned(
right: 0,
top: 0,
child: Align(
alignment: Alignment.topRight,
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: Text(
"Edit",
),
),
),
),
Row(
mainAxisSize: MainAxisSize.min,
children: [
MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () {
// Get.toNamed('/events',arguments: 0);
},
child: Padding(
padding:
const EdgeInsets.only(top: 0.0),
child: SvgPicture.asset(
allowDrawingOutsideViewBox: true,
Images.avatar,
),
)),
),
SizedBox(
width: 20,
),
Column(
// mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'FirstName',
textAlign: TextAlign.left,
),
SizedBox(
height: 6,
),
Text("Update your role"),
SizedBox(
height: 20,
),
Row(
children: [
Column(
// mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Email',
textAlign: TextAlign.left,
),
SizedBox(
height: 10,
),
Text(
'Organization',
textAlign: TextAlign.left,
),
],
),
SizedBox(
width: 30,
),
Column(
mainAxisSize: MainAxisSize.min,
// mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'email',
textAlign: TextAlign.left,
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
SizedBox(
height: 10,
),
Text(
"NA",
),
],
)
],
)
],
),
],
),
],
)
],
),
),
),
],
)
],
))
],
),
);
}
}
SideBar() is a Column widget having multiple elements. Code of the sidebar is,
class SideBar extends StatefulWidget {
#override
State<SideBar> createState() => _SideBarState();
}
class _SideBarState extends State<SideBar> {
#override
Widget build(BuildContext conText) {
return Material(
elevation: 1,
child: Container(
width: 70,
color: Color(0xFAFAFB),
child: Padding(
padding: const EdgeInsets.only(top: 15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
SvgPicture.asset(
Images.topStoriesIcon,
),
SvgPicture.asset(
Images.topStoriesIcon,
),
SvgPicture.asset(
Images.topStoriesIcon,
)
],
),
],
),
),
),
);
}
}
I got an error: Assertion failed: constraints.hasBoundedWidth is not true.
But listview is working when I wrap with Expanded widget like this,
Row(
children: [
SideBar(),
Expanded(
child: ListView(
shrinkWrap: true,
children: [
],
),
)
],
).
But at that time I got Incorrect ParentWidget error
I tried many ways but didn't get results.
The expected result is attached below,
enter image description here
You can use Positioned widget as Stack child, you dont need to have on Column
child: Stack(
children: [
Positioned( // if needed put it here
top: 0,
right: 0,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Align( /// not here
alignment: Alignment.topRight,
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: Text(
"Edit",
),
),
),
Row(
mainAxisSize: MainAxisSize.min,

Flutter ignoring overflow and wrap settings

I am trying to work out why Flutter is ignoring my overflow and wrap settings on my Text widget
Card(
borderOnForeground: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
side: BorderSide(
color: Colors.grey[200],
width: 1.0,
),
),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
CircleAvatar(
backgroundImage:
widget.user.profileImageUrl.isEmpty
? const AssetImage(
'assets/images/avatar-5.png')
: CachedNetworkImageProvider(
widget.user.profileImageUrl,
)),
const SizedBox(width: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'${widget.user.firstName} ${widget.user.lastName[0]}'),
Text(task.desc,
overflow: TextOverflow.fade,
maxLines: 2,
softWrap: false,
style: Theme.of(context)
.textTheme
.bodyText1),
]),
],
),
Row(children: [
const Icon(Icons.calendar_today_outlined, size: 12),
const SizedBox(width: 6),
Text(DateFormat('E, d MMM').format(task.due),
style: Theme.of(context).textTheme.caption)
]),
]),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
_buildBudget(formatCurrency.format(widget.task.budget))
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(children: [
const Icon(Icons.location_on_outlined, size: 12),
const SizedBox(width: 6),
Text(task.location,
style: Theme.of(context).textTheme.caption)
]),
],
),
Here is a similar question, that might help you:
Flutter - Wrap text on overflow, like insert ellipsis or fade
To achieve the desired effect, you have to tell your text widgets how much space they should take. For example by wrapping your column (the parent of the overflowing text widgets) with a Flexible or Expanded.
I tried to minify your example a little bit to make it more obvious:
class CardWidget extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Card(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: Column(
children: [
// Your other widegts
// Row(children: [ ... ]),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Your circle avatar with a constant size
Container(width: 50, height: 50, color: Colors.red),
const SizedBox(width: 10),
// The important part
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('Firstname Lastname'),
const Text(
'Really long description that does not fit on to the screen',
overflow: TextOverflow.fade,
maxLines: 2),
],
),
),
],
),
// Your other widegts
// Row(children: [ ... ]),
],
),
),
);
}
}
Note that you should remove the softWrap: false. If false, the glyphs in the text will be positioned as if there was unlimited horizontal space.
If the text exceeds 2 lines, the faded overflow effect will be visible. If you do not want that, just remove the maxLines attribute.
Full Example
Here is a full example with a structure, that will work within a ListView assuming location, date and budget widgets should be on the same line:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: ListView(shrinkWrap: true, children: [
CardWidget(),
CardWidget(),
CardWidget(),
]),
);
}
}
class CardWidget extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Card(
borderOnForeground: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
side: BorderSide(
width: 1.0,
),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: Column(
children: [
Row(
children: [
Container(height: 50, width: 50, color: Colors.red),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Firstname Lastname'),
Text(
"Long text that exceeds multiple lines. Long text that exceeds multiple lines. Long text that exceeds multiple lines",
overflow: TextOverflow.fade,
maxLines: 3,
style: Theme.of(context).textTheme.bodyText1),
],
),
),
],
),
const SizedBox(height: 25),
Row(
children: [
// Location and Date
Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(Icons.location_on_outlined, size: 12),
const SizedBox(width: 6),
Text("Location"),
],
),
const SizedBox(width: 25),
Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(Icons.calendar_today_outlined, size: 12),
const SizedBox(width: 6),
Text("Date"),
],
),
// The budget widget
Expanded(child: Container()),
Text("200"),
],
),
],
),
),
);
}
}
Wrap your Column in a Expanded.. should be work
Expanded(child:Column(...))
and try to add Expanded (wrap Row) here too (last line in code):
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child:Row( ////HERE
The Row does not have a specified width. So one of the childs should have an Expanded
ok i have tested... here the full code:
Card(
borderOnForeground: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
side: BorderSide(
color: Colors.grey,
width: 1.0,
),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Row(
children: [
CircleAvatar(backgroundImage: const AssetImage('assets/images/avatar-5.png')),
const SizedBox(width: 10),
Expanded(
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text('${'widget.user.firstName'} '),
Text('task.desc',
overflow: TextOverflow.fade,
maxLines: 2,
softWrap: false,
style: Theme.of(context).textTheme.bodyText1),
]),
),
],
),
),
Row(children: [
const Icon(Icons.calendar_today_outlined, size: 12),
const SizedBox(width: 6),
Text('DateFormat( ).format(task.due)', style: Theme.of(context).textTheme.caption)
]),
]),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [Text('dff')],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(children: [
const Icon(Icons.location_on_outlined, size: 12),
const SizedBox(width: 6),
Text('task.location', style: Theme.of(context).textTheme.caption)
])
],
)
])));
Wrap child of Column with Flexible :
Column(
mainAxisSize : MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Flexible (child :Text(
'${widget.user.firstName} ${widget.user.lastName[0]}')),
Flexible (
child :Text(task.desc,
overflow: TextOverflow.fade,
maxLines: 2,
softWrap: false,
style: Theme.of(context)
.textTheme
.bodyText1)),
]),

How to create a color bar with rows of text in flutter

How do I use flutter to create bar show in the screenshot below?
Row(
children: [
Expanded(
child: SizedBox(
child: Text("CONTACT US",
style: TextStyle(color: Colors.white),
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 30.0),
child: SizedBox(
child: Text("SOCIAL MEDIA", style: TextStyle(color: Colors.white),),
),
)
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 30.0),
child: SizedBox(
child: Text("NEWSLETTER", style: TextStyle(color: Colors.white),),
),
)
),
],
),
you can try with something similar and adjust for your purpose and color:
class Sample extends StatefulWidget {
#override
_SampleState createState() => _SampleState();
}
class _SampleState extends State<Sample> {
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: Text('sample'),
),
body: Container(
height: 200,
width: 2000,
color: Color(0xff808080),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Contact Us'),
Row(children: [
Icon(Icons.phone),
Text('phone')]),
Row(children: [
Icon(Icons.mail),
Text('info#test.it')]),
Row(children: [
Icon(Icons.map_outlined),
Text('unavailable')]),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Contact Us'),
Icon(Icons.wrap_text_rounded),
Icon(Icons.point_of_sale),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Newsletter'),
Text('Susbcribe'),
],
),
],
),
)
);
}
}

[flutter]Why my column alignment is always center?

I declared two columns in a row to layout the text and the icon.
The column for the icon is always center even if I set the mainAxisAlignment with MainAxisAlignment.start.
Here is the code for the card:
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:life_logger/models.dart';
import 'package:life_logger/screens/entry_editor_screen.dart';
import 'package:life_logger/widgets/dot.dart';
Wrap buildActivities(Entry entry) {
var children = <Widget>[];
var idx = 0;
entry.activities.forEach((activity) {
var element = Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
Icon(
activity.iconData,
color: entry.mood.color,
),
SizedBox(
width: 3,
),
Text(
'${activity.description}',
style: TextStyle(color: Colors.grey),
),
]);
children.add(element);
if (idx < entry.activities.length - 1) {
children.add(Dot());
}
idx++;
});
return Wrap(
children: children,
spacing: 5,
crossAxisAlignment: WrapCrossAlignment.center,
);
}
Widget buildEntryRow(Entry entry, BuildContext context) {
var entryRow = GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => EntryEditorScreen(entry)),
);
},
child: Row(
children: <Widget>[
// the column for the icon
Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 8.0, right: 8.0),
child: Icon(
entry.mood.iconData,
color: entry.mood.color,
size: 48,
),
),
],
),
Expanded(
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Baseline(
baseline: 30.0,
baselineType: TextBaseline.alphabetic,
child: Text(
entry.mood.description,
style: TextStyle(
color: entry.mood.color,
fontSize: 24,
),
),
),
Baseline(
baseline: 30.0,
baselineType: TextBaseline.alphabetic,
child: Text(
DateFormat.Hm().format(entry.createdAt),
style: TextStyle(
color: Colors.grey,
fontSize: 16,
),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(child: buildActivities(entry)),
],
),
Row(
children: <Widget>[
Text(
entry.note,
style: TextStyle(
color: Colors.grey,
fontSize: 16,
),
),
],
),
],
),
),
],
));
return entryRow;
}
class EntryCard extends StatefulWidget {
final List<Entry> entries;
EntryCard(this.entries);
#override
_EntryCardState createState() => _EntryCardState();
}
class _EntryCardState extends State<EntryCard> {
#override
Widget build(BuildContext context) {
var dateRow = Container(
height: 30,
decoration: BoxDecoration(
color: widget.entries[0].mood.color.withOpacity(0.5),
borderRadius: BorderRadius.all(Radius.circular(4.0)),
),
child: Row(
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 24.5, right: 24.5),
child: Ring(
size: 5.0,
color: widget.entries[0].mood.color,
),
),
Text(
DateFormat('EEEEE, M月d日').format(widget.entries[0].createdAt),
style: TextStyle(
color: widget.entries[0].mood.color,
fontSize: 14,
),
)
],
));
return Card(
child: Column(
children: <Widget>[dateRow] +
widget.entries.map((entry) => buildEntryRow(entry, context)).toList(),
));
}
}
The actual layout as follow:
Use crossAxisAlignment: CrossAxisAlignment.start
And for future, I would suggest you to add code that is independent of other code so that others can run it and see.
like that for one widget
Container(
child: Align(
alignment: Alignment.centerRight,
child: Text(S.current.forgetPassword),
),
),
or for all
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
If you want you can adjust column according to you .
Here is code of how to call widgets of columns at start.
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
Use it :
Column(
children: const <Widget>[
Align(
alignment: Alignment.centerLeft,
child: Text('Text 1')
),
Align(
alignment: Alignment.centerLeft,
child: Text('Text 2')
),
],
)
Setting the height of the Container worked for me:
height: double.infinity,