How to align widget under another widget in Flutter? - flutter

I have a widget meant to represent progress which goes
like this
I need to be able to put a name under a bubble, but when I do that like this:
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.green,
width: 1.5,
),
),
height: MediaQuery.of(context).size.height / 10,
width: MediaQuery.of(context).size.width / 10,
child: Center(
child: Icon(
Icons.check,
color: Colors.green,
size: 30,
),
),
),
Text("Test label"),
],
),
this happens.
I also tried putting the bars in a row with the circle:
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
children: [
Container(
padding: EdgeInsets.symmetric(
vertical:
MediaQuery.of(context).size.height / 20,
),
height:
1 + MediaQuery.of(context).size.height / 10,
width: MediaQuery.of(context).size.width / 16,
),
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: mainColor,
width: 1.5,
),
),
height: MediaQuery.of(context).size.height / 10,
width: MediaQuery.of(context).size.width / 10,
child: Center(
child: Icon(
Icons.check,
color: mainColor,
size: 30,
),
),
),
Container(
padding: EdgeInsets.symmetric(
vertical:
MediaQuery.of(context).size.height /20,
),
height:
1 + MediaQuery.of(context).size.height / 10,
width: MediaQuery.of(context).size.width / 16,
child: Container(
color: grey,
),
),
],
),
Text("Test label"),
],
),
This is better, but still creates problems if the text is bigger
How can I align the text below the circle without causing problems with the lines?
The code for the entire widget (sorry that it's so long, don't know how to show it otherwise):
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.symmetric(
vertical:
MediaQuery.of(context).size.height / 20,
),
height:
1 + MediaQuery.of(context).size.height / 10,
width: MediaQuery.of(context).size.width / 16,
),
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.green,
width: 1.5,
),
),
height: MediaQuery.of(context).size.height / 10,
width: MediaQuery.of(context).size.width / 10,
child: Center(
child: Icon(
Icons.check,
color: Colors.green,
size: 30,
),
),
),
Text("Test label"),
],
),Container(
padding: EdgeInsets.symmetric(
vertical:
MediaQuery.of(context).size.height / 20,
),
height:
1 + MediaQuery.of(context).size.height / 10,
width: MediaQuery.of(context).size.width / 16,
child: Container(
color: Colors.grey,
),
),
Container(
padding: EdgeInsets.symmetric(
vertical: MediaQuery.of(context).size.height / 20,
),
height: 1 + MediaQuery.of(context).size.height / 10,
width: 3 / 2 * MediaQuery.of(context).size.width / 8,
child: Container(
color: Colors.grey,
),
),
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.grey,
width: 1.5,
),
),
height: MediaQuery.of(context).size.height / 10,
width: MediaQuery.of(context).size.width / 10,
),
Container(
padding: EdgeInsets.symmetric(
vertical: MediaQuery.of(context).size.height / 20,
),
height: 1 + MediaQuery.of(context).size.height / 10,
width: MediaQuery.of(context).size.width / 8,
child: Container(
color: Colors.grey,
),
),
Container(
padding: EdgeInsets.symmetric(
vertical: MediaQuery.of(context).size.height / 20,
),
height: 1 + MediaQuery.of(context).size.height / 10,
width: MediaQuery.of(context).size.width / 8,
child: Container(
color: Colors.grey,,
),
),
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.grey,,
width: 1.5,
),
),
height: MediaQuery.of(context).size.height / 10,
width: MediaQuery.of(context).size.width / 10,
)
],
),

One solution I would suggest is that try Wrapping Text with ConstrainedBox and Container and limit the max width.
For example -
ConstrainedBox(
constraints: BoxConstraints(maxWidth: 50),
child: Container(
child: Text('Your Text'),
),
),
Thought that will move the text in the next line if it is too long to be placed in a single line.

Related

I had an error in flutter as "BOTTOM OVERFLOWING BY 1.1 PIXELS" while creating buttons

