Card borderOnForeground isn't working as expected - flutter

Code:
Card(
color: Colors.blue,
borderOnForeground: false, // doesn't do anything on true also
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(300)),
child: Container(
width: 200,
height: 200,
color: Color(0x30FF0C5C),
child: Text(
"|||||||",
style: TextStyle(fontSize: 40),
),
),
)
Docs say:
borderOnForeground: Whether to paint the [shape] border in front of the [child].
The default value is true. If false, the border will be painted behind the [child].
Output:
Issue:
I want the white vertical lines to be inside the blue circle when by default (when borderOnForeground: true) but it doesn't do that, neither it does on setting it to false. What borderOnForeground actually does then?
NOTE:
I know there are many ways of achieving what I asked using ClipRRect, ClipOval etc. I am not looking for those solutions, I just want to know what borderOnForeground does?

The problem is you have no border (like in CSS) and that's why true and false look the same. To see the difference, add a thick border:
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(300.0),
),
side: BorderSide(
color: Colors.red,
width: 20.0,
),
),
and if you set borderOnForeground: false the part of the Card's child that was under the red border will now be above it.

Related

How to implement a background with a gradient border and a gradient background

What I want to implement is like this style. Pls see the picture below.
Need show
The border is gradient, start color is
#08FFFB
and the end color is
#FF4EEC
.And the background which like black is also gradient which start color is
#3A3A3A
and the end color is
#0B0B0B
The corner radius is 16.
I want to use it as a custom indicator in TabBar component. So, I custom the
indicator
like this.
#override
Widget build(BuildContext context) {
List\<String\> list = \["全部","读书","电影", "小说"\];
return Padding(
padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
child: Container(
width: double.infinity,
height: 62,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(20))),
child: Padding(
padding: EdgeInsets.fromLTRB(25, 13, 25, 13),
child: TabBar(
labelColor: Colors.white,
unselectedLabelColor: YYSColors.yysTextColor(),
isScrollable: true,
indicator: new BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: \<Color\>\[
Color(int.parse("FF3A3A3A", radix: 16)),
Color(int.parse("FF2B2B2B", radix: 16))
\],
),
borderRadius: BorderRadius.circular(16),
border: new Border.all(
color: Color(int.parse("FF08FFFB", radix: 16)), width: 2),
),
tabs: list
.map((String arenaType) {
return Tab(text: arenaType);
}).toList(),
),
),
),
),
);
}
I have tried to use image in BoxDecoration but it is not work. And I also get some informations from internet that maybe I can use a custom Widget extends Decoration, but I need to override paint() method. It is too difficulty to me. So I came here to ask for help. Thanks a lot.
It is my frist question at here. So the format is not that good. Pls forgive me.
Defining gradient for container is pretty straight forward,
For border gradient please follow this good blog.
https://blog.logrocket.com/how-to-create-simple-gradient-borders-flutter/
Design a gradient container.
Using Stack take the second container.

What is this icon name?

I want to use this icon on my Flutter app, unfortunately I do not know the name. Someone could tell me what's the name?
the three points icon is:
Icon(Icons.more_horiz)
and you can reach the same shape over it like this:
Container(
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
border: Border.all(
color: Colors.black,
width: 1,
),
),
child: Icon(Icons.more_horiz),
),
this will result in something like this, I didn't compare them, so changing just the padding and border, and border radius values will get you there

How can I create this circles for my flutter UI?

I want to create those blue circles (you can see them on the picture), the app UI design was created with Figma.
I don't even know how to start, I'm new at flutter
Any ideas or tips?
You can start learning from flutter.dev.
There are many ways to do this. I am using Container with decoration
Container(
height: 70,
width: 70,
padding: EdgeInsets.all(10), //spacing using padding
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(width: 5, color: Colors.blue),
),
child: const Material( //inner circle
color: Colors.green,
shape: CircleBorder(),
),
)
More about Container.

How to draw a dynamic height line in flutter?

I wanted to draw a dynamic height line, as shown in the given picture below
I did something line this using a continer with one sided border
Container(
child:(content goes here....)
margin: EdgeInsets.symmetric(horizontal:16+20.0),
decoration: BoxDecoration(
border: Border(
left: BorderSide(width: 2.0, color: Colors.lightBlue.shade600),
),
color: Colors.white,
),
)
but the issue is the corners(top and below) of the line is not rounded.
I want to draw a vertical line on the left side of my post, and on the right side goes the content.
You could try something like this:
IntrinsicHeight(
child: Row(
children: [
Container(
width: 5,
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)),
color: const Color(0x7f9e9e9e),
),
),
Expanded(child: **content goes here**),
],
),
)
And here's a DartPad example for you: Example
Which will produce something like this:
Where the bar on the left will size automatically with the contents on the right.

How to create outlined Card widget in Flutter

I want to include a outlined material card with flutter, but since the card widget doesn't have a style element or something similar, I am not sure how to implement this.
I tried using the shape: property but wasn't very successful, mostly because I didn't understand how it works.
Output:
It has shape property which takes a Border you can change that.
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40), // if you need this
side: BorderSide(
color: Colors.grey.withOpacity(0.2),
width: 1,
),
),
child: Container(
color: Colors.white,
width: 200,
height: 200,
),
)
I think the screenshot you showed can also be achieved by just using elevation property of the Card.