Flutter : the two container radius has a small line shadow - flutter

Now I am trying to draw a container with the radius border to intersect with another container
But there is a line that remains visible around each container as shown in the picture Does anyone know how to hide it!
there is my code for that
Container(
height: MediaQuery.of(context).size.height * .47,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Color.fromRGBO(28, 163, 200, 1),
border: null,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(30.0),
//bottomLeft: Radius.circular(40.0),
),
),
),
Container(
color: Colors.transparent,
child: Container(
width: MediaQuery.of(context).size.width,
color: Color.fromRGBO(28, 163, 200, 1),
child: Container(
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Color.fromRGBO(247, 250, 251, 1),
border: null,
borderRadius: BorderRadius.only(
topRight: Radius.circular(30.0),
//bottomLeft: Radius.circular(40.0),
),
),
child: Padding(
padding: const EdgeInsets.only(left: 20, right: 20, top: 20),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"القائمة",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
color: Colors.black),
),
Spacer(),
Text(
"عرض الكل",
style: TextStyle(
fontSize: 14,
color: Color.fromRGBO(255, 140, 0, 1)),
),
],
),
),
),
),
),

sounds like a renderer artifact, if you change the top container height ratio it goes away
height: MediaQuery.of(context).size.height * .47, // <-- change this to be 0.5
if you really want that particular height, then use a Stack() rather than embedded Containers

if you change the hight of the container it will render correctly. I have attached a screenshot of the result I get with this:
Column(
children: [
Container(
height: 300, //<--- This is what's causing the issue
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Color.fromRGBO(28, 163, 200, 1),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(30.0),
//bottomLeft: Radius.circular(40.0),
),
),
),
Container(
// color: Colors.transparent,
child: Container(
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Color.fromRGBO(28, 163, 200, 1),
),
child: Container(
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Color.fromRGBO(247, 250, 251, 1),
borderRadius: BorderRadius.only(
topRight: Radius.circular(30.0),
//bottomLeft: Radius.circular(40.0),
),
),
child: Padding(
padding: const EdgeInsets.only(left: 20, right: 20, top: 20),
child: Row(
children: [
Text(
"القائمة",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.black),
),
Spacer(),
Text(
"عرض الكل",
style: TextStyle(fontSize: 14, color: Color.fromRGBO(255, 140, 0, 1)),
),
],
),
),
),
),
),
],
)

Related

Make Container take content size of child

I'm new in Flutter,
I have a Container which child is Stack that using Positioned inside.
My problem is Container just taking Non-Positioned widget size.
Here is my problem:
I want something like this:
Here is my Widget code:
class CheckUpItem extends StatelessWidget {
const CheckUpItem({
Key? key,
}) : super(key: key);
#override
Widget build(BuildContext context) {
return SizedBox(
width: 100,
child: Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
color: Colors.white,
border: Border.fromBorderSide(
BorderSide(
width: 1,
color: Color(0xFFBAD9F8),
),
),
boxShadow: [
BoxShadow(
color: Color(0x00000029),
offset: Offset(2, 3),
blurRadius: 2,
),
],
),
child: Column(
children: [
ClipRRect(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(4),
topRight: Radius.circular(4),
),
child: Container(
decoration: const BoxDecoration(
color: Color(0xFFE6F6FF),
border: Border(
bottom: BorderSide(
width: 1,
color: Color(0xFFBAD9F8),
),
),
),
child: Consumer(
builder: (context, ref, child) {
return Center(
child: Text(
'BMI',
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
height: 1.43,
color: Color(0xFF6B6B6B),
),
),
);
},
),
),
),
Container(
padding: const EdgeInsets.only(top: 5.5, bottom: 4),
child: Column(
children: [
Stack(
clipBehavior: Clip.none,
children: [
Container(
width: 36,
height: 36,
decoration: const BoxDecoration(
shape: BoxShape.circle,
border: Border.fromBorderSide(
BorderSide(
width: 2,
color: Color(0xFFBF3D3D),
),
),
color: Color(0xFFF86060),
),
child: const Center(
child: Text(
'B',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
height: 1,
fontSize: 20,
),
),
),
),
Positioned(
bottom: -6,
left: 26,
child: Container(
width: 22,
height: 22,
padding: const EdgeInsets.fromLTRB(1, 0, 3, 2),
decoration: const BoxDecoration(
border: Border.fromBorderSide(
BorderSide(
width: 1,
color: Color(0xFF6A8FD4),
),
),
color: Color(0xFFE0EEFC),
shape: BoxShape.circle,
),
child: SvgPicture.asset(ImageAssets.speaker),
),
),
],
),
const SizedBox(height: 6),
],
),
),
],
),
),
);
}
}
I'm stucking all day with this, I'm tempary using Column and const SizedBox(height: 6) for fake height.
How to make it right way?
P/s: Sorry, my English is not good!
Because every thing is static hear and you know how much the svg container going down, you can calculate it and add it to padding bottom, like this:
Container(
padding: const EdgeInsets.only(top: 5.5, bottom: 10), // 4 + 6(Positioned bottom)
child: Stack(
clipBehavior: Clip.none,
children: [
Container(
width: 36,
height: 36,
decoration: const BoxDecoration(
shape: BoxShape.circle,
border: Border.fromBorderSide(
BorderSide(
width: 2,
color: Color(0xFFBF3D3D),
),
),
color: Color(0xFFF86060),
),
child: const Center(
child: Text(
'B',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
height: 1,
fontSize: 20,
),
),
),
),
Positioned(
bottom: -6,
left: 26,
child: Container(
height: 22,
width: 22,
decoration: const BoxDecoration(
border: Border.fromBorderSide(
BorderSide(
width: 1,
color: Color(0xFF6A8FD4),
),
),
color: Color(0xFFE0EEFC),
shape: BoxShape.circle,
),
child: SvgPicture.asset(
'assets/images/tes.svg',
),
),
),
],
),
),

