How to make one text up and one move down? - flutter

Design I want:
My current design:
Hello, I would like to ask how to make a text design like the picture that I want. Examples of waiting approval are above and 7 are below waiting approval. Can anyone help me?
This is my code:
Container(
height: 100,
width: 900,
alignment: Alignment.centerRight,
decoration: BoxDecoration(
border: Border.all(
color: Colors.transparent,
width: 1.0,
),
),
child: Expanded(
child: Text('Waiting Approval 7',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.bold,
color: Colors.black),
textAlign: TextAlign.center),
),
),

Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Waiting Approval', style: TextStyle(fontSize: 16),),
Text('7', style: TextStyle(fontSize: 16),)
],
),

Here you go
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container( decoration: BoxDecoration(
border: Border.all(color: Colors.grey,width: 0.5)),
child: Row(
children: [
Expanded(
child: Container(
padding: const EdgeInsets.all(10),
decoration: const BoxDecoration(
border: Border(right: BorderSide(color: Colors.grey,width: 0.5))),
child: Column(children: const [
Text(
"Waiting Approval",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
),
),
SizedBox(height: 10.0),
Text(
"7",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20,
),
),
]),
),
),
Container(
color: Colors.red,
),
Expanded(
child: Container(
padding: const EdgeInsets.all(10),
decoration: const BoxDecoration(
border: Border(left: BorderSide(color: Colors.grey,width: 0.5))),
child: Column(children: const [
Text(
"Upcoming Appointments",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15,
),
),
SizedBox(height: 10.0),
Text(
"7",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20,
),
),
]),
),
),
],
),
),
],
));
}

Use a Column widget for with two Text widget.
Container(
height: 100,
width: 900,
alignment: Alignment.centerRight,
decoration: BoxDecoration(
border: Border.all(
color: Colors.transparent,
width: 1.0,
),
),
child: Column(
children: [
Text('Waiting Approval',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.bold,
color: Colors.black),
textAlign: TextAlign.center),
Text("7"),//second text, if you need space wrap with padding or include another sizedBox at top
],
),
),

if you want to have numbers under text your could add them in a separate widgets, Or use RichText instead.
for example you could use a function that takes in parameters text and number and generate a widget like: (Columnwith two childrens; text and number; bellow each others).
Then use that function twice in a row.

Use List Tile or use column
child: ListTile(
title: Text("aaaaa"),
subtitle: Text("111111"),
)
or
Column(
children:[
Text(""),
Text(""),
]
)

You can use
Column
use '\n ' with String interpolation
consider int itemCount carries the number,
1.
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('Waiting Approval'),
Text(itemNumber),
]
)
2. '\n ' with String interpolation
Text(
'Waiting for Approval \n ${itemCount}',
textAlign: TextAlign.center,
)

Related

how to implement textfield inside tile flutter

hi i need to design this page
but i'm new in flutter so i'm face difficult to manage to do it
here is my try
Container (
child: Column (
children: <Widget> [
Container(
margin: EdgeInsets.all(20),
child: Text(
"Source Account",
style: TextStyle(fontSize: 30,
color: Color(0xff8aa1ba)),
),
),
Container(
height: 100,
child: Card(
color: Color(0xff343b4b),
clipBehavior: Clip.antiAlias,
elevation: 10,
margin: EdgeInsets.all(7),
child: Column(
children: <Widget>[
ListTile(
title: Text("Main Account 123456",
style: TextStyle(
color: Colors.white,
fontSize: 15, fontWeight: FontWeight.bold),textAlign: TextAlign.left,),
subtitle: Text(" Available Balance \n 10.000.9 KWD" ,
style: TextStyle(
color: Colors.white,
fontSize: 15, fontWeight: FontWeight.bold),textAlign: TextAlign.right,),
),
],
),
),
),
],
),
)
so can any one help me to implement this or give me an idea of how to implement a textfield inside a list tile or card
Put a Row inside of your title. So replace the your code with something like this:
ListTile(
title: Row(
children: <Widget>[
Expanded(
child: TextField(
// your TextField's Content
),
),
],
),
Card(color: Colors.grey, child: Container(
padding: EdgeInsets.symmetric(vertical: 4, horizontal: 8), child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Loans", style: TextStyle(color: Colors.white, fontWeight: FontWeight.w500,),),
Column(children: [
Icon(Icons.add),
Text("Amount", style: TextStyle(color: Colors.white,),)
])
]
),
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
borderRadius: BorderRadius.circular(2),
),
padding: EdgeInsets.symmetric(horizontal: 16),
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
),
style: TextStyle(color: Colors.white),
textAlign: TextAlign.end,
),
)
]),
),)

