How do I convert CSS radial gradient to Flutter - css

How do I convert this CSS radial gradient to Flutter gradient:
background: radial-gradient(50% 50% at 50% 50%, #1AD4FD 0%, #2588FD 100%);
Gradient

Here's a rough equivalent :
Container(
decoration: const BoxDecoration(
gradient: RadialGradient(
colors: [
Color(0xFF1AD4FD),
Color(0xFF2588FD)
]
)
),
width: 320,
height: 180,
)

Related

How do I convert box shadow from CSS to Flutter

How do I convert this box shadow to Flutter?
box-shadow: 0px 4px 4px rgba(27, 31, 95, 0.4);
shadow
You can use BoxShadow on Container,
Container(
height: 200,
width: 500,
decoration: BoxDecoration(
color: Colors.blue,
boxShadow: [
///modify the way you like, you can have more
BoxShadow(
color: shadowColor,
blurRadius: 4,
offset: Offset(0, 4),
)
],
),
),
As for the look, the UI is similar to Card widget
Card(
elevation: 4, //use it
child: SizedBox(),
),

How to add multiple linear gradient properties for background with material ui?

I am trying to apply two linear gradient at the same time to my background property.
In CSS, this is what I wanted to achieve.
background: linear-gradient(to bottom right, #dbeaff, #f3dfde), linear-gradient(to top right, #f7faff, #dbcff3);
In material ui, I applied the same rule for my Paper component with 'sx' as below, but it seems to only apply the first linear gradient, not both.
<Paper elevation={1} sx={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
borderRadius: '18px',
flexWrap: 'wrap',
minWidth: '320px',
background: 'linear-gradient(to bottom right, #dbeaff, #f3dfde), linear-gradient(to top right, #f7faff, #dbcff3)',
'& > :not(style)': {
m: 1,
p: 1,
},
}}>
Any suggestions?

How to use some CSS elements in flutter

Hello guys I was looking for something and dind't found any answer.
I'm trying to find something like position: absolute; background-image: radial-gradient(circle at 50% 48.193905%, rgb(13, 114, 255) 0%, transparent 100%); filter: brightness(109); to use in flutter, but with no success. My main problem is on the circle % and the brightness. Is flutter not providing these ?
Or is there any widget that allow us to do that?
Currently I'm using something like this
Container(
decoration: BoxDecoration(
gradient: RadialGradient(
colors: [
myColor(fColor),
Color(0x00000000)
],
radius: 1.0,
),
),
);
Thanks you
For radial gradient, wrap your widget in a Container and pass a decoration -
Container(
decoration: BoxDecoration(
gradient: RadialGradient(...some configuration)
For filters, try using BackdropFilter. Check out the official flutter docs
For absolute positioning, you'd need a bit more. Use Stack and wrap its children with Align or Positioned.
You can move the gradient around using 'center' parameter to move it across x and y axis (x, y)
Example:
decoration: BoxDecoration(
gradient: RadialGradient(
colors: [
Colors.black,
Colors.pink,
Colors.green,
Colors.orange,
],
center: Alignment(-0.5, -0.20), //(x,y)
// focal: Alignment(0.7, -0.01),
// focalRadius: 4.0,
),
You can also use focal and focalRadius parameters to adjust the focal. You can see more useful details on this link https://www.woolha.com/tutorials/flutter-using-radialgradient-examples
If you want to add an image on top of the gradient, you can do it with an Opacity and Stack Widget.
Example:
Stack(
children: [
Container(
height: 225,
decoration: BoxDecoration(
gradient: RadialGradient(
colors: [
Colors.black,
Colors.orange,
Colors.pink,
Colors.green,
],
center: Alignment.topRight,
tileMode: TileMode.repeated,
),
borderRadius: BorderRadius.circular(
25.0,
),
border: Border.all(color: Colors.black),
boxShadow: [
BoxShadow(
color: Colors.red,
blurRadius: 5.0,
),
],
),
),
Stack(
children: [
Opacity(
opacity: 0.6,
child: Image(
width: MediaQuery.of(context).size.width,
image: AssetImage('lib/assets/imgs/example.jpg'),
fit: BoxFit.fill,
),
),
],
)
],
),

change the color of Highmap

I'm working on with Highmaps and this is the one I use :
http://www.highcharts.com/maps/demo/data-class-ranges
In this map the colors for different countries goes from white to blue I want to change that to "Red to Blue" gradient like in this css example :
background: -webkit-linear-gradient(red, yellow, green, blue); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(red, yellow, green, blue); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(red, yellow, green, blue); /* For Firefox 3.6 to 15 */
background: linear-gradient(red, yellow, green, blue); /* Standard syntax (must be last) */
How can I do that ?
You can specify colors in the colorAxis object.
colorAxis: {
dataClasses: [{
to: 3,
color: "red"
}, {
from: 3,
to: 10,
color: "yellow"
}, {
from: 10,
to: 30,
color: "green"
}, {
from: 30,
to: 100,
color: "blue"
}, {
from: 100,
to: 300,
color: "pink"
}, {
from: 300,
to: 1000,
color: "purple"
}, {
from: 1000,
color: "black"
}]
},
Hex values like #FF0000 work as well.
Working example: http://jsfiddle.net/8wcntpcz/
EDIT:
Docs: http://api.highcharts.com/highmaps#colorAxis.dataClasses

css style in the ext js combo box

My code:
{
border: 1,
bodyStyle: 'margin:0 0 0 140px;',
style: {
borderColor: 'black',
borderStyle: 'solid', //margin:'0 0 0 140' //margin-left: '140px' }, width: 140, name: 'comp', id:'compId', triggerAction: 'all', mode: 'local', store: new Ext.data.SimpleStore({
fields: ['myId', 'displayText'],
data: [
[1, 'item1'],
[2, 'item2']
]
}), displayField: 'displayText', xtype: 'combo',
},
here in ext js 2.3 bodyStyle is not getting appended to the combobox.Can anyone suggest how to resolve this?
Thanks
I think this could be what you need.
{
xtype: 'combo'
style : 'margin-left: 140px; border: solid black 1px;',
name: 'comp',
id:'compId',
triggerAction: 'all',
mode: 'local',
store: new Ext.data.SimpleStore({
fields: ['myId', 'displayText'],
data: [
[1, 'item1'],
[2, 'item2']
]
}),
displayField: 'displayText',
valueField : 'myId'
}
Note there is no bodyStyle config option according to the docs - http://docs.sencha.com/extjs/2.3.0/#!/api/Ext.form.ComboBox
I removed the width option as with the margin-left style attribute (also 140px) I thought you may end up with something odd looking.
combo.js :
{xtype:'combobox', cls:'combo'}
combo.css:
.combo .x-boundlist-selected {
background: #757575;
background-image: -webkit-linear-gradient(top, #757575, #474747);
background-image: -moz-linear-gradient(top, #757575, #474747);
background-image: -ms-linear-gradient(top, #757575, #474747);
background-image: -o-linear-gradient(top, #757575, #474747);
background-image: linear-gradient(to bottom, #757575, #474747);
border: solid #4e4e4e 2px;
color: #ffffff;
text-decoration: none;
}
.combo .x-boundlist-item {
background: #757575;
background-image: -webkit-linear-gradient(top, #757575, #474747);
background-image: -moz-linear-gradient(top, #757575, #474747);
background-image: -ms-linear-gradient(top, #757575, #474747);
background-image: -o-linear-gradient(top, #757575, #474747);
background-image: linear-gradient(to bottom, #757575, #474747);
border: solid #4e4e4e 2px;
color: #ffffff;
text-decoration: none;
}
this is one of the code that used bodyStyle atribute in 2.3 version
this may help you.
this.itemCombo= new Ext.form.ComboBox({
name : "combooo",
fieldLabel : "Status",
displayField : 'combo',
valueField : 'id',
mode : 'local',
triggerAction : 'all',
hiddenName : "comboo",
editable : false,
width : 100,
store : this.store,
value : "0"
});
this.frmPanel = new Ext.form.FormPanel({
bodyStyle : "padding:10px",
border : true,
autoScroll : true,
layout : "table",
layoutConfig : {
columns : 1,
style : "vertical-align:top"
},
items : [{
bodyStyle : "padding-right:10px",
xtype : "panel",
layout : "form",
border : false,
labelWidth : 110,
colspan : 2,
items : [this.item1,this.itemCombo]
}]
});

Resources