I want to create this color gradient in flutter.
The corresponding css which achieves this is background: linear-gradient(180deg, rgba(1, 79, 134, 0.4) 0%, #014F86 100%)
I have tried everything from setting stops in LinearGradient to setting transform as transform: GradientRotation(pi), to set the radiant to 180 degree as stated in the corresponding css. I also tried setting the points manually in x and y axis using Alignment in begin and end parameters. Nothing seems to work though. Added a sample to show everything I tried so far. Not the exact code I tried but tried playing around commenting out various parts but no luck so far.
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: <Color>[
Color(0XFF014F86),
Color(0XFF014F86),
// Color(0XFF5575a3),
// Color(0XFF8b9ec1),
// Color(0XFFbfc9e0),
// Color(0XFFf3f6ff),
],
transform: GradientRotation(pi),
stops: [0.4, 1],
),
I also have the corresponding android native vector that achieves the same.
<!-- Rectangle 6 -->
<View
android:id="#+id/rectangle_6"
android:layout_width="311dp"
android:layout_height="37dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="32dp"
android:layout_alignParentTop="true"
android:layout_marginTop="257dp"
android:background="#drawable/rectangle_6"
android:elevation="18dp"
/>
<!-- drawable/rectangle_6.xml -->
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="311dp"
android:height="37dp"
android:viewportWidth="311"
android:viewportHeight="37"
>
<group>
<clip-path
android:pathData="M8 0H303C307.418 0 311 3.58172 311 8V29C311 33.4183 307.418 37 303 37H8C3.58172 37 0 33.4183 0 29V8C0 3.58172 3.58172 0 8 0Z"
/>
<group
android:translateX="1.029"
android:translateY="0"
android:pivotX="155.5"
android:pivotY="18.5"
android:scaleX="2.106"
android:scaleY="2"
android:rotation="90"
>
<path
android:pathData="M0 0V37H311V0"
>
<aapt:attr name="android:fillColor">
<gradient
android:type="linear"
android:startX="77.75"
android:startY="18.5"
android:endX="233.25"
android:endY="18.5"
>
<item
android:color="#66014F86"
android:offset="0"
/>
<item
android:color="#014F86"
android:offset="1"
/>
</gradient>
</aapt:attr>
</path>
</group>
</group>
</vector>
Any help on how to achieve this using BoxDecoration and LinearGradient in a Flutter Container would be greatly appreciated!
LinearGradient(
colors: [Color(0xff0373c4), Color(0xff014f86)],
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
)
You can use this online tool to generate it :
online tool
Related
There is no problem with the assets path in the "pubspec.yaml" file because there are other svg that appear from the same path as well.
svg code 👇 after cleaning in SVG cleaner
<svg height="22" viewBox="0 0 34 22" width="34" xmlns="http://www.w3.org/2000/svg">
<g fill="none" stroke="#e5b74b" stroke-linecap="round" stroke-linejoin="round">
<path d="m34.5 10.5-10.5 7.5 10.5 7.5z" />
<path
d="m4.5 7.5h16.5a3 3 0 0 1 3 3v15a3 3 0 0 1 -3 3h-16.5a3 3 0 0 1 -3-3v-15a3 3 0 0 1 3-3z"
transform="translate(-1 -7)"
/>
</g>
</svg>
error: 👇
════════ Exception caught by SVG ═══ Unable to load asset:
packages/icons/assets/svgs/post_your_listing/Icon feather_video.svg
══════
just these lines without any details
my assets in the workspace, and just 7 icons not appearing in the flutter app, so the path in "pubspec.yaml" with no problem!
in pubspec.yaml
code:
SvgPicture.asset(
icon,
color: orange,
height: 35,
package: 'icons',
),
add you SVG assets file path in pubspec.yml like this
assets:
- assets/test.svg
and then load SVG files via path
SvgPicture.asset(
"assets/test.svg",
color: orange,
height: 35,
package: 'icons',
),
I am using react native svg charts to display some data on line chart .the data is associated with some time which need to be labelled on x axis can anybody tell me how can I do it.
When we look at LineChart, it draws the lines like this.
It accepts 50 as points and 10 points and draws a line between
It accepts 10 as points and 40 points and draws a line between
class LineChartExample extends React.PureComponent {
render() {
const data = [50, 10, 40, 95, -4, -24, 85, 91, 35, 53, -53, 24, 50, -20, -80]
return (
<LineChart
style={{ height: 200 }}
data={data}
svg={{ stroke: 'rgb(134, 65, 244)' }}
contentInset={{ top: 20, bottom: 20 }}
>
<Grid />
</LineChart>
)
}
}
I want to put opacity for container which contain hexadecimal color code. How can it be done?
Here is my current code:
final body = Container(
width: MediaQuery.of(context).size.width,
margin: const EdgeInsets.only(left: 40.0, right: 40.0),
padding: EdgeInsets.all(28.0),
decoration: new BoxDecoration(
color: const Color(0xFF0E3311),//here i want to add opacity
border: new Border.all(color: Colors.black54,
),
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(40.0),
topRight: const Radius.circular(40.0),
bottomLeft: const Radius.circular(40.0),
bottomRight:const Radius.circular(40.0) )
),
child: Column(
children: <Widget>[ email, password,loginButton],
),
);
Change the line
const Color(0xFF0E3311)
to
const Color(0xFF0E3311).withOpacity(0.5)
or any value you want.
If you just want to set an opacity to your color it's simple as adding 2 hex numbers before your color code. Check this answer to know all the values.
But if you want to change the opacity of all the widget, in your case a Container, you can wrap it into a Opacity widget like this:
double _opacityValue = 0.50;//This value goes from 0.0 to 1.0. In this case the opacity is from 50%
final Widget _bodyWithOpacity = Opacity(
opacity: _opacityValue,
child: body,
);
Check here the Opacity's documentation and this quick video if you want to know more about it!
Flutter uses hexadecimal ARGB values for colors, which are formatted as const Color(0xAARRGGBB). That first pair of letters, the AA, represent the alpha channel. You must convert your decimal opacity values to a hexadecimal value.
Hex Opacity Values:
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
60% — 99
55% — 8C
50% — 80
45% — 73
40% — 66
35% — 59
30% — 4D
25% — 40
20% — 33
15% — 26
10% — 1A
5% — 0D
0% — 00
For instance:
static const Color mainColor = Color(0xff0097A7);
to:
static Color accentColor = Color(0x1A0097A7);
will change the opacity to 10%.
We can use Color.fromRGBO(255, 255, 255, 0.5) for opacity as well.
Flutter uses a 32 bit color value in ARGB format, where A = Alpha, R = RED, G = GREEN and B = BLUE.
So to control the opacity you can change the values of first two digits of the hex value in const Color(0xFF0E3311), you can use values ranging from 0x000E3311,0x010E3311....0xFF0E3311.
Hope that helps!
here in code
const Color(0xFF0E3311)
after 0x two values (in above code 'FF') are for opacity. 'FF' for opaque and '00' for fully transparent. so by altering this value you can change color opacity.
Also we get by Colors class diff opacity value color for white and black. for example
Colors.white70 means white color with 70% opacity
I am new to OSM.
I have the document https://trac.openstreetmap.org/browser/subversion/applications/rendering/osmarender6/osm-map-features-z14.xml?rev=10976
This document describe set of rules for certain zoom.
There are rules that uses an image (svg) objects, e.g:
<rule e="node" k="waterway" v="lock_gate">
<wayMarker k="waterway" class="canal-lock"/>
</rule>
And there is CSS for canal-lock in the same file:
.canal-lock {
fill: none;
stroke: #ffffff;
stroke-width: 0.1px;
stroke-opacity: 0;
marker-mid: url(#canal-lock);
}
And finally, at the bottom of the document there is:
<svg:marker fill="none" id="canal-lock" markerHeight="5.9px" markerUnits="userSpaceOnUse" markerWidth="5.9px" orient="auto" refX="1px" refY="5px" stroke="#000000" stroke-width="0.75px" stroke-opacity="1" viewBox="0 0 10 10">
<svg:path d="M 1,0 L -2,5 L 1,10"/>
</svg:marker>
My Question is, Where does the canal-lock image is obtained from. i could not find that svg on the site, and my map seems to not working well since its looking for this image.
How to design GridView in such a way that it display 3 images per row and can be scrolled up for the other Images behind? it seems this gridView displays images in a row.
Below I have 8 Pic in Gridview:
1) How to setup GridView to displays images with(3 images per row) or without specifying number of images per row and the rest will be viewed by scrolling up?
Thanks
< GridView HorizontalAlignment="Left" Margin="30,200,0,0" Grid.Row="1" VerticalAlignment="Top" Width="800" Height="400" >
//-- pic 1
< GridViewItem>
< Grid HorizontalAlignment="Left" Width="200" Height="200">
< Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}">
< Image Source="Images/M123.jpg" Tag="name" Tapped="Image_Tapped_1" Stretch="UniformToFill"/>
< /Border>
< StackPanel VerticalAlignment="Bottom" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}">
< TextBlock FontSize="30" Text="name" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}"
Style="{StaticResource TitleTextStyle}" Height="40" Margin="15,10,15,0"/>
</StackPanel>
</Grid>
</GridViewItem>
//- pic 2 using GridViewItem
//-- pic 3 using GridViewItem
//--- Pic 3 to Pic 8 GridViewItem
< / GridView>
Put the grid view in a scrollviewer and let the height of the gridview be auto ie it will take the height of the entire content and width of the grid view to a specific one so that t cqn take only 3 items
next step is to just enable the vertical scroll property of the scroll viewer and disable the horizontal scroll property.
i hope this solves the purpose .
try to use jquery plugin
http://gridviewscroll.aspcity.idv.tw/
function gridviewScroll() {
$('#<%=gvMain.ClientID%>').gridviewScroll({
width: 700,
height: 330,
freezesize: 2,
arrowsize: 30,
varrowtopimg: "Images/arrowvt.png",
varrowbottomimg: "Images/arrowvb.png",
harrowleftimg: "Images/arrowhl.png",
harrowrightimg: "Images/arrowhr.png",
headerrowcount: 2
});
}