Flutter widget second row consume remaining space

I am fairly new to flutter, many things I don't understand yet. I have tried many things and I can't get what I want yet. Any suggestions would be helpful.
Widget build(BuildContext context) {
return Column(children: [
Expanded(
child: Container(
// make the full container the amber color
color: Colors.amber[600],
child: Column(children: [
Row(children: [
Expanded(
child: Text(
windowName,
style: TextStyle(
backgroundColor: Colors.blueGrey[200],
fontSize: 24,
fontWeight: FontWeight.bold),
),
),
IconButton(
onPressed: onCurrentDelete,
icon: Icon(Icons.delete_outline, size: 32)),
]),
//IntrinsicHeight(
// child:
Row(
//crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: Container(
// make the left container blue
color: Colors.blue[600],
//constraints: BoxConstraints.expand(),
//decoration: BoxDecoration(
// border: Border.all(
// width: 2,
//)),
child: Text(
startTime,
style: TextStyle(
backgroundColor: Colors.blueGrey[200],
fontSize: 16,
fontWeight: FontWeight.normal),
)),
),
Expanded(
child: Container(
// make the right container green
color: Colors.green[600],
//decoration: BoxDecoration(
// border: Border.all(
// width: 2,
//)),
child: Text(
endTime,
style: TextStyle(
backgroundColor: Colors.blueGrey[200],
fontSize: 16,
fontWeight: FontWeight.normal),
)),
)
],
),
//),
]),
),
)
]);
What I want is the two containers in the last row to take up the remaining space. I have used color attribute to show the size of specific widgets.
The blue and green containers need to fill the to the bottom of the amber section.
I have tried many alternatives and each time the widget generates a fault when it is rendered.
I hope this is what you are looking for:
Image
Code:
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Column(children: [
Expanded(
child: Container(
// make the full container the amber color
color: Colors.amber[600],
child: Column(children: [
Row(children: [
Expanded(
child: Text(
"windowName",
style: TextStyle(
backgroundColor: Colors.blueGrey[200],
fontSize: 24,
fontWeight: FontWeight.bold),
),
),
IconButton(
onPressed: () {},
icon: Icon(Icons.delete_outline, size: 32)),
]),
//IntrinsicHeight(
// child:
Row(
//crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
// make the left container blue
color: Colors.blue[600],
//constraints: BoxConstraints.expand(),
//decoration: BoxDecoration(
// border: Border.all(
// width: 2,
//)),
child: Text(
"startTime",
style: TextStyle(
backgroundColor: Colors.blueGrey[200],
fontSize: 16,
fontWeight: FontWeight.normal),
)),
SizedBox(
width: MediaQuery.of(context).size.width * 0.4,
),
Container(
// make the right container green
color: Colors.green[600],
//decoration: BoxDecoration(
// border: Border.all(
// width: 2,
//)),
child: Text(
"endTime",
style: TextStyle(
backgroundColor: Colors.blueGrey[200],
fontSize: 16,
fontWeight: FontWeight.normal),
))
],
),
//),
]),
),
)
]),
),
);
}
I added height (300) to green and blue containers. and it works fine.
code:
Column(children: [
Expanded(
child: Container(
// make the full container the amber color
color: Colors.amber[600],
child: Column(mainAxisSize: MainAxisSize.max, children: [
Row(children: [
Expanded(
child: Text(
'windowName',
style: TextStyle(
backgroundColor: Colors.blueGrey[200],
fontSize: 24,
fontWeight: FontWeight.bold),
),
),
IconButton(
onPressed: () {}, icon: Icon(Icons.delete_outline, size: 32)),
]),
//IntrinsicHeight(
// child:
Row(
//crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: Container(
height: 300,
// make the left container blue
color: Colors.blue[600],
//constraints: BoxConstraints.expand(),
//decoration: BoxDecoration(
// border: Border.all(
// width: 2,
//)),
child: Text(
'startTime',
style: TextStyle(
backgroundColor: Colors.blueGrey[200],
fontSize: 16,
fontWeight: FontWeight.normal),
)),
),
Expanded(
child: Container(
height: 300,
// make the right container green
color: Colors.green[600],
//decoration: BoxDecoration(
// border: Border.all(
// width: 2,
//)),
child: Text(
'endTime',
style: TextStyle(
backgroundColor: Colors.blueGrey[200],
fontSize: 16,
fontWeight: FontWeight.normal),
)),
)
],
),
//),
]),
),
)
])