This is my code. Help me with this:
return SafeArea(
child: Container(
width: size.width,
height: size.height,
color: background,
child: FittedBox(
fit: BoxFit.contain,
alignment: Alignment.center,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Container(
width: size.width,
height: size.height * 0.1,
child: Padding(
padding: EdgeInsets.zero,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
],
),
),
),
Container(
width: size.width,
height: size.height * 0.25,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Container(
width: size.width * 0.25,
height: size.height * 0.25,
decoration: new BoxDecoration(
color: buttonBackground,
borderRadius: new BorderRadius.all(
Radius.circular(40.0),
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Icon(
Icons.keyboard_arrow_left,
color: iconButton,
size: 38,
),
Text(
"L&R",
style: TextStyle(
fontWeight: FontWeight.bold,
color: text,
fontSize: 24,
),
),
Icon(
Icons.keyboard_arrow_right,
color: iconButton,
size: 38,
),
],
),
),
Container(
padding: EdgeInsets.zero,
width: size.width * 0.1,
height: size.width * 0.1,
decoration: new BoxDecoration(
gradient: new LinearGradient(
begin: Alignment.topLeft,
end: Alignment.topRight,
colors: [
Colors.blue,
Colors.pink,
],
),
shape: BoxShape.circle,
),
child: Container(
padding: EdgeInsets.zero,
width: size.width * 0.4,
height: size.width * 0.4,
decoration: new BoxDecoration(
color: background,
shape: BoxShape.circle,
),
),
),
Container(
width: size.width * 0.25,
height: size.height * 0.25,
decoration: new BoxDecoration(
color: buttonBackground,
borderRadius: new BorderRadius.all(
Radius.circular(40.0),
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Icon(
Icons.keyboard_arrow_up,
color: iconButton,
size: 38,
),
Text(
"U & D",
style: TextStyle(
fontWeight: FontWeight.bold,
color: text,
fontSize: 24,
),
),
Icon(
Icons.keyboard_arrow_down,
color: iconButton,
size: 38,
),
],
),
),
],
),
),
Container(
width: size.width,
height: size.height*0.23,
),
],
),
),
),
),
);
Try below code hope its helpful to you.
Add your Column Widget inside SingleChildScrollView
SingleChildScrollView(
child:Column(
children:[
//Add your widgets here
],
),
),
I'm trying to reproduce the error, but I need your constants to do so. Can you add the constants.dart file to your question? Or at least the file where you specify size.width and size.height, for example?
That way I can run your code on my computer and see what I can do to help you.
For now, I'm thinking you should probably use Flex widget (https://api.flutter.dev/flutter/widgets/Flex-class.html) to fix this problem without making the app scroll, since that's not always what you want (thinking of a login page or something).

