Fit a column in expanded or container widget in Flutter - 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,
),
],
),
),
),
);
}
}

Related

How to make one text up and one move down?

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,
)

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,
),
)
]),
),)

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),
),
),
],
),
],
),
);
}

How to Expand and collpase the Container in the flutter

import 'package:flutter/material.dart';
class SoloPage extends StatefulWidget {
#override
_SoloPageState createState() => _SoloPageState();
}
class _SoloPageState extends State<SoloPage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Solo"),
backgroundColor: Colors.blueGrey.shade900,
),
body: SingleChildScrollView(
child: Container(
margin: EdgeInsets.all(10),
height: 220,
width: double.infinity,
child: Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50)
)
),
height: 35,
width: double.infinity,
),
Container(
decoration: BoxDecoration(
color: Colors.blueGrey.shade800,
),
margin: EdgeInsets.only(top: 35),
height: 150,
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Column(
children: <Widget>[
Text("Date",
style: TextStyle(
color: Colors.white,
)),
Text("12/10/20",
style: TextStyle(
color: Colors.white,
)),
],
),
Column(
children: <Widget>[
Text("Time",
style: TextStyle(
color: Colors.white,
)),
Text("12:30 PM",
style: TextStyle(
color: Colors.white,
)),
],
),
Column(
children: <Widget>[
Text("Map",
style: TextStyle(
color: Colors.white,
)),
Text("Erangle",
style: TextStyle(
color: Colors.white,
)),
],
),
Column(
children: <Widget>[
Text("Mode",
style: TextStyle(
color: Colors.white,
)),
Text("TPP",
style: TextStyle(
color: Colors.white,
)),
],
)
],
),
Divider(
color: Colors.white,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Column(
children: <Widget>[
Text("Players Joined",
style: TextStyle(
color: Colors.white,
)),
Text("25",
style: TextStyle(
color: Colors.white,
)),
],
),
Column(
children: <Widget>[
Text("Winning Prizes",
style: TextStyle(
color: Colors.white,
)),
Text(""),
],
),
Column(
children: <Widget>[
Text("Remaining Players",
style: TextStyle(
color: Colors.white,
)),
Text("75",
style: TextStyle(
color: Colors.white,
)),
],
)
],
),
Divider(
color: Colors.white,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Column(
children: <Widget>[
Text("Per Kill",
style: TextStyle(
color: Colors.white,
)),
Text("₹ 10",
style: TextStyle(
color: Colors.white,
)),
],
),
Column(
children: <Widget>[
Text("Entry Fees",
style: TextStyle(
color: Colors.white,
)),
Text("₹ 20",
style: TextStyle(
color: Colors.white,
)),
],
),
],
),
],
),
),
Container(
margin: EdgeInsets.only(top: 185),
height: 35,
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(bottomRight: Radius.circular(50)),
color: Colors.blueGrey.shade900,
),
child: Center(
child: InkWell(
onTap: () {
print("Solo Joined");
},
child: Text(
"Join Contest",
style: TextStyle(
color: Colors.white,
fontSize: 25,
fontFamily: "OpenSans",
fontWeight: FontWeight.bold,
),
),
)),
),
],
),
),
),
);
}
}
I have done the above code to create and design the container and on clicking on the container i want to expand that container and then by clicking on the same text i want to expand that container. There is text Winning Prizes in the container and by clicking on that i want to expand that container.
Image of the container

handling application layout in flutter app