How to set same alignment for these two text

How do I make the second text align with the first text. Excerpt of the code is below
Padding(
padding: EdgeInsets.only(top: 20, bottom: 20, left: 10),
child: Column(
children: [
Container(
child: Text(
document.data()['Product Title'],
style: TextStyle(
color: Colors.black
),
),
),
SizedBox(height: 10,),
Container(
child: Text(
document.data()['Product Price'],
style: TextStyle(
color: Colors.black,
),
),
),
Container(
decoration: BoxDecoration(
color: Palette.mainColor,
borderRadius: BorderRadius.circular(8)
),
),
],
),
),
This is how it is at the moment
set the column crossAxisAlignment: CrossAxisAlignment.start
Set CrossAxisAlignment property to Column Widget.
Your Column Widget Should be like this after applying this property.
Column(
crossAxisAlignment: CrossAxisAlignment.start
children: [
Container(
child: Text(
document.data()['Product Title'],
style: TextStyle(
color: Colors.black
),
),
),
SizedBox(height: 10,),
Container(
child: Text(
document.data()['Product Price'],
style: TextStyle(
color: Colors.black,
),
),
),
],
),
Add alignment property to your container.
alignment: Alignment.centerLeft,
Edit:
Ok, I got the problem. #M.M.Hasibuzzaman is right. You need to add crossAxisAlignment: CrossAxisAlignment.start. The correct solution with full code:
Widget build(BuildContext context) {
return Scaffold(
body: Row(
children: [
Column(
children: [
Container(
width: 80,
height: 80,
alignment: Alignment.centerLeft,
child: Image.network(
'https://cdn.friendlystock.com/wp-content/uploads/2020/06/2-loud-speaker-cartoon-clipart.jpg',
)),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
"Loud Speaker",
// textAlign: TextAlign.start,
style: TextStyle(color: Colors.black),
),
],
),
SizedBox(
height: 10,
),
Row(
children: [
Text(
"GHS6758",
textAlign: TextAlign.start,
style: TextStyle(
color: Colors.black,
),
),
],
),
Container(
decoration: BoxDecoration(
color: Colors.red, //Palette.mainColor,
borderRadius: BorderRadius.circular(8),
),
),
],
),
],
),
);
}

Fit a column in expanded or container widget in Flutter

