I am making alert notification and I want the container to be wrapped around it content. Was not able to give left border to the rounded container to had to make another container that will be matching the height of the parent container. Now if i give height to the parent container this doesn't seems to be a good approach as the text inside the container might vary... I want the container to automatically detect the height necessary for the nice appearance and widgets inside it do not overlap or exceed
Container(
width: double.infinity,
height: 80.0,
padding: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.inversePrimary,
borderRadius: BorderRadius.all(Radius.circular(10.0)),
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.primary,
spreadRadius: 0,
blurRadius: 1,
offset: const Offset(0, 1)
), // no shadow color set, defaults to black
]
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Container(
width: 8,
padding: EdgeInsets.all(0.0),
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(topLeft: Radius.circular(10.0),bottomLeft:Radius.circular(10.0) ),
color: buildMaterialColor(const Color(0xFF70AD47)),
),
),
),
Expanded(
flex: 40,
child: Container(
padding:EdgeInsets.all(8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children:[
Expanded(
flex: 1,
child: Text(
textAlign: TextAlign.end,
String.fromCharCode( CupertinoIcons.check_mark_circled.codePoint),
style: TextStyle(
inherit: false,
color: buildMaterialColor(const Color(0xFF70AD47)).shade400,
fontSize: 40.0,
fontFamily: CupertinoIcons.check_mark_circled.fontFamily,
package: CupertinoIcons.check_mark_circled.fontPackage,
),
),
),
Expanded(
flex:5,
child: Container(
padding: EdgeInsets.only(left:10.0,right: 0.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Success",
style: TextStyle(
inherit: false,
color: buildMaterialColor(const Color(0xFF70AD47)).shade400,
fontSize: 16.0,
),
),
Text(
"lorem ipsum de feacto de jure lorem ipsum de feacto de jure",
style: TextStyle(
overflow: TextOverflow.clip,
inherit: false,
color: Theme.of(context).colorScheme.onPrimaryContainer,
fontSize: 14.0,
),
),
],
)
),
),
]
),
),
),
Expanded(
flex: 5,
child: Container(
child: IconButton(
onPressed: (){},
icon: Icon(
Icons.close_rounded,
color: buildMaterialColor(const Color(0xFF70AD47)).shade400,
size: 16.0,
),
),
),
)
],
)
),
try this
ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
child:Container(
width: double.infinity,
height: 80.0,
padding: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
decoration: BoxDecoration(
color: Colors.black,
border: Border(
left: BorderSide(
color: Theme.of(context).colorScheme.primary,
width: 10,
),
top: BorderSide.none,
right: BorderSide.none,
bottom: BorderSide.none,
),
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.primary,
spreadRadius: 0,
blurRadius: 1,
offset: const Offset(0, 1),
), // no shadow color set, defaults to black
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 40,
child: Container(
padding: EdgeInsets.all(8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
CupertinoIcons.check_mark_circled,
color:
(const Color(0xFF70AD47)).withAlpha(400),
size: 40.0,
),
Expanded(
// flex: 5,
child: Container(
padding: EdgeInsets.only(
left: 10.0, right: 0.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
"Success",
style: TextStyle(
inherit: false,
color: (const Color(0xFF70AD47))
.withAlpha(400),
fontSize: 16.0,
),
),
Expanded(
child: Text(
"lorem ipsum de feacto de jure lorem ipsum de feacto de jure lorem ipsum de feacto de jure lorem ipsum de feacto de jure lorem ipsum de feacto de jure lorem ipsum de feacto de jure",
style: TextStyle(
overflow: TextOverflow.clip,
inherit: false,
color: Theme.of(context)
.colorScheme
.onPrimaryContainer,
fontSize: 14.0,
),
),
),
],
)),
),
],
),
),
),
Expanded(
flex: 5,
child: Container(
child: IconButton(
onPressed: () {},
icon: Icon(
Icons.close_rounded,
color: (const Color(0xFF70AD47)).withAlpha(200),
size: 16.0,
),
),
),
)
],
)),
)
and you get results like this i tripled the text and checkout the result also i removed container for border and created the left border with border property of container :
EDIT:
try this code in this the container will grow according to the text:
ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
child: Container(
width: double.infinity,
// height: 80.0,
padding: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
decoration: BoxDecoration(
color: Colors.black,
border: Border(
left: BorderSide(
color: Theme.of(context).colorScheme.primary,
width: 10,
),
top: BorderSide.none,
right: BorderSide.none,
bottom: BorderSide.none,
),
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.primary,
spreadRadius: 0,
blurRadius: 1,
offset: const Offset(0, 1),
), // no shadow color set, defaults to black
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 40,
child: Container(
padding: EdgeInsets.all(8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
CupertinoIcons.check_mark_circled,
color:
(const Color(0xFF70AD47)).withAlpha(400),
size: 40.0,
),
Expanded(
// flex: 5,
child: Container(
padding:
EdgeInsets.only(left: 10.0, right: 0.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Success",
style: TextStyle(
inherit: false,
color: (const Color(0xFF70AD47))
.withAlpha(400),
fontSize: 16.0,
),
),
Text(
"lorem ipsum de feacto de jure lorem ipsum de feacto de jure lorem ipsum de feacto de jure lorem ipsum de feacto de jure lorem ipsum de feacto de jure lorem ipsum de feacto de jure lorem ipsum de feacto de jure lorem ipsum de feacto de jure lorem ipsum de feacto de jure lorem ipsum de feacto de jure lorem ipsum de feacto de jure lorem ipsum de feacto de jure",
style: TextStyle(
overflow: TextOverflow.fade,
inherit: false,
color: Theme.of(context)
.colorScheme
.onPrimaryContainer,
fontSize: 14.0,
),
),
],
),
),
),
],
),
),
),
Expanded(
flex: 5,
child: Container(
child: IconButton(
onPressed: () {},
icon: Icon(
Icons.close_rounded,
color: (const Color(0xFF70AD47)).withAlpha(200),
size: 16.0,
),
),
),
)
],
)),
)
this is the result:
you can remove the height property and wrap the parent Container widget with an Expanded widget.it should look like this:
i hope this helps.
Expanded(
child: Container( width: double.infinity,
padding: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.inversePrimary,
borderRadius: BorderRadius.all(Radius.circular(10.0)),
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.primary,
spreadRadius: 0,
blurRadius: 1,
offset: const Offset(0, 1)
), // no shadow color set, defaults to black
]
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Container(
width: 8,
padding: EdgeInsets.all(0.0),
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(topLeft: Radius.circular(10.0),bottomLeft:Radius.circular(10.0) ),
color: buildMaterialColor(const Color(0xFF70AD47)),
),
),
),
Expanded(
flex: 40,
child: Container(
padding:EdgeInsets.all(8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children:[
Expanded(
flex: 1,
child: Text(
textAlign: TextAlign.end,
String.fromCharCode( CupertinoIcons.check_mark_circled.codePoint),
style: TextStyle(
inherit: false,
color: buildMaterialColor(const Color(0xFF70AD47)).shade400,
fontSize: 40.0,
fontFamily: CupertinoIcons.check_mark_circled.fontFamily,
package: CupertinoIcons.check_mark_circled.fontPackage,
),
),
),
Expanded(
flex:5,
child: Container(
padding: EdgeInsets.only(left:10.0,right: 0.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Success",
style: TextStyle(
inherit: false,
color: buildMaterialColor(const Color(0xFF70AD47)).shade400,
fontSize: 16.0,
),
),
Text(
"lorem ipsum de feacto de jure lorem ipsum de feacto de jure",
style: TextStyle(
overflow: TextOverflow.clip,
inherit: false,
color: Theme.of(context).colorScheme.onPrimaryContainer,
fontSize: 14.0,
),
),
],
)
),
),
]
),
),
),
Expanded(
flex: 5,
child: Container(
child: IconButton(
onPressed: (){},
icon: Icon(
Icons.close_rounded,
color: buildMaterialColor(const Color(0xFF70AD47)).shade400,
size: 16.0,
),
),
),
)
],
)),
)
Think you item build like, no need to provide flex. Use expanded to available spaces.
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildLeft(context),
Expanded(child: buildMiddle(context)),
/// take
buildRightCloseIcon(),
],
),
Test widget.
class FAs23 extends StatefulWidget {
const FAs23({super.key});
#override
State<FAs23> createState() => _FAs23State();
}
class _FAs23State extends State<FAs23> {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
SizedBox(
height: 200,
),
Container(
width: double.infinity,
height: 80.0,
padding: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.inversePrimary,
borderRadius: BorderRadius.all(Radius.circular(10.0)),
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.primary,
spreadRadius: 0,
blurRadius: 1,
offset: const Offset(
0, 1)), // no shadow color set, defaults to black
]),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildLeft(context),
Expanded(child: buildMiddle(context)),
/// take
buildRightCloseIcon(),
],
),
),
],
),
),
);
}
Container buildRightCloseIcon() {
return Container(
child: IconButton(
onPressed: () {},
icon: Icon(
Icons.close_rounded,
color: const Color(0xFF70AD47),
size: 16.0,
),
),
);
}
Container buildMiddle(BuildContext context) {
return Container(
padding: EdgeInsets.all(8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
textAlign: TextAlign.end,
String.fromCharCode(CupertinoIcons.check_mark_circled.codePoint),
style: TextStyle(
inherit: false,
color: const Color(0xFF70AD47),
fontSize: 40.0,
fontFamily: CupertinoIcons.check_mark_circled.fontFamily,
package: CupertinoIcons.check_mark_circled.fontPackage,
),
),
Expanded(
child: Container(
padding: const EdgeInsets.only(left: 10.0, right: 0.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
"Success",
style: TextStyle(
inherit: false,
color: Color(0xFF70AD47),
fontSize: 16.0,
),
),
Text(
"lorem ipsum de feacto de jure lorem ipsum de feacto de jure",
style: TextStyle(
overflow: TextOverflow.clip,
inherit: false,
color:
Theme.of(context).colorScheme.onPrimaryContainer,
fontSize: 14.0,
),
),
],
)),
),
]),
);
}
Container buildLeft(BuildContext context) {
return Container(
width: 8,
// height: double.infinity,// will get parent height
padding: const EdgeInsets.all(0.0),
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10.0), bottomLeft: Radius.circular(10.0)),
color: Color(0xFF70AD47),
),
);
}
}
Please remove MediaQuery.of(context).size.height
Expanded(
flex: 1,
child: Container(
width: 8,
padding: EdgeInsets.all(0.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(topLeft: Radius.circular(10.0),bottomLeft:Radius.circular(10.0) ),
color: buildMaterialColor(const Color(0xFF70AD47)),
),
Rest are
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.inversePrimary,
borderRadius: const BorderRadius.all(Radius.circular(10.0)),
boxShadow: [
BoxShadow(
color: Theme.of(context).colorScheme.primary,
blurRadius: 1,
offset: const Offset(0, 1)),
]),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 8,
padding: const EdgeInsets.all(0.0),
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10.0),
bottomLeft: Radius.circular(10.0)),
color: Color(0xFF70AD47),
),
child: const SizedBox(height: 100),
),
Expanded(
child: Column(
children: const [
Text(
"Success",
style: TextStyle(
inherit: false,
color: Color(0xFF70AD47),
fontSize: 16.0,
),
),
Text(
"lorem ipsum de feacto de jure lorem ipsum de feacto de jure",
style: TextStyle(
overflow: TextOverflow.clip,
inherit: false,
fontSize: 14.0,
),
),
],
),
),
IconButton(
onPressed: () {},
icon: const Icon(
Icons.close_rounded,
color: Color(0xFF70AD47),
size: 16.0,
),
)
],
),
),
Related
I was trying to create an app with Flutter and Dart and I was wondering if there was a way to go newline if a container inside a row overflows.
Here's an example, the thing I want to do is to make the "button" go newline if it intersects into another one to make it more readable.
I hope someone can help me, I will link the code also for a better understanding.
Padding(
padding: EdgeInsets.fromLTRB(0, MediaQuery.of(context).size.height/40, 0, 0),
child: Column(
children: [
Row( //I tre bottoni di 'Like', 'Commenta' e 'Condividi'
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container( //Like button
width: MediaQuery.of(context).size.width/4,
height: MediaQuery.of(context).size.height/15,
decoration: const BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.all(Radius.circular(20)),
boxShadow: [
BoxShadow(
color: Colors.blue,
spreadRadius: 5,
blurRadius: 20,
)
]
),
child: Row( //Contenuto del container, 'child:' perché è il figlio del container
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [ //'Children:[]' perché contiene più elementi
Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 5, 0),
child: Icon(
Icons.thumb_up, color: Colors.white,
size: MediaQuery.of(context).size.height/40,
),
),
Center(
child: Text('Like',
overflow: TextOverflow.fade,
style: TextStyle(
fontSize: MediaQuery.of(context).size.height/40,
fontFamily: 'Poppins',
color: Colors.white,
),
),
),
],
),
),
Padding(
padding: EdgeInsets.fromLTRB(MediaQuery.of(context).size.width/40, 0, MediaQuery.of(context).size.width/40, 0),
child: Container( //Comment button
width: MediaQuery.of(context).size.width/4,
height: MediaQuery.of(context).size.height/15,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
color: Colors.green,
boxShadow: [
BoxShadow(
color: Colors.green,
spreadRadius: 5,
blurRadius: 20,
)
]
),
child: Row( //Contenuto del secondo bottone (quello centrale)
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(30, 0, 5, 0),
child: Icon(
Icons.message, color: Colors.white,
size: MediaQuery.of(context).size.height/40,
),
),
Text('Commenta',
overflow: TextOverflow.clip,
style: TextStyle(
fontSize: MediaQuery.of(context).size.height/40,
fontFamily: 'Poppins',
color: Colors.white,
),
),
],),
),
),
Container( //Share post button
width: MediaQuery.of(context).size.width/4,
height: MediaQuery.of(context).size.height/15,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
color: Colors.red,
boxShadow: [ //Parentesi quadre perché può contenere più proprietà, è perciò una lista
BoxShadow(
color: Colors.red,
spreadRadius: 5,
blurRadius: 20,
)
]
),
child: Row( //Contenuto del container
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 5, 0),
child: Icon(
Icons.share, color: Colors.white,
size: MediaQuery.of(context).size.height/40,
),
),
Text('Condividi',
style: TextStyle(
fontSize: MediaQuery.of(context).size.height/40,
fontFamily: 'Poppins',
color: Colors.white,
),
)
]
)
),
],
),
],
),
)
],),
Method1: You have to use Flexible widget to avoid overflow.
Padding(
padding: EdgeInsets.fromLTRB(0, MediaQuery.of(context).size.height/40, 0, 0),
child: Column(
children: [
Row( //I tre bottoni di 'Like', 'Commenta' e 'Condividi'
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container( //Like button
width: MediaQuery.of(context).size.width/4,
height: MediaQuery.of(context).size.height/15,
decoration: const BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.all(Radius.circular(20)),
boxShadow: [
BoxShadow(
color: Colors.blue,
spreadRadius: 5,
blurRadius: 20,
)
]
),
child: Row( //Contenuto del container, 'child:' perché è il figlio del container
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [ //'Children:[]' perché contiene più elementi
Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 5, 0),
child: Icon(
Icons.thumb_up, color: Colors.white,
size: MediaQuery.of(context).size.height/40,
),
),
Flexible(
child: Center(
child: Text('Like',
overflow: TextOverflow.fade,
style: TextStyle(
fontSize: MediaQuery.of(context).size.height/40,
fontFamily: 'Poppins',
color: Colors.white,
),
),
),
),
],
),
),
Padding(
padding: EdgeInsets.fromLTRB(MediaQuery.of(context).size.width/40, 0, MediaQuery.of(context).size.width/40, 0),
child: Container( //Comment button
width: MediaQuery.of(context).size.width/4,
height: MediaQuery.of(context).size.height/15,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
color: Colors.green,
boxShadow: [
BoxShadow(
color: Colors.green,
spreadRadius: 5,
blurRadius: 20,
)
]
),
child: Row( //Contenuto del secondo bottone (quello centrale)
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(30, 0, 5, 0),
child: Icon(
Icons.message, color: Colors.white,
size: MediaQuery.of(context).size.height/40,
),
),
Flexible(
child: Text('Commenta',
overflow: TextOverflow.clip,
style: TextStyle(
fontSize: MediaQuery.of(context).size.height/40,
fontFamily: 'Poppins',
color: Colors.white,
),
),
),
],),
),
),
Container( //Share post button
width: MediaQuery.of(context).size.width/4,
height: MediaQuery.of(context).size.height/15,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
color: Colors.red,
boxShadow: [ //Parentesi quadre perché può contenere più proprietà, è perciò una lista
BoxShadow(
color: Colors.red,
spreadRadius: 5,
blurRadius: 20,
)
]
),
child: Row( //Contenuto del container
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 5, 0),
child: Icon(
Icons.share, color: Colors.white,
size: MediaQuery.of(context).size.height/40,
),
),
Flexible(
child: Text('Condividi',
style: TextStyle(
fontSize: MediaQuery.of(context).size.height/40,
fontFamily: 'Poppins',
color: Colors.white,
),
),
)
]
)
),
],
),
],
),
)
Edited
Method 2:
Padding(
padding: EdgeInsets.fromLTRB(0, MediaQuery.of(context).size.height / 40, 0, 0),
child: Column(
children: [
Row(
//I tre bottoni di 'Like', 'Commenta' e 'Condividi'
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Container(
//Like button
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(10),
decoration: const BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.all(Radius.circular(20)),
boxShadow: [
BoxShadow(
color: Colors.blue,
spreadRadius: 5,
blurRadius: 20,
)
]),
child: Row(
//Contenuto del container, 'child:' perché è il figlio del container
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
//'Children:[]' perché contiene più elementi
Padding(
padding: const EdgeInsets.only(right: 5),
child: Icon(
Icons.thumb_up,
color: Colors.white,
size: MediaQuery.of(context).size.height / 40,
),
),
Flexible(
child: Center(
child: Text(
'Like',
overflow: TextOverflow.fade,
style: TextStyle(
fontSize: MediaQuery.of(context).size.height / 40,
fontFamily: 'Poppins',
color: Colors.white,
),
),
),
),
],
),
),
),
Expanded(
child: Container(
//Comment button
padding: EdgeInsets.all(10),
margin: EdgeInsets.all(10),
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
color: Colors.green,
boxShadow: [
BoxShadow(
color: Colors.green,
spreadRadius: 5,
blurRadius: 20,
)
]),
child: Row(
//Contenuto del secondo bottone (quello centrale)
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(right: 5),
child: Icon(
Icons.message,
color: Colors.white,
size: MediaQuery.of(context).size.height / 40,
),
),
Flexible(
child: Text(
'Commenta',
overflow: TextOverflow.clip,
style: TextStyle(
fontSize: MediaQuery.of(context).size.height / 40,
fontFamily: 'Poppins',
color: Colors.white,
),
),
),
],
),
),
),
Expanded(
child: Container(
//Share post button
padding: EdgeInsets.all(10),
margin: EdgeInsets.all(10),
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
color: Colors.red,
boxShadow: [
//Parentesi quadre perché può contenere più proprietà, è perciò una lista
BoxShadow(
color: Colors.red,
spreadRadius: 5,
blurRadius: 20,
)
]),
child: Row(
//Contenuto del container
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(right: 5),
child: Icon(
Icons.share,
color: Colors.white,
size: MediaQuery.of(context).size.height / 40,
),
),
Flexible(
child: Text(
'Condividi',
style: TextStyle(
fontSize: MediaQuery.of(context).size.height / 40,
fontFamily: 'Poppins',
color: Colors.white,
),
),
)
])),
),
],
),
],
),
)
Method 3: Try with Wrap to make the buttons in multiple lines but text will be in single line
Padding(
padding: EdgeInsets.fromLTRB(0, MediaQuery.of(context).size.height / 40, 0, 0),
child: Column(
children: [
Container(
width: double.infinity,
child: Wrap(
alignment: WrapAlignment.center,
children: [
Container(
//Like button
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(10),
decoration: const BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.all(Radius.circular(20)),
boxShadow: [
BoxShadow(
color: Colors.blue,
spreadRadius: 5,
blurRadius: 20,
)
]),
child: Row(
mainAxisSize: MainAxisSize.min,
//Contenuto del container, 'child:' perché è il figlio del container
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
//'Children:[]' perché contiene più elementi
Padding(
padding: const EdgeInsets.only(right: 5),
child: Icon(
Icons.thumb_up,
color: Colors.white,
size: MediaQuery.of(context).size.height / 40,
),
),
Flexible(
child: Text(
'Like',
overflow: TextOverflow.fade,
style: TextStyle(
fontSize: MediaQuery.of(context).size.height / 40,
fontFamily: 'Poppins',
color: Colors.white,
),
),
),
],
),
),
Container(
//Comment button
padding: EdgeInsets.all(10),
margin: EdgeInsets.all(10),
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
color: Colors.green,
boxShadow: [
BoxShadow(
color: Colors.green,
spreadRadius: 5,
blurRadius: 20,
)
]),
child: Row(
//Contenuto del secondo bottone (quello centrale)
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(right: 5),
child: Icon(
Icons.message,
color: Colors.white,
size: MediaQuery.of(context).size.height / 40,
),
),
Flexible(
child: Text(
'Commenta',
overflow: TextOverflow.clip,
style: TextStyle(
fontSize: MediaQuery.of(context).size.height / 40,
fontFamily: 'Poppins',
color: Colors.white,
),
),
),
],
),
),
Container(
//Share post button
padding: EdgeInsets.all(10),
margin: EdgeInsets.all(10),
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
color: Colors.red,
boxShadow: [
//Parentesi quadre perché può contenere più proprietà, è perciò una lista
BoxShadow(
color: Colors.red,
spreadRadius: 5,
blurRadius: 20,
)
]),
child: Row(
//Contenuto del container
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(right: 5),
child: Icon(
Icons.share,
color: Colors.white,
size: MediaQuery.of(context).size.height / 40,
),
),
Flexible(
child: Text(
'Condividi',
style: TextStyle(
fontSize: MediaQuery.of(context).size.height / 40,
fontFamily: 'Poppins',
color: Colors.white,
),
),
)
])),
],
),
),
],
),
)
Just figured out the problem, I put the Wrap widget in the wrong position and now it works as needed.
Here's the code to help others who have the same problem.
Wrap(children: [
Row( //I tre bottoni di 'Like', 'Commenta' e 'Condividi'
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container( //Like button
width: MediaQuery.of(context).size.width/4,
height: MediaQuery.of(context).size.height/15,
decoration: const BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.all(Radius.circular(20)),
boxShadow: [
BoxShadow(
color: Colors.blue,
spreadRadius: 5,
blurRadius: 20,
)
]
),
child: Row( //Contenuto del container, 'child:' perché è il figlio del container
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [ //'Children:[]' perché contiene più elementi
Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 5, 0),
child: Icon(
Icons.thumb_up, color: Colors.white,
size: MediaQuery.of(context).size.height/40,
),
),
Flexible(
child: Text('Like',
overflow: TextOverflow.fade,
style: TextStyle(
fontSize: MediaQuery.of(context).size.height/40,
fontFamily: 'Poppins',
color: Colors.white,
),
),
),
],
),
),
Padding(
padding: EdgeInsets.fromLTRB(MediaQuery.of(context).size.width/40, 0, MediaQuery.of(context).size.width/40, 0),
child: Container( //Comment button
width: MediaQuery.of(context).size.width/4,
height: MediaQuery.of(context).size.height/15,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
color: Colors.green,
boxShadow: [
BoxShadow(
color: Colors.green,
spreadRadius: 5,
blurRadius: 20,
)
]
),
child: Row( //Contenuto del secondo bottone (quello centrale)
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(30, 0, 5, 0),
child: Icon(
Icons.message, color: Colors.white,
size: MediaQuery.of(context).size.height/40,
),
),
Flexible(
child: Text('Commenta',
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: MediaQuery.of(context).size.height/40,
fontFamily: 'Poppins',
color: Colors.white,
),
),
),
],),
),
),
Container( //Share post button
width: MediaQuery.of(context).size.width/4,
height: MediaQuery.of(context).size.height/15,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
color: Colors.red,
boxShadow: [ //Parentesi quadre perché può contenere più proprietà, è perciò una lista
BoxShadow(
color: Colors.red,
spreadRadius: 5,
blurRadius: 20,
)
]
),
child: Row( //Contenuto del container
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 5, 0),
child: Icon(
Icons.share, color: Colors.white,
size: MediaQuery.of(context).size.height/40,
),
),
Flexible(
child: Text('Condividi',
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: MediaQuery.of(context).size.height/40,
fontFamily: 'Poppins',
color: Colors.white,
),
),
)
]
)
),
],
),
],
```
I placed a post like this. When the text did not fit, it did not pass when it should have been on the bottom line.
Code:
body: Container(
padding: EdgeInsets.all(10),
child: Container(
height: 150,
decoration: BoxDecoration(
color: Colors.black
),
padding: EdgeInsets.all(10),
child: Container(
height: 180,
decoration: BoxDecoration(
border: Border.all(color: Colors.white, width: 2),
),
child: Row(
children: [
Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Soru sor, kazan", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.white),),
Text("SorSor! uygulaması ile soru sor, para kazan! Tek amacın yaşadığın sorunları soru olarak açmak ve diğer kullanıcıların sorularını yanıtlamak.", style: TextStyle(fontSize: 16, color: Colors.white),),
],
),
),
],
),
),
)
)
I want it to go to the bottom line when there is no space left. How can I do it?
Just remove the Row widget that you have above the Padding and the issue will gone.
Container(
height: 180,
decoration: BoxDecoration(
border: Border.all(color: Colors.white, width: 2),
),
child: Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Soru sor, kazan",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white),
),
Text(
"SorSor! uygulaması ile soru sor, para kazan! Tek amacın yaşadığın sorunları soru olarak açmak ve diğer kullanıcıların sorularını yanıtlamak.",
style: TextStyle(fontSize: 16, color: Colors.white),
),
],
),
),
),
I am using three text in side a column, one text is long then I got this error "A RenderFlex overflowed by 248 pixels on the right."
I am using three text in side a column, one text field is long then I got this error "A RenderFlex overflowed by 248 pixels on the right." How to fix it?
This is m code.
import 'package:cwc/ApiManager/api_magager.dart';
import 'package:cwc/constants/constants.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
class EVDetails extends StatefulWidget {
final eventsListDetails;
const EVDetails({Key? key, this.eventsListDetails}) : super(key: key);
#override
State<EVDetails> createState() => _EVDetailsState();
}
class _EVDetailsState extends State<EVDetails> {
#override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 10),
child:widget.eventsListDetails['image'] == null || widget.eventsListDetails['description'] =="" ?Image.asset(
'assets/video_cover.png',
height: 120,
width: 100,
):Image.network(
imgBaseUrl+'${widget.eventsListDetails['image']}',
height: 120,
width: 100,
fit: BoxFit.fill,
),
),
Padding(
padding: const EdgeInsets.fromLTRB(19, 15, 0, 0),
child: Flexible(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'${widget.eventsListDetails['name']}',
style: GoogleFonts.poppins(
fontSize: 18,
color: Color(0xff444444),
fontWeight: FontWeight.w600,
),maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
'Cancer, Diabetes and Dental \nProblems',
style: GoogleFonts.poppins(
fontSize: 12,
color: Color(0xff8F9698),
fontWeight: FontWeight.normal,
),
),
Text(
'For Champion Membership',
style: GoogleFonts.poppins(
fontSize: 14,
color: Color(0xffC691D3),
fontWeight: FontWeight.w600,
),
),
],
),
),
),
],
),
Text(
'Event Description',
style: GoogleFonts.poppins(
fontSize: 18,
// color: Color(0xFFC691D3),
color: Color(0xff444444),
fontWeight: FontWeight.w500),
),
SizedBox(
height: 11,
),
Text(
"${widget.eventsListDetails['description']}",
style:
GoogleFonts.poppins(fontSize: 13, color: Color(0xFF444444)),
textAlign: TextAlign.justify,
),
Padding(
padding: EdgeInsets.fromLTRB(0, 24, 0, 0),
child: Container(
decoration: BoxDecoration(
color: Color(0xffC691D3).withOpacity(0.2),
borderRadius: BorderRadius.only(
topRight: Radius.circular(10.0),
bottomRight: Radius.circular(10.0),
topLeft: Radius.circular(10.0),
bottomLeft: Radius.circular(10.0)),
),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Row(
children: [
Column( crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Start Date & Time',
style: GoogleFonts.poppins(
fontSize: 12,
color: Color(0xFF444444),
),
),
Text(
"${formateDat(DateTime.parse(widget.eventsListDetails['startTime']))} at ${DateFormat("hh:mm a").format(DateFormat("yyyy-MM-ddTHH:mm:ssZ").parseUTC("${widget.eventsListDetails['startTime']}").toLocal())} PT",
style: GoogleFonts.poppins(
fontSize: 14,
color: Color(0xFF444444),
),
),
],
),
SizedBox(height: 20,),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'End Date & Time',
style: GoogleFonts.poppins(
fontSize: 12,
color: Color(0xFF444444),
),
),
Text(
"${formateDat(DateTime.parse(widget.eventsListDetails['endTime']))} at ${DateFormat("hh:mm a").format(DateFormat("yyyy-MM-ddTHH:mm:ssZ").parseUTC("${widget.eventsListDetails['endTime']}").toLocal())} PT",
style: GoogleFonts.poppins(
fontSize: 14,
color: Color(0xFF444444),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(0, 5, 10, 2),
child: Row(
children: [
Row(
children: [
Icon(
Icons.schedule,
color: Color(0xFFC691D3),
),
SizedBox(
width: 2,
),
Text(
'${widget.eventsListDetails['duration']} mins',
style: GoogleFonts.poppins(
fontWeight: FontWeight.normal,
fontSize: 14,
color: Color(0xFFC691D3)),
),
],
),
SizedBox(
width: 5,
),
Row(
children: [
Icon(
Icons.online_prediction,
color: Color(0xFFC691D3),
),
SizedBox(
width: 2,
),
Text(
'${widget.eventsListDetails['eventMode']}',
style: GoogleFonts.poppins(
fontWeight: FontWeight.normal,
fontSize: 14,
color: Color(0xFFC691D3)),
),
],
),
],
),
),
],
),
],
),
Spacer(),
Image.asset(
'assets/calender.png',
height: 120,
width: 120,
)
],
),
),
),
)
],
),
),
);
}
}
formateDat(DateTime date) {
final DateFormat formatter = DateFormat.MMM();
String formatted = formatter.format(date);
formatted = "${formatted} " +"${date.day}";
var week = DateFormat('EEEE').format(date);
var we = week[0] + week[1] + week[2];
return "$we, " + formatted;
}
Try below code hope its help to you. Put your Column Inside Expanded Widget:
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding:EdgeInsets.all(5),
decoration: BoxDecoration(
color: Colors.orange.shade200,
border:Border.all(color:Colors.black,),
borderRadius: BorderRadius.all(
Radius.circular(12.0),
),),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image.network(
'https://miro.medium.com/max/1400/1*-6WdIcd88w3pfphHOYln3Q.png',
width: 100,
),
SizedBox(
width: 10,
),
Expanded(
child: Column(//put this column inside Expanded widget
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
' {widget.eventsListDetails[index][ name ]}',
),
Text('Cancer,Diabetes and Dental Problems'),
Text(
" {widget.eventsListDetails[index]['description']}ex]['description']}",
),
],
),
),
],
),
),
SizedBox(height: 10),
Text('Event Description'),
SizedBox(height: 10),
Text(
'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.'),
],
),
Your result screen->
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
Text(
' {widget.eventsListDetails[index][ name ]}',
)),
Expanded(Text('Cancer,Diabetes and Dental Problems')),
Expanded(Text(
" {widget.eventsListDetails[index]['description']}ex]['description']}",
),)
],
),
Here is your solution,
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 150,
height: 150,
color: Colors.grey,
),
const SizedBox(width: 10,),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Lorem ipsum is placeholder text commonly used in the graphic, print, and publishing industries for previewing layouts and visual mockups.')
],
),
)
],
)
I'm getting below overflow error and I want to make an expanded view for hashtags.
For example, I want 4th hashtag in the new line.
Ive tried to wrap Row with Expanded and tried to give fix width but not working.
My issue :
My code:
Container(
margin: EdgeInsets.only(left: 10, right: 10, bottom: 10),
decoration: BoxDecoration(
color: ColorRes.white,
borderRadius: BorderRadius.circular(8),
),
child: Row(
children: [
Container(
height: 40,
width: 40,
margin: EdgeInsets.symmetric(horizontal: 5),
decoration: BoxDecoration(
color: ColorRes.primaryColor,
borderRadius: BorderRadius.all(
Radius.circular(60),
),
),
alignment: Alignment.center,
child: Text(
"PS",
style: TextStyle(
color: ColorRes.white,
fontSize: 16,
),
),
),
Expanded(
child: Container(
padding: EdgeInsets.all(5),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Jane Mosca Battello",
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 5),
child: Row(
children: [
Expanded(
child: Row(
children: [
Text(
"Stage : ",
style: TextStyle(
fontSize: 14,
color: ColorRes.black,
),
),
Container(
decoration: BoxDecoration(
color: ColorRes.green,
borderRadius: BorderRadius.circular(4),
),
padding: EdgeInsets.symmetric(horizontal: 3),
child: Text(
"Lead",
style: TextStyle(
fontSize: 12,
color: ColorRes.white,
),
),
),
],
),
),
Expanded(
child: Row(
children: [
Text(
"Source : ",
style: TextStyle(
fontSize: 14,
color: ColorRes.black,
),
),
Container(
decoration: BoxDecoration(
color: ColorRes.primaryColor,
borderRadius: BorderRadius.circular(4),
),
padding: EdgeInsets.symmetric(horizontal: 3),
child: Text(
"Website",
style: TextStyle(
fontSize: 12,
color: ColorRes.white,
),
),
),
],
),
),
],
),
),
Row(
mainAxisSize: MainAxisSize.min,
children: ["Buyer Lead", "Seller Lead","Buyer Lead ", "Seller Lead"]
.map(
(e) => Container(
decoration: BoxDecoration(
color: ColorRes.primaryColor.withOpacity(0.7),
borderRadius: BorderRadius.circular(4),
),
padding: EdgeInsets.symmetric(horizontal: 3),
margin: EdgeInsets.only(right: 5),
child: Text(
"#$e",
style: TextStyle(
fontSize: 12,
color: ColorRes.white,
),
),
),
)
.toList(),
)
],
),
),
),
],
),
)
instead of row use Wrap Widget. it will work
Add your container to flexible widget
Row(
mainAxisSize: MainAxisSize.min, children: [
"Buyer Lead",
"Seller Lead",
"Buyer Lead ",
"Seller Lead",
"Seller Lead",
"Seller Lead",
]
.map(
(e) => Flexible(
child: Container(
decoration: BoxDecoration(
color: Colors.red.withOpacity(0.7),
borderRadius: BorderRadius.circular(4),
),
padding: EdgeInsets.symmetric(horizontal: 3),
margin: EdgeInsets.only(right: 5),
child: Text(
"#$e",
style: TextStyle(
fontSize: 12,
color: Colors.white,
),
),
),
),
)
.toList(),
)
This particular screen is composed of a large container (Height of screen) : This container is composed of three parts : A header (fixed container : 10% of screen size), a footer (fixed container : 10% of screen size) and a middle part : container : height of 80% of screen size.
I would like the middle container to be scrollable : so I inserted a LISTVIEW as the child of this container... but it keeps telling me I get a RenderFlex overflowed.... Why doesn't the content of the middle container scroll in between the header and the footer ??
Here is the code :
Scaffold(
backgroundColor: Colors.indigo[900],
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
automaticallyImplyLeading: false,
leading: IconButton(
icon: Icon(Icons.arrow_back_ios_rounded,
color: Colors.red[400], size: 25.0),
onPressed: () {
uD.clearSearchList();
Navigator.pushReplacementNamed(context, StudentHomeScreen.id);
}),
title: Text(
'ETAPE 1 - Découverte',
style: TextStyle(color: Colors.indigo[900], fontSize: 22),
),
actions: [
Container(
margin: const EdgeInsets.only(right: 10),
child: Icon(Icons.memory, size: 45, color: Colors.red[900]),
),
],
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Container(
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
color: Colors.orange[50],
borderRadius: BorderRadius.circular(10.0),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: (MediaQuery.of(context).size.height) * 0.12,
padding: const EdgeInsets.fromLTRB(12, 12, 12, 0),
decoration: BoxDecoration(
color: Colors.orange[100],
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Activité 1',
style: TextStyle(
color: Colors.red[900],
fontSize: 30,
fontWeight: FontWeight.bold),
),
Text(
'Mot n°1/24',
style: TextStyle(
color: Colors.indigo[900],
fontSize: 17.0,
),
),
],
),
SleekCircularSlider(
appearance: CircularSliderAppearance(
infoProperties: InfoProperties(
modifier: (reussite) {
return '${reussite.toInt()} / 5';
},
bottomLabelText: 'Réussite',
bottomLabelStyle:
TextStyle(fontSize: 12, color: Colors.red[900]),
),
size: 90,
customColors: CustomSliderColors(
progressBarColor: Colors.green[900]),
customWidths:
CustomSliderWidths(progressBarWidth: 8)),
min: 0,
max: 5,
initialValue: reussite <= 5 ? reussite : 5,
)
],
),
),
Container(
height: (MediaQuery.of(context).size.height) * 0.8,
child: ListView(
shrinkWrap: true,
children: [
Container(
padding: EdgeInsets.all(12.0),
margin: const EdgeInsets.only(top: 8),
child: Text(
'Ecoute et répète 5 fois le mot en anglais.',
style:
TextStyle(color: Colors.indigo[700], fontSize: 17),
),
),
Container(
margin: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
width: 1.0,
),
borderRadius: BorderRadius.circular(10.0),
),
padding: const EdgeInsets.only(top: 16),
child: Row(
children: [
Container(
height: 200,
child: Image.asset(
'images/avatar_teacher.jpeg',
),
),
Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
child: Text(
'An adult',
style: TextStyle(
color: Colors.red[900],
fontSize: 23,
),
),
),
Container(
margin: const EdgeInsets.only(bottom: 60),
child: Text(
'Un adulte',
style: TextStyle(
color: Colors.indigo[900],
fontSize: 15,
),
),
),
GestureDetector(
child: Container(
height: 45,
margin:
EdgeInsets.fromLTRB(0, 5.0, 0, 15.0),
alignment: Alignment.topRight,
child: Icon(
Icons.volume_up,
color: Colors.indigo[500],
size: 55.0,
),
),
onTap: () {
Tts.speak(
phrase: 'little',
langue: Language.english);
},
),
Container(
alignment: Alignment.topRight,
child: Text('/adult/'),
),
],
),
),
],
),
),
Container(
height: 80,
margin: const EdgeInsets.symmetric(vertical: 20),
alignment: Alignment.center,
child: IconButton(
icon: Icon(
Icons.mic,
color: Colors.red[900],
size: 50,
),
onPressed: () async {
uD.checkSpokenWords('adult', reussite);
}),
),
Container(
alignment: Alignment.center,
child: Text(
'Clique sur le micro et répète le mot',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black45,
fontSize: 15.0,
),
),
),
SizedBox(
height: 50.0,
),
Container(
width: double.infinity,
alignment: Alignment.centerLeft,
margin: const EdgeInsets.only(top: 12),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
width: 1.0,
),
borderRadius: BorderRadius.circular(10.0),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Text('Voici ce que j\'ai compris : '),
Text(uD.spokenWords),
],
),
),
),
],
),
),
Container(
height: (MediaQuery.of(context).size.height) * 0.08,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.orange[100],
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(10),
bottomRight: Radius.circular(10),
),
),
margin: const EdgeInsets.only(top: 8),
child: RoundedProgressBar(
milliseconds: 1000,
childLeft: Text(
'Réussite de l\'activité : ',
style: TextStyle(color: Colors.indigo[900]),
),
childRight: Text("$reussite%",
style: TextStyle(color: Colors.red[900])),
percent: reussite,
theme: RoundedProgressBarTheme.blue),
),
],
),
),
),
);
You should replace the middle Container (the one with the 0.8 * MediaQuery height) with Expanded so it will take the available space between the 2 other Containers.