I have Entry page to my app like below, I am getting bottom overflow , image size issue , text font issue, when I run on the phone with less than 5 inches,
If I run the same app on over 5 inches I am getting like below
Can anyone who have worked on developing flutter apps help me on how I can adjust according to the screen?
also How to adjust text size, image size every other things as per the screen size?
below is my code:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
Color colorTheme;
class LoginPage extends StatefulWidget {
#override
_LoginPageState createState() => new _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
TextEditingController controllerEmail = TextEditingController();
TextEditingController controllerPassword = TextEditingController();
String username, password;
Widget loginButtonChild = const Text(
"Log in",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white, fontFamily: "OpenSans-Regular", fontSize: 16),
);
Widget loginButtonWithCircle = Row(
children: <Widget>[
const Text(
"Log in",
style: TextStyle(
color: Colors.white,
fontFamily: "OpenSans-Regular",
),
),
CircularProgressIndicator(),
],
);
#override
Widget build(context) {
double maxHeight = MediaQuery.of(context).size.height;
// ScreenUtil.instance = ScreenUtil.getInstance()..init(context);
return Scaffold(
resizeToAvoidBottomPadding: true,
body: SingleChildScrollView(
child: LimitedBox(
maxHeight: maxHeight * 1,
child: Stack(
//fit: StackFit.expand,
children: <Widget>[
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.05,
left: MediaQuery.of(context).size.width * 0.05),
child: Image.asset('assets/Heat Map.png',
width: 100, height: 20, fit: BoxFit.fill),
)
],
),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(15))),
padding: EdgeInsets.all(
// MediaQuery.of(context).size.width * 0.09,
MediaQuery.of(context).size.width * 0.1,
),
child: Image.asset(
'assets/layer_1_3.png',
// color: Color(0xFFe31735),
// width: 300,
width: MediaQuery.of(context).size.width * 0.72,
// height: 300,
height: MediaQuery.of(context).size.height * 0.5,
fit: BoxFit.contain,
),
),
Positioned(
left: 78.0,
bottom: 10.0,
child: RichText(
text: TextSpan(
text: 'APP',
style: TextStyle(
fontWeight: FontWeight.bold, color: Colors.black),
children: <TextSpan>[
TextSpan(
text: '\nDevelopment',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
),
),
TextSpan(
text: '\nFlutter',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.normal,
),
),
],
),
maxLines: 3,
overflow: TextOverflow.ellipsis,
softWrap: true,
),
),
],
),
SingleChildScrollView(
child: new Container(
padding: const EdgeInsets.fromLTRB(20.0, 0.0, 40.0, 40.0),
child: new Form(
child: new Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 20),
child: Icon(Icons.person_outline,
size: 38, color: Colors.black),
),
SizedBox(width: 10.0),
new Expanded(
child: new TextFormField(
style: TextStyle(color: Colors.black),
controller: controllerEmail,
//cursorColor: , make it yellow later TODO
decoration: new InputDecoration(
labelText: "Username",
enabledBorder: new UnderlineInputBorder(
borderSide: new BorderSide(
color: Colors.red,
))),
keyboardType: TextInputType.text,
),
),
],
),
Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 20),
child: Icon(
Icons.lock_outline,
size: 38,
color: Colors.black,
),
),
SizedBox(width: 10.0),
new Expanded(
child: new TextFormField(
controller: controllerPassword,
style: TextStyle(color: Colors.red),
decoration: new InputDecoration(
labelText: "Password",
enabledBorder: new UnderlineInputBorder(
borderSide: new BorderSide(
color: Colors.red,
))),
obscureText: true,
keyboardType: TextInputType.text,
),
),
],
),
Padding(
padding: EdgeInsets.only(
top: 0,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
FlatButton(
onPressed: () {
},
child: Text(
"Forgot password?",
style: TextStyle(
color: Colors.grey,
fontFamily: "OpenSans-Regular",
),
),
)
],
),
),
SizedBox(
height: MediaQuery.of(context).size.width * 0.04,
),
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius:
new BorderRadius.circular(25.0),
side: BorderSide(color: Colors.red)),
color: Colors.red,
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: EdgeInsets.only(left: 48),
child: loginButtonChild,
),
const SizedBox(
width: 45.0,
height: 45.0,
),
Icon(Icons.arrow_forward,
color: Colors.white),
],
),
onPressed: () {
}),
],
),
),
),
),
],
),
],
),
),
),
);
}
}
You can use SingleChildScrollView to avoid overflow error just wrap your widget with SingleChildScrollView
Example:-
SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height,
child:YourWidget();
)
)