How to Convert CSS Gradient to Flutter Gradient - css

How to convert CSS Gradient
background: linear-gradient(177.82deg, rgba(138, 160, 55, 0.2) 51.9%, #8E9B5E 69.3%);
to Flutter Gradient?

you just need to know :
the hex colors of the Gradient
the direction (like at my example it's from top to bottom and to say it to Flutter, it'll be from topCenter bottomCenter)
see the code example:
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.red.withOpacity(0.1),
Colors.green.withOpacity(0.8),
],
),
),
)
Note number 1:
that I just used the red and the green to make it clear for you, but you can use the hex colors like that
convert just the hashtag to 0xff like:
#8E9B5E
to
0xff8E9B5E
and you can replace:
Colors.red.withOpacity(0.1),
to be like:
Color(0xff8E9B5E),
Note number 3:
the function of .withOpacity(0.1) is just for Opacity like the percentage of the color appearance (from 0.0 to 1.0) and you can change the value of the Opacity or delete it if you want and use just Colors.red or Color(0xff8E9B5E)

Related

Changing icons to images

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.

How to remove the space between SpinBox content and underline?

My question is essentially the same as How to remove Space at the bottom of TextField in flutter?, except instead of a TextFormField widget, I am asking the same for a SpinBox widget. Setting isDense: true or isCollapsed: true seems to move the number out of line with the increment/decrement buttons (see screenshots)
Meanwhile, wrapping in a SizedBox and setting height is some improvement, but I am not able to shrink height as much as I would like, or increment/decrement go below the line.
This is with a height of 25:
Having a height of 45 looks visually fine but it takes up too much space for my needs.
Current code which produces the layout below:
SizedBox(
width: 120,
height: 45,
child: SpinBox(
value: 0,
onChanged: (value) {}
),
)
Looking at the source code of the SpinBox you can see that you have the inputDecoration of the TextField exposed, and you can try removing the contentPadding of it and see if it fixes your issue :
SpinBox(
decoration: InputDecoration(
contentPadding: EdgeInsets.zero,
),
);

TabBar Fixed Container Shadow goes down of ListView while scrolling vertically in flutter

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

Polyline Stroke Color with Alpha doesn't work in Here API v3.1

I am migrating from the v3.0 of the Here Javascript API to v3.1, and it seems that the latest version doesn't support alpha values for the strokeColor of Polylines. If your use an 8 digit hex code (the last two digits being alpha), the line is displayed as White. This worked fine in version 3.0 and is handy when displaying overlapping routes.
Here's an example JSFiddle: http://jsfiddle.net/phil_sweeney/mk2z761j/
// '4d' = 30% alpha
map.addObject(new H.map.Polyline(
lineString, { style: {strokeColor:'#f7a36f4d', lineWidth: 4 }}
));
strokeColor is set to: '#f7a36f4d'. If you remove the '4d' from the end (30% alpha), you'll get an orange-ish line.
Is this considered a bug which is going to be fixed - or is this just the way it's going to be from here out?
It looks like an issue on WEBGL rendering engine.
For now I suggest using rgba instead of hexadecimal color:
map.addObject(new H.map.Polyline(
lineString, { style: {strokeColor:'rgba(247, 163, 111, 0.3)', lineWidth: 4 }}
));

Highmaps border color of region

I am using Highmaps in one of my web based application. Until now it was easy to modify it according to my use case but now i need to changes the border color of the region and i am unable to do it.
Code i have tried but failed:
chart: {
plotBorderColor: '#ffffff',
borderColor: "#ffffff",
}
See attached image what i want to achieve
Want to change the outline color to white
http://jsfiddle.net/qLen614m/
You can use the stroke attribute of the path element:
path {
stroke: white;
}
There is an options to set border color for map series. It is borderColor and it should be set in series.
series : [{
borderColor: 'white',
...
API link
Example: http://jsfiddle.net/qLen614m/1/
You should use borderWidth property for series.
The border width of each map area.
series: [{
borderWidth: 2
}]
Here is the official demo.

Resources