I am using innerDrawer in my profilePage. I put a column in scaffold and added widgets inside. One of these widgets is SignedContracts and this widget has an Expanded widget with a column inside. I want to fit or fill this column in expanded or container widget like second picture. I try lots of things but I did not find any solution.
Note: The red borders in the first picture to see the borders of the containers.
I made this:
But I want like this:
Scaffold part:
scaffold: Scaffold(
body: Container(
child: Column(
children: [
SizedBox(
height: 20,
),
Stack(
children: [
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.red, width: 2),
),
child: Image.network(
"${firestoreDB.user.photoURL}",
width: 500,
height: 250,
fit: BoxFit.fill,
),
),
Positioned(
child: IconButton(
icon: Icon(Icons.menu),
onPressed: () {
_toggle();
},
),
),
Positioned(
child: Text(
"${_user.name}",
style: TextStyle(color: Colors.white, fontSize: 20.0),
),
bottom: 50,
left: 50,
),
Positioned(
child: Text(
"${_user.desc}",
style: TextStyle(color: Colors.white, fontSize: 15.0),
),
bottom: 30,
left: 50,
),
],
),
MiddleCounts(lastWeekListen, lastWeekStream,sL),
Row(),
SignedContracts(),
],
),
),
),
SignedContracts widget:
class SignedContracts extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Expanded(
child: Container(
decoration:
BoxDecoration(border: Border.all(color: Colors.red, width: 2)),
alignment: Alignment.centerLeft,
//height: 500,
padding: EdgeInsets.all(30),
//color: Colors.black,
child: Container(
decoration:
BoxDecoration(border: Border.all(color: Colors.red, width: 2)),
child: Column(
//crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
Text(
"Signed Contracts",
style: TextStyle(color: Colors.white, fontSize: 30.0),
),
SizedBox(
height: 20,
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
"Multiple Rights Agreement",
style: TextStyle(color: Colors.grey),
),
Text(
"Sound Recording Licence",
style: TextStyle(color: Colors.grey),
),
Text(
"Merchandising Agreement",
style: TextStyle(color: Colors.grey),
),
Text(
"Synchronisation Licence",
style: TextStyle(color: Colors.grey),
),
Text(
"Artist Development Agreement",
style: TextStyle(color: Colors.grey),
),
Text(
"Management Agreement",
style: TextStyle(color: Colors.grey),
),
],
),
FlatButton(
onPressed: () {},
child: Text(
"Manage Contracts",
style: TextStyle(color: Colors.white),
),
color: Colors.red,
),
],
),
),
),
);
}
}
You can wrap your second Column in SignedContracts class with Expanded widget like code below:
class SignedContracts extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Expanded(
child: Container(
decoration:
BoxDecoration(border: Border.all(color: Colors.red, width: 2)),
alignment: Alignment.centerLeft,
//height: 500,
padding: EdgeInsets.all(30),
//color: Colors.black,
child: Container(
decoration:
BoxDecoration(border: Border.all(color: Colors.red, width: 2)),
child: Column(
//crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
// mainAxisSize: MainAxisSize.max,
children: [
Text(
"Signed Contracts",
style: TextStyle(color: Colors.white, fontSize: 30.0),
),
SizedBox(
height: 20,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
"Multiple Rights Agreement",
style: TextStyle(color: Colors.grey),
),
Text(
"Sound Recording Licence",
style: TextStyle(color: Colors.grey),
),
Text(
"Merchandising Agreement",
style: TextStyle(color: Colors.grey),
),
Text(
"Synchronisation Licence",
style: TextStyle(color: Colors.grey),
),
Text(
"Artist Development Agreement",
style: TextStyle(color: Colors.grey),
),
Text(
"Management Agreement",
style: TextStyle(color: Colors.grey),
),
],
),
),
FlatButton(
onPressed: () {},
child: Text(
"Manage Contracts",
style: TextStyle(color: Colors.white),
),
color: Colors.red,
),
],
),
),
),
);
}
}

Container fill width of Column

I have a row inside this a column, column children are a two text, first text widget I put inside a container, I want the container background fill dull width of column. but the background only seen in where the text are present, left and right are empty,
here is my code
Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
_bookingData.bookingData[index].paymentStatusFe =="Paid" ?
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.deepPurpleAccent)
),
child:
Column(
children: <Widget>[
Container(
child: Text("Paid"),
color: Colors.red,
),
Padding(
padding: const EdgeInsets.all(2.0),
child: Text(
'AED' +
' ' +
_bookingData
.bookingData[
index]
.amount
.toString(),
style: TextStyle(
fontSize:
12,
fontFamily:
'Roboto Condensed',
color: Colors.deepPurpleAccent,
fontWeight:
FontWeight
.w600),
),
)
],
),
): Container(
// width: double.infinity,
decoration: BoxDecoration(
border: Border.all(color: Colors.red)
),
child:
Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
"Not Paid",
style: TextStyle(
backgroundColor: Colors.red,
color: Colors.white
),
),
Padding(
padding: const EdgeInsets.all(2.0),
child: Text(
'AED' +
' ' +
_bookingData
.bookingData[
index]
.amount
.toString(),
style: TextStyle(
fontSize:
12,
fontFamily:
'Roboto Condensed',
color: Colors.red,
fontWeight:
FontWeight
.w600),
),
)
],
),
),
],
),
Row is put inside a Listview. So I want to have red in background for paid text, but red is only coming start of paid and till where it ends, not the entire column.
You have to do two changes in your code
1) Add your root container in within expanded widget
2) In your inner container set width:double.infinity
Row(mainAxisSize: MainAxisSize.max, children: <Widget>[
// first change
Expanded(
flex: 1,
child: Container(
decoration:
BoxDecoration(border: Border.all(color: Colors.deepPurpleAccent)),
child: Column(
children: <Widget>[
Container(
//second change
width: double.infinity,
child: Text("Paid"),
color: Colors.red,
),
Padding(
padding: const EdgeInsets.all(2.0),
child: Text(
'AED TEST',
style: TextStyle(
fontSize: 12,
fontFamily: 'Roboto Condensed',
color: Colors.deepPurpleAccent,
fontWeight: FontWeight.w600),
),
)
],
)),
),
]);