How do I make a Label with two containers. One smaller and another bigger

I'm trying to do this design
Which widget should I use to approach this result?
There are two tags and they are overlapped.
So you can use "Stack" to build it:
Widget _buildCustomTag() {
Radius radius = Radius.circular(6);
return Container(
height: 60,
margin: EdgeInsets.symmetric(horizontal: 4), // this is just for checking the view
child: Stack(
children: [
Positioned.fill(
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius:
BorderRadius.only(topRight: radius, bottomRight: radius)),
margin: EdgeInsets.symmetric(vertical: 4),
padding: EdgeInsets.symmetric(horizontal: 20),
alignment: Alignment.centerRight,
child: Text('R\$ 99,90'),
)),
Positioned(
top: 0,
bottom: 0,
child: Container(
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.only(
topRight: radius, bottomRight: radius)),
alignment: Alignment.center,
padding: EdgeInsets.only(right: 8, left: 20),
child: Text('05/01/2021'),
)),
],
));
}
You can use Expanded widget and adding its flex width value.
Row(
children: [
Expanded(
flex: 1,
child: Container(),
),
Expanded(
flex: 2,
child: Container(),
),
],
),
You should use Expanded or Flexible widget for that use below code :
Row(
children: [
Flexible(
flex: 1,
child: Container(
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.redAccent,
borderRadius: BorderRadius.only(
topRight: Radius.circular(10),
bottomRight: Radius.circular(10),
),
),
height: 50,
child: Text(
'05/01/2021',
style: TextStyle(
fontSize: 17,
color: Colors.white,
),
textAlign: TextAlign.center,
),
),
),
Flexible(
flex: 2,
child: Container(
padding: EdgeInsets.all(10),
alignment: Alignment.centerRight,
decoration: BoxDecoration(
color: Colors.grey.shade300,
borderRadius: BorderRadius.only(
topRight: Radius.circular(10),
bottomRight: Radius.circular(10),
),
),
height: 45,
child: Text(
'R\$ 99,90',
style: TextStyle(
fontSize: 17,
color: Colors.black,
),
textAlign: TextAlign.center,
),
),
),
],
),
Your screen look like ->

Flutter Card and Container design

I wanted to achieve this:
But I end up getting this (ignore the color):
How can I shape the border of the colored border side, I keep getting this weird error (or at least I have never encounter one), I shape the topLeft and bottomLeft border and it pops up A borderRadius can only be given for a uniform Border. What am I doing wrong here? I have placed a Container inside a Card widget, I tried the other way around, but not the results I expected. I now have what I need, I just need to round the topLeft and bottomLeft corner of the Container (Or maybe something else) to achieve the goal from the first picture with the blue colour.
Here is the code:
Container(
height: 98.0,
width: double.infinity,
child: Card(
elevation: 4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4.0),
),
shadowColor: Color.fromRGBO(0, 0, 0, 0.6),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10), //this is causing the error, when I remove it, I get the card like on picture 2 with the red line
border: Border(
left: BorderSide(
color: Colors.red,
width: 3.0,
style: BorderStyle.solid),
),
),
child: Row(
// some content here
],
),
),
),
),
Thanks in advance for the help!
please try with this
Padding(
padding: const EdgeInsets.all(8.0),
child: Card(
color: Colors.green,
elevation: 16,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
child: Wrap(
children: [
Container(
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(10),
topRight: Radius.circular(10))),
margin: EdgeInsets.only(left: 10),
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Dr. Alok Verma",
style: TextStyle(fontSize: 24),
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text("Date: 14-06-2021",
style: TextStyle(fontSize: 24))),
Expanded(
child: FlatButton(
onPressed: () {},
child: Container(
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(5)),
padding: EdgeInsets.all(8),
child: Text("Completed",
style: TextStyle(fontSize: 24)))))
],
),
Text("Time: 10:20", style: TextStyle(fontSize: 24)),
SizedBox(
height: 20,
),
Text("Aastha Hospital",
style: TextStyle(
fontSize: 24, fontWeight: FontWeight.bold)),
Text("Some address", style: TextStyle(fontSize: 18)),
],
),
)
],
),
),
)
image:

Adjust size Container?

I'm new to flutter, I'm trying to change size of a container, but it not change even i change height:150 and width=150, I just want green screen show about 1/5 screen, but i really don't know how to fix this. I don't understand why, when changing the height and width of the Container, nothing will change
here is code
return Container(
decoration: new BoxDecoration(color: Colors.white),
child: new MaterialApp(
title: "Sample",
debugShowCheckedModeBanner: false,
home: Container(
height: 150.0,
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(30),
bottomRight: Radius.circular(30),
)),
child: Stack(
children: [
Positioned(
top: 150,
left: 0,
child: Row(
children: <Widget>[
SvgPicture.asset(
user,
width: 60,
height: 60,
),
SizedBox(
width: 10,
),
Text(
"Welcome back, $username",
style: TextStyle(
fontSize: 20,
fontFamily: fontRegular,
decoration: TextDecoration.none,
color: Colors.white,
),
),
SizedBox(
width: 10,
),
Container(
padding: const EdgeInsets.all(5.0),
decoration: BoxDecoration(
border: Border.all(width: 1.5, color: Colors.black),
color: Color.fromRGBO(230, 230, 230, 1),
borderRadius: BorderRadius.circular(30),
),
child: Row(
children: [
SvgPicture.asset(
"assert\\dollar.svg",
height: 25,
width: 25,
),
Text(
'$coinValue',
style: TextStyle(
fontSize: 18,
color: Colors.black,
decoration: TextDecoration.none),
),
],
),
),
SizedBox(
width: 13,
),
],
),
),
],
),
),
),
);
}
Here is result
i just want something like this
hope this helps you:
Add Scaffold around the inner container (the one with height 150 )... and you don't need the stack and positioned(the content won't show up if you don't remove them):
MaterialApp(
title: "Sample",
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Container(
height: 150.0,
decoration: ...
Rewrite your code as below:
home: Scaffold(
body: SafeArea(
child: Container(
height: 150.0,
decoration: BoxDecoration(
color: Colors.green,
),
child: Row(
children: <Widget>[
SizedBox(
width: 10,
),
Text(
"Welcome back",
style: TextStyle(
fontSize: 20,
//fontFamily: fontRegular,
decoration: TextDecoration.none,
color: Colors.white,
),
),
SizedBox(
width: 10,
),
Container(
padding: const EdgeInsets.all(5.0),
decoration: BoxDecoration(
border: Border.all(width: 1.5, color: Colors.black),
color: Color.fromRGBO(230, 230, 230, 1),
borderRadius: BorderRadius.circular(30),
),
child: Row(
children: [
Text(
'dsfsfsf',
style: TextStyle(
fontSize: 18,
color: Colors.black,
decoration: TextDecoration.none),
),
],
),
),
SizedBox(
width: 13,
),
],
),
),
),
),
You have the Stack widget inside your Container widget. That is why it is taking the whole screen. Try removing the Stack widget.
return Container(
decoration: new BoxDecoration(color: Colors.white),
child: new MaterialApp(
title: "Sample",
debugShowCheckedModeBanner: false,
home: Container(
height: 150.0,
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(30),
bottomRight: Radius.circular(30),
)),
child: Positioned(
top: 150,
left: 0,
child: Row(
children: <Widget>[
SvgPicture.asset(
user,
width: 60,
height: 60,
),
SizedBox(
width: 10,
),
Text(
"Welcome back, $username",
style: TextStyle(
fontSize: 20,
fontFamily: fontRegular,
decoration: TextDecoration.none,
color: Colors.white,
),
),
SizedBox(
width: 10,
),
Container(
padding: const EdgeInsets.all(5.0),
decoration: BoxDecoration(
border: Border.all(width: 1.5, color: Colors.black),
color: Color.fromRGBO(230, 230, 230, 1),
borderRadius: BorderRadius.circular(30),
),
child: Row(
children: [
SvgPicture.asset(
"assert\\dollar.svg",
height: 25,
width: 25,
),
Text(
'$coinValue',
style: TextStyle(
fontSize: 18,
color: Colors.black,
decoration: TextDecoration.none),
),
],
),
),
SizedBox(
width: 13,
),
),
],
),
),
),
);
Do as follows
Container(
height: 150,
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(20),
bottomLeft: Radius.circular(20))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
radius: 30.0,
backgroundImage: NetworkImage('https://via.placeholder.com/150'),
backgroundColor: Colors.transparent,
),
Expanded(child:Text("Hey there, Welcome back LQK!")),
Container(
width:100,
padding: const EdgeInsets.all(5.0),
decoration: BoxDecoration(
border: Border.all(width: 1.5, color: Colors.black),
color: Color.fromRGBO(230, 230, 230, 1),
borderRadius: BorderRadius.circular(30),
),
child: Row(
children: [
Icon(Icons.search) //put your desired icon here
],
),
),
],
)