Flutter, Expanded Stack`s child cut/removed by other widget

Container(
padding:
EdgeInsets.only(left: 16, right: 20, top: 16, bottom: 16),
height: 68,
width: 200,
color: Colors.green,
child: Row(
children: [
Expanded(
child: Container(
child: Stack(
children: <Widget>[
Positioned(
// top: 16,
left: 0,
// height: 40,
// width: 40,
child: Container(
height: 36,
width: 60,
decoration: BoxDecoration(
color: Colors.black,
shape: BoxShape.circle,
),
),
),
],
),
),
),
SizedBox(
width: 4,
),
Container(
width: 120,
height: 30,
color: Colors.red,
),
],
),
)
The black circle is wrapped by Expanded
But the space is invaded by others
how to prevent this??
I'd rather this give overflow to the right without clipping my stack widget.
You can use Positioned in a container instead of circle.
Container(
padding: EdgeInsets.only(left: 16, right: 20, top: 16, bottom: 16),
height: 68,
width: double.infinity,
color: Colors.green,
child: Stack(
children: [
Container(
height: 36,
width: 60,
decoration: BoxDecoration(
color: Colors.black,
shape: BoxShape.circle,
),
),
Positioned(
left: 50,
top: 3,
child: Container(
width: MediaQuery.of(context).size.width-100,
height: 30,
color: Colors.red,
),
),
],
),
)
Output:

Flutter: View of message sent on whatsapp?

I want to get this message view, but I can't add clock and blue tick at the end. It should not look distorted when the message gets longer.
I tried such a code but the result was not the same.
Row sentMessage(BuildContext context, int index) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
child: Container(
constraints: BoxConstraints(
maxWidth: displayWidth(context) * 0.80,
minWidth: displayWidth(context) * 0.20,
),
decoration: BoxDecoration(
color: Color(0xffDCF8C6),
borderRadius: BorderRadius.all(Radius.circular(9))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
child: Text(messages[index]),
),
Container(
child: Text('11:11'),
)
],
),
margin: EdgeInsets.symmetric(
horizontal: displayWidth(context) * 0.02,
vertical: displayWidth(context) * 0.004,
),
padding: EdgeInsets.all(displayWidth(context) * 0.02),
),
alignment: Alignment.centerRight,
width: displayWidth(context),
),
],
);
}
This is the result
I was able to do it myself after spending some time and thinking.
Row sentMessage(BuildContext context, int index) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
child: Container(
constraints: BoxConstraints(
maxWidth: displayWidth(context) * 0.80,
minWidth: displayWidth(context) * 0.20,
),
decoration: BoxDecoration(
color: Color(0xffDCF8C6),
borderRadius: BorderRadius.all(Radius.circular(5))),
child: Wrap(
verticalDirection: VerticalDirection.down,
alignment: WrapAlignment.end,
children: [
Container(
margin: EdgeInsets.zero,
padding: EdgeInsets.only(
bottom: displayHeightOutAppBar(context) * 0.005),
constraints: BoxConstraints(
maxWidth: displayWidth(context) * 0.80,
),
child: Text(
messages[index],
style: TextStyle(
fontSize: displayWidth(context) * 0.04,
color: Colors.black,
),
),
),
Container(
padding: EdgeInsets.zero,
margin: EdgeInsets.only(
top: displayHeightOutAppBar(context) * 0.006,
left: displayWidth(context) * 0.015),
//alignment: Alignment.bottomRight,
constraints: BoxConstraints(
maxWidth: displayWidth(context) * 0.20,
),
child: Text(
'11:11',
style: TextStyle(color: Colors.grey),
),
),
Container(
margin: EdgeInsets.only(
top: displayHeightOutAppBar(context) * 0.006),
child: Icon(
Icons.done_all,
size: displayWidth(context) * 0.04,
color: Colors.blue,
),
),
],
),
margin: EdgeInsets.symmetric(
horizontal: displayWidth(context) * 0.02,
vertical: displayWidth(context) * 0.004,
),
padding: EdgeInsets.only(
left: displayWidth(context) * 0.015,
right: displayWidth(context) * 0.015,
top: displayWidth(context) * 0.015),
),
alignment: Alignment.centerRight,
width: displayWidth(context),
),
],
);
}
I add an explanation with the recommendation of #gmdev
The wrong thing I did was to place the items one on the other using the "Column".Instead I placed them side by side using "Wrap".
I gave "MaxWidth" value to "Containers" that cover the items inside instead of the main "Container".I adjusted the spaces between them with "Padding" and "Margin".
Maybe there are different ways to do this but I think it's the simplest way.Those with different solutions can write
Here I froze again and added the second edit
There is a small triangle on the edge of the first message sent via Whatsapp.The only way to do this is "ClipPath".If your math is not good, you will have to work hard to do this.Couldn't find a similar example on the internet.
Row firstSentMessage(BuildContext context, int index) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
child: ClipPath(
clipper: MyCustomClipper1(),
child: Container(
constraints: BoxConstraints(
maxWidth: displayWidth(context) * 0.80,
minWidth: displayWidth(context) * 0.20,
),
decoration: BoxDecoration(
color: Color(0xffDCF8C6),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(5),
bottomLeft: Radius.circular(5),
bottomRight: Radius.circular(5)),
),
child: Wrap(
verticalDirection: VerticalDirection.down,
alignment: WrapAlignment.end,
children: [
Container(
margin: EdgeInsets.zero,
padding: EdgeInsets.only(
bottom: displayHeightOutAppBar(context) * 0.005),
constraints: BoxConstraints(
maxWidth: displayWidth(context) * 0.80,
),
child: Text(
messages[index],
style: TextStyle(
fontSize: displayWidth(context) * 0.04,
color: Colors.black,
),
),
),
Container(
padding: EdgeInsets.zero,
margin: EdgeInsets.only(
top: displayHeightOutAppBar(context) * 0.006,
left: displayWidth(context) * 0.015,
),
//alignment: Alignment.bottomRight,
constraints: BoxConstraints(
maxWidth: displayWidth(context) * 0.20,
),
child: Text(
'11:11',
style: TextStyle(color: Colors.grey),
),
),
Container(
margin: EdgeInsets.only(
top: displayHeightOutAppBar(context) * 0.006,
right: displayWidth(context) * 0.015,
),
child: Icon(
Icons.done_all,
size: displayWidth(context) * 0.04,
color: Colors.blue,
),
),
],
),
margin: EdgeInsets.symmetric(
horizontal: displayWidth(context) * 0.01,
vertical: displayWidth(context) * 0.004,
),
padding: EdgeInsets.only(
left: displayWidth(context) * 0.015,
right: displayWidth(context) * 0.015,
top: displayWidth(context) * 0.015),
),
),
alignment: Alignment.centerRight,
width: displayWidth(context),
margin: EdgeInsets.only(top: displayHeightOutAppBar(context) * 0.007),
),
],
);
}
And this is "Clipper".
class MyCustomClipper1 extends CustomClipper<Path> {
#override
Path getClip(Size size) {
Path path = Path();
path.lineTo(0, size.height);
path.lineTo(20, size.height);
path.arcToPoint(Offset(size.width - 12, 13),
radius: Radius.circular(1), clockwise: false);
path.lineTo(size.width, 0);
path.close();
return path;
}
#override
bool shouldReclip(CustomClipper<Path> oldClipper) => true;
}
I added "ClipPath" and "clipper" for it in new codes.I slightly changed the "padding" and "margin" values to make the image correct.
My Code :
[import 'package:flutter/material.dart';
class OwnMessageCard extends StatelessWidget {
const OwnMessageCard({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Align(
alignment: Alignment.centerLeft,
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width - 45,
),
child: Card(
elevation: 1,
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
color: Color(0xffdcf8c6),
margin: EdgeInsets.symmetric(
horizontal: 15,
vertical: 5,
),
child: Stack(children: \[
Padding(
padding: const EdgeInsets.only(
left: 10,
right: 60,
top: 10,
bottom: 20,
),
child: Text(
"Hey, Joy Sinha",
style: TextStyle(
fontSize: 16,
),
),
),
Positioned(
bottom: 4,
right: 10,
child: Row(
children: \[
Text(
"20:58",
style: TextStyle(
fontSize: 13,
color: Colors.grey\[600\],
),
),
SizedBox(
width: 5,
),
Icon(
Icons.done_all,
size: 20,
),
\],
),
),
\]),
),
),
);
}
}][1]

How to Adjust container height according to the text height in flutter?

I am building a flutter application where I am trying to add a container and it's child text.
I want the container to take as much height as the text requires. But instead it takes the height specified.
Following is my code:
class ChangePassword extends StatefulWidget {
#override
_ChangePasswordState createState() =>
_ChangePasswordState();
}
class _ChangePasswordState extends State<ChangePassword> {
final GlobalKey<ScaffoldState> _scaffoldkey = new GlobalKey<ScaffoldState>();
#override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
key: _scaffoldkey,
drawer: Drawer(
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: <Widget>[
Container(
height: (MediaQuery.of(context).size.height * 0.23),
child: DrawerHeader(
child: Container(
padding:
EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: Row(
children: [
Container(
height: MediaQuery.of(context).size.width * 0.1,
width: MediaQuery.of(context).size.width * 0.1,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Theme.of(context).primaryColor,
image: DecorationImage(
fit: BoxFit.fill,
image: NetworkImage(imageurl)),
boxShadow: [
BoxShadow(
blurRadius: 25,
color: Colors.black.withOpacity(0.2),
offset: Offset(0, 10),
)
],
),
),
Container(
height: MediaQuery.of(context).size.width * 0.15,
width: MediaQuery.of(context).size.width * 0.5,
padding: EdgeInsets.symmetric(horizontal: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
name,
style: TextStyle(
fontSize: 15,
color: Colors.lightBlue[900],
fontWeight: FontWeight.bold),
),
Text(email),
SizedBox(
height: 2,
),
Row(
children: [
Icon(
Icons.remove_red_eye_outlined,
size: 12,
),
Text(
'View Profile',
style: TextStyle(
fontSize: 12,
),
)
],
)
],
),
),
],
)),
decoration: BoxDecoration(
color: Colors.white,
),
),
),
],
),
),
body: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: MediaQuery.of(context).size.height * 0.35,
child: Stack(children: [
Positioned(
height: MediaQuery.of(context).size.height * 0.23,
top: 0,
child: Padding(
padding: EdgeInsets.only(top: 50),
child: Container(
color: Color(0xff002060),
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 0.1,
child: Align(
alignment: Alignment.topCenter,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
_scaffoldkey.currentState.openDrawer();
},
child: new Container(
child: Icon(
Icons.menu,
color: Colors.white,
size: MediaQuery.of(context).size.height *
0.04,
),
padding: new EdgeInsets.all(7.0),
),
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.3,
),
Container(
height:
MediaQuery.of(context).size.height * 0.07,
child: Center(
child: Text(
'Profile',
style: TextStyle(
color: Colors.white,
),
),
),
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.3,
),
Icon(
Icons.search,
color: Colors.white,
size: MediaQuery.of(context).size.height * 0.04,
),
],
),
),
),
),
),
Positioned(
top: MediaQuery.of(context).size.height * 0.16,
left: MediaQuery.of(context).size.width * 0.03,
child: Row(
children: [
Container(
width: MediaQuery.of(context).size.height * 0.14,
height: MediaQuery.of(context).size.height * 0.14,
decoration: ShapeDecoration(
shape: CircleBorder(), color: Colors.white),
child: Padding(
padding: EdgeInsets.all(8.0),
child: DecoratedBox(
decoration: ShapeDecoration(
shape: CircleBorder(),
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(
'https://thumbor.forbes.com/thumbor/fit-in/416x416/filters%3Aformat%28jpg%29/https%3A%2F%2Fspecials-images.forbesimg.com%2Fimageserve%2F5f4ebe0c87612dab4f12a597%2F0x0.jpg%3Fbackground%3D000000%26cropX1%3D292%26cropX2%3D3684%26cropY1%3D592%26cropY2%3D3987',
))),
),
),
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.05,
),
Column(
children: [
Container(
height: MediaQuery.of(context).size.height * 0.08,
child: Text(
'Bill Gates',
style: TextStyle(
fontSize: 25,
color: Colors.white,
fontWeight: FontWeight.bold,
fontFamily: 'Calibri'),
),
),
],
)
],
),
),
Positioned(
top: MediaQuery.of(context).size.height * 0.24,
left: MediaQuery.of(context).size.height * 0.165,
child: FittedBox(
fit: BoxFit.fill,
child: Container(
height: MediaQuery.of(context).size.height * 0.09,
width: MediaQuery.of(context).size.width * 0.6,
child: Text(
'Bill Gates welcomes you. Welcome to Microsoft. It gives me immense pleasure to announce Josh Hazlewood as it\'s new CEO. It is always immense pleasure to work with them. looking foward to have a great time with him.',
style: TextStyle(
color: Colors.black, fontFamily: 'Calibri'),
),
),
),
),
]),
),
],
)),
],
),
));
}
Following is the image:
I want the container that contains the text below 'Bill Gates' to be wrapped according to the information entered there.
The whole container should decrease as I am planning to add widgets below this customised appbar, so is there any way I can achieve this?
I tried to use flexible but it did not work. Can someone help me with this please?
Use fitted box:-
FittedBox(
fit:BoxFit.fitHeight,
child:Text("Your text"),
),
Do not provide the height of the container and it will adjust automatically.
#Ankit,
Culprit:
As you mentioned, the Container widget is intended to take the width and height you explicitly specify, so it does what you tell it to do.
What you should have done in the above case is avoid specifying the height for that Container which contains the Text widget as follows.
Change this code section from:
Positioned(
top: MediaQuery.of(context).size.height * 0.24,
left: MediaQuery.of(context).size.height * 0.165,
child: FittedBox(
fit: BoxFit.fill,
child: Container(
height: MediaQuery.of(context).size.height * 0.09,
width: MediaQuery.of(context).size.width * 0.6,
child: Text(
'Bill Gates welcomes you. Welcome to Microsoft. It gives me immense pleasure to announce Josh Hazlewood as it\'s new CEO. It is always immense pleasure to work with them. looking foward to have a great time with him.',
style: TextStyle(
color: Colors.black, fontFamily: 'Calibri'),
),
),
),
),
To the following code, where I have removed specifying the height property of the container:
Positioned(
top: MediaQuery.of(context).size.height * 0.24,
left: MediaQuery.of(context).size.height * 0.165,
child: FittedBox(
fit: BoxFit.height,
child: Container(
width: MediaQuery.of(context).size.width * 0.6,
child: Text(
'Bill Gates welcomes you. Welcome to Microsoft. It gives me immense pleasure to announce Josh Hazlewood as it\'s new CEO. It is always immense pleasure to work with them. looking foward to have a great time with him.',
style: TextStyle(
color: Colors.black, fontFamily: 'Calibri'),
),
),
),
),
By doing that, and wrapping the Container within a FittedBox, that varying text length Text widget will cause it to adjust its height accordingly.
Following part is important here:
child: FittedBox(
fit: BoxFit.height,

Flutter set maxWidth on Stack with constrainedBox

in my simple implementation of Card don't have maxWidth and when i rotate application that fills the width and i'm trying to avoiding that and setting `maxWith:300.0', my code doesn't work
return Container(
color: Color(0xffeeeeee),
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: 300),
child: Stack(
overflow: Overflow.visible,
children: <Widget>[
Container(
height: 200.0,
color: Colors.indigo,
),
Positioned(
width: MediaQuery.of(context).size.width - 20,
height: MediaQuery.of(context).size.height / 1.3,
left: 10.0,
top: 95.0,
child: Card(
elevation: 2.0,
color: Colors.white,
child: Container(
decoration: BoxDecoration(color: Colors.white12),
),
)),
],
),
));