I am having a Container that is having a BoxShadow, what i would like to achieve is to make the shadow to only appear at the top side of the Container. Below is my code
Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0)
),
boxShadow: [
BoxShadow(
offset: Offset(0, 0),
blurRadius: 20,
spreadRadius: 2,
color: Colors.grey,
),
],
),
child: Column(
children: [
// My widgets
]
)
)
I would like to completely remove the shadow at the bottom. I have tried playing with the offset like below
offset: Offset(0, -10),
But this just makes the shadow look bad, makes it look a little bit dense and makes it to look like a block
Related
Thank you for reading my question.
I'm a total rookie with Flutter but trying to learn and understand the code.
At this moment I'm trying to change an app layout. This app is showing 4 rows with 3 tiles in each row. In the tiles are icons showing. I want to change the icons into images.
The code for the icons is in two dart files. You can see a part of the code that is creating the tile and it is referring to another dartfile where for each tile the icon names are in the code.
How can I change this code so it is not referring to icons but to images?
Here is a part of the first dart file where tiles are created with icons inside
child: Column(
children: [
Expanded(
child: Row(
children: [
const Spacer(
flex: 2,
),
Flexible(
flex: 10,
fit: FlexFit.tight,
child: FittedBox(
alignment: Alignment.center,
fit: BoxFit.contain,
child: Icon(
tileInformation.icon, <-----------------------
size: 36,
color: AppConstants.iconColor,
),
),
),
const Spacer(
flex: 2,
),
],
),
),
Here is a part of the other dart file were the icon names are
TileInformation(
tileDe_gemeente,
Icons.location_city_outlined, <-----------------------------------
TileType.webpage,
url: "//justalink/",
),
TileInformation(
tileWaar,
Icons.follow_the_signs_outlined, <------------------------------
TileType.webpage,
url: "/justalink//",
),
TileInformation(
tileAgenda,
Icons.auto_stories_outlined , <--------------------------------
TileType.webpage,
url: "//justalink/",
),
If I replace this line:
child: Icon(
tileInformation.icon,
size: 36,
color: AppConstants.iconColor
To this line:
child: Image(image: AssetImage("assets/images/icon.png"),
Then the tiles are showing all the same images. So my problem is how to use the second dart file to choose a different image for every tile.
I want to add a bit shadow to my Container, which I have done using Material Widget or BoxShadow but in column at bottom of fixed container I have expanded Listview when I scroll up vertically container shadow goes down of Listview which I do not want I want Shadow to appear on top of ListView Items as we Scroll vertically , That's all please help me out
...Here is my code
Material(
elevation: 2,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.red,
blurRadius: 2,
spreadRadius: 2,
offset: Offset(0,2),
),
],
),
height: SizeConfig.isLargeScreen ? 60.h : 105.h,
width: double.infinity,
child: !SizeConfig.isLargeScreen),),
Note: I have given elevation 3 to my Listview card as well, Please let me know what i can do to make this container shadow go above Listview while Scrolling Vertically
I guess this can be solved by using padding widget, know more about the padding widget in ( https://youtu.be/oD5RtLhhubg ).
Another way to handle the issue adding a listView with separator, divider.
Still the problem continues check with margin of the container.
Finally on top of all since this is about container shadow you can try with the offset value in boxshadow property.
share with us, which method helps you to solve the issue or how did you solved the issue by trying something different.
You have two ways to solve this issue
the first one is to wrap your Material widget with Padding widget like this:
Padding(
Material(
elevation: 2,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.red,
blurRadius: 2,
spreadRadius: 2,
offset: Offset(0,2),
),
],
),
height: SizeConfig.isLargeScreen ? 60.h : 105.h,
width: double.infinity,
child: !SizeConfig.isLargeScreen),),),
or simply add SizedBox(height: 20,), under the Material widget it will make some space between the Material widget and the ListView then it will solve your issue
I'm using this swiper in a stack widget which is enclosed in a Card widget
Swiper(
itemBuilder: (BuildContext context, int index) {
return new Container(
// margin: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(16)),
border: Border.all(
color: Colors.grey,
)),
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(16)),
child: CachedNetworkImage(
imageUrl: post.mediaUrl,
),
),
);
},
itemCount: 10,
viewportFraction: 0.8,
scale: 0.9,
),
The Errors are as follows:
════════ Exception caught by scheduler library ═════════════════════════════════════════════════════
RenderBox was not laid out: RenderRepaintBoundary#4a53c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE DETACHED
'package:flutter/src/rendering/box.dart': Failed assertion: line 1694
pos 12: 'hasSize'
The following assertion was thrown while applying parent data.:
Incorrect use of ParentDataWidget.
The ParentDataWidget Expanded(flex: 1) wants to apply ParentData of
type FlexParentData to a RenderObject, which has been set up
to accept ParentData of incompatible type StackParentData.
Usually, this means that the Expanded widget has the wrong ancestor
RenderObjectWidget. Typically, Expanded widgets are placed directly
inside Flex widgets. The offending Expanded is currently placed inside
a Stack widget.
The ownership chain for the RenderObject that received the
incompatible parent data was: RepaintBoundary ←
NotificationListener ← GlowingOverscrollIndicator
← Scrollable ← NotificationListener ← PageView ←
NotificationListener ← TransformerPageView ←
Swiper ← Expanded ← ⋯
I am new to Flutter and I would like to know how you can create fragments
in the middle of an app like in this image right here.
Also I've been wondering if you can align the 'In Progress ' with 2 datetimeWidgets in a row
Thank you
enter image description here
You can try this one
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// your child widgets here
// In Progress widget + 2 date time Widget
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
ProgressWidget(),
Column(
children: <Widget>[
DateTimeWidget1(),
DateTimeWidget2(),
],
)
],
)
],
)
I need a FormField which contains both suffixIcon and Ordinary icon in a single row.
Here are the three ways to add icons to your textfield
TextField(
controller: ...,
decoration: InputDecoration(
icon: Icon(...), //Icon outside
prefixIcon: Icon(...), //Icon at the beginning
suffixIcon: Icon(...), //Icon at the end
),
),
You can use Row and add icon anywhere you want.
Container(
child: Row(
children: <widget>[
Icon(),
Icon(),
Expanded(child: TextField()),
Icon(),
Icon(),
]),
),