I'm having an issue getting my container to extend downward into the "safe area" in my Flutter code.
Showing the problem. White container not extending to the edge of display:
return Card(
elevation: 1,
margin: EdgeInsets.all(0),
child: SafeArea(
top: false,
bottom: true,
minimum: const EdgeInsets.all(0),
child: Container(
margin: EdgeInsets.all(0),
height: 50,
width: double.infinity,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.6),
spreadRadius: 5,
blurRadius: 7,
offset: Offset(0,0)
)
],
),
padding: EdgeInsets.symmetric(horizontal: 20),
child: Row( [...]
Does anyone see what the issue might be, or how I can fix it?
In your SafeArea to extend the bottom, you should call false:
SafeArea(
top: false,
bottom: false,//<---- add this
...
)
Related
I have 3 positioned as children of Stack inside of ListView.builder
also set top and right for all 3 positioned when run, got this error
size.isFinite
Also I have error that
buttom overflowd by102 pixels
If I remove top and right Only and only from first positioned work currectly, what is my mistake
ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: HomeProvider().homeItems.length,
itemBuilder: (context, index) => SizedBox(
child: Stack(
children: [
Positioned(
top: 35,
right: 20,
child: Material(
child: Container(
height: 75.0,
width: width * 0.9,
decoration: BoxDecoration(
color: ColorManager.white,
borderRadius: BorderRadius.circular(0.0),
boxShadow: [
BoxShadow(
color: ColorManager.grey,
offset: const Offset(-10.0, 10.0),
blurRadius: 20.0,
spreadRadius: 4.0),
],
),
),
),),
positioned(
top:30,
right:45,
...
),
positioned(
top:30,
right:45,
...
),
]
Positioned needs to know Stack constraints if you want to position it (using top/right/bottom/left). So you need to assign some height to the SizedBox which wraps your Stack.
ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: HomeProvider().homeItems.length,
itemBuilder: (context, index) => SizedBox(
height: 100, // give some height here
child: Stack(
children: [
Positioned(
top: 35,
right: 20,
child: Material(
child: Container(
height: 75.0,
width: width * 0.9,
decoration: BoxDecoration(
color: ColorManager.white,
borderRadius: BorderRadius.circular(0.0),
boxShadow: [
BoxShadow(
color: ColorManager.grey,
offset: const Offset(-10.0, 10.0),
blurRadius: 20.0,
spreadRadius: 4.0),
],
),
),
),),
Positioned(
top:30,
right:45,
...
),
Positioned(
top:30,
right:45,
...
),
])));
I'm new to flutter, I'm trying to create a container, inside SingleChildScrollView. when i create shadow of containers, it is a straight line which is due to the boundary of SingleChildScrollView.
SingleChildScrollView(
scrollDirection: Axis.horizontal,
padding: EdgeInsets.only(top: 35, left: 5, bottom: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.all(3),
child: Container(
height: 170,
width: 120,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
gradient: const LinearGradient(colors: [
Colors.deepOrange,
Colors.orange,
], transform: GradientRotation(120)),
),
),
),
Padding(
padding: EdgeInsets.only(bottom: 20),
child: Container(
height: 170,
width: 120,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
gradient: const LinearGradient(colors: [
Colors.deepOrange,
Colors.orange,
], transform: GradientRotation(120)),
boxShadow: [
BoxShadow(color: Colors.orange.shade200,offset: Offset(10,5),spreadRadius: 1,blurRadius: 100)
]
),
),
),
Padding(
padding: EdgeInsets.all(3),
child: Container(
height: 170,
width: 120,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
gradient: const LinearGradient(
colors: [
Colors.deepOrange,
Colors.orange,
],
transform: GradientRotation(120),
),
),
),
)
],
),
)
i have applied shadow to the second padding. here is the image and i circled the part which doest fit in the UI
image of problem
Add clipBehavior: Clip.none to the SingleChildScrollView. The default is Clip Clip clipBehavior = Clip.hardEdge.
SingleChildScrollView(
clipBehavior: Clip.none,
scrollDirection: Axis.horizontal,
padding: EdgeInsets.only(top: 35, left: 5, bottom: 10),
child: Row(),
);
I have container, with some shadow, and I want SizedBox inside with shadow for effect, that it's inside of container. Although, the inside SizedBox's shadow overlaps the parent container shadow. How to fix this? Basically, it would be sufficient to have on child's SizedBox shadow only on top and bottom, but I didn't found a way how to do this.
Scaffold(
appBar: AppBar(
title: Text('Test'),
),
body: SingleChildScrollView(
child: SizedBox(
width: double.infinity,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20)),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 7,
)
]),
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
child: Column(
children: [
Container(
margin: EdgeInsets.all(20), child: Text('Some text')),
SizedBox(
child: Container(
padding: EdgeInsets.all(10),
decoration:
BoxDecoration(color: Colors.white, boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
)
]),
child: Column(children: [Text('bruh')]),
),
width: double.infinity,
),
Padding(
padding: const EdgeInsets.all(15.0),
child: Text('Aaaa'),
)
],
)
),
),
)
);
If you use a css file set the style as:
box-shadow: 0px 10px 5px #888, 0px -10px 5px #888;
I tried to create a container with box shadow but not able to get same result as I want. This is i achieved but i want to show shadow with rounded edges and one of my horizontal list with bottom shadow and 2nd with all side shadow. I also need low thickness of shadow. My lists have background image and text. Please help me how to achieve this.
My Code
Container(
height: 180.0,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: response.data.length,
itemBuilder: (context, index) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {},
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: CachedNetworkImageProvider(
response.data[index].imageUrl,
),
fit: BoxFit.fill)),
margin: EdgeInsets.only(bottom: 6.0, right: 10.0),
width: MediaQuery.of(context).size.width - 100,
child: Container(
width: MediaQuery.of(context).size.width - 100,
margin: EdgeInsets.only(left: 8.0, right: 6.0),
decoration: BoxDecoration(
boxShadow: <BoxShadow>[
BoxShadow(
color: Color(0xff000000).withOpacity(.9),
blurRadius: 10.0,
spreadRadius: 2.0,
offset: Offset(0.0, 180))
],
),
child: Padding(
padding: const EdgeInsets.fromLTRB(
10.0, 35.0, 5.0, 0.0),
child: Text(
response.data[index].name.toUpperCase(),
style: GoogleFonts.roboto(
textStyle: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: Color(0xffFFFFFF))),
),
),
),
),
);
}),
)
this might help
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 3,
offset: Offset(0, 4)),
],
Ref Stackoverflow ref
use offset property of BoxShadow to control how the shadow should be visible and radius property to control thickness of the shadow.
I'm trying to reproduce this layout button
I created a Stack with a Container and a Positioned button, but I can't set the button out of the box.
Stack(children: <Widget>[
Container(
decoration: new BoxDecoration(
shape: BoxShape.rectangle,
border: new Border.all(
color: Colors.black,
width: 1
)
),
child: Text("League of legends")
),
Positioned(
right: 0,
bottom: 0,
child: Container(
width: 9,
height: 9,
child: new Container(
width: 9,
height: 9,
decoration: new BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
),
)
)
])
I tried add Padding but without success.
The result of my code is this:
The constructor of Stack has the overflow argument, which enables you to choose whether to paint its children outside of its boundary.
By passing in Overflow.visible to overflow and setting negative values in right and bottom in Positioned(), you can make the circle stick out of the box.
Stack(
overflow: Overflow.visible,
children: <Widget>[
Container(
decoration: ...,
child: ...,
),
Positioned(
right: -4,
bottom: -4,
child: Container(
width: 9,
height: 9,
decoration: new BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
),
)
],
)
I've reduced redundantly nested Containers into one.