How to go from one feed to another in flutter as same as in instagram

I am trying to apply the same concept of instagram to go from one feed to another.
Here i have like quiz1 part and i want to go to the another quiz2 section on tapping to to the right side and after pressing left side i want to go for quiz1 section.
Widget mainQuiz() {
return Column(
children: [
Spacer(
flex: 1,
),
Container(
padding: EdgeInsets.all(30),
child: Text(
"When was the first spaceship NOT launched?",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 24,
),
),
),
/* ---------------------OPTION 1----------------------*/
Container(
margin: EdgeInsets.only(
left: 65,
right: 65,
bottom: 15,
),
decoration: BoxDecoration(
border: Border.all(color: Colors.white),
borderRadius: BorderRadius.circular(100)),
child: Row(
children: [
Container(
margin: EdgeInsets.all(10),
child: Row(
children: [
Stack(
children: [
Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.white),
shape: BoxShape.circle,
),
child: Icon(
Icons.check,
size: 15,
color: Color(0xffFFC700),
),
)
],
),
Text(
"Last Tuesday",
style: TextStyle(
color: Colors.white,
fontSize: 16,
),
),
],
),
),
Spacer(),
Container(
constraints: BoxConstraints.expand(
height: 40,
width: 50,
),
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.only(
topRight: Radius.circular(100),
bottomRight: Radius.circular(100),
),
),
child: Center(
child: Text(
"55%",
style: TextStyle(
color: Colors.white,
fontSize: 16,
),
),
),
),
],
),
),
/* ---------------------OPTION 2----------------------*/
Container(
margin: EdgeInsets.only(
left: 65,
right: 65,
bottom: 15,
),
decoration: BoxDecoration(
border: Border.all(color: Colors.white),
borderRadius: BorderRadius.circular(100)),
child: Row(
children: [
Container(
margin: EdgeInsets.all(10),
child: Row(
children: [
Stack(
children: [
Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.white),
shape: BoxShape.circle,
),
child: Icon(
Icons.check,
size: 15,
color: Color(0xffFFC700),
),
)
],
),
Text(
"1969",
style: TextStyle(
color: Colors.white,
fontSize: 16,
),
),
],
),
),
Spacer(),
Container(
constraints: BoxConstraints.expand(
height: 40,
width: 50,
),
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.only(
topRight: Radius.circular(100),
bottomRight: Radius.circular(100),
),
),
child: Center(
child: Text(
"45%",
style: TextStyle(
color: Colors.white,
fontSize: 16,
),
),
),
),
],
),
),
/* ---------------------OPTION 3----------------------*/
Container(
margin: EdgeInsets.only(
left: 65,
right: 65,
bottom: 15,
),
padding: EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
decoration: BoxDecoration(
border: Border.all(color: Colors.white),
borderRadius: BorderRadius.circular(100)),
child: Row(
children: [
Stack(
children: [
Container(
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
border: Border.all(color: Colors.white),
shape: BoxShape.circle,
),
child: SizedBox(
height: 15,
width: 15,
),
)
],
),
Text(
"1957",
style: TextStyle(
color: Colors.white,
fontSize: 16,
),
),
],
),
),
Spacer(
flex: 2,
),
],
);
}
like this is quiz one section i want to go to the second quiz section which i can take as same ui
I would wrap your "mainQuiz" inside a Stack widget.
In that way you could add other 2 Containers inside the Stack's children.
Those containers could be positioned using "Positioned" widget.
One on the left of the screen and one on the right.
You should give then the size too.
I would let them transparent and I would give them a "GestureDetector" or something to detect the tap and call the Navigator to change screen.
As per your requirement, I think you should use
PageView
By default it has the swipe feature to go to the next and previous screen.
EDIT:-
As per you requirements, you know that you have a screen which already have interaction in form of giving answers, which has to be done using clicks. Though you can place empty containers in stack to implement clicks for left right, but as container need to have some width, thus they will overlap with you answers because basic padding is not more than 20. Thus I think you should go for swipe or specified buttons to go the left right i.e next and previous question.