Flutter scrolling Row - flutter

i have a Row inside a listview that it does not scroll with the rest of listview content i wanted to be scrollable, by the wat the cards inside the listView scrolls fine but not the row, i tried to put it inside a Stack , but still same problem
here is my code
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar()
body: ListView(
scrollDirection: Axis.vertical,
shrinkWrap: true,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
GestureDetector(
onTap: () {
Navigator.pushNamed(context, route.Prochaines_route);
},
child: Container(
padding: EdgeInsets.all(17.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Color(0xFFe0f2f1),
),
child: Container(
child: Text(
"Prochianes",
style: TextStyle(
color: Color(0xFF30a6ca),
),
),
),
),
),
GestureDetector(
onTap: () {
Navigator.pushNamed(context, route.EnCours_route);
},
child: Container(
padding: EdgeInsets.all(17.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
child: Text("En cours"),
),
),
GestureDetector(
onTap: () {
Navigator.pushNamed(context, route.Termines_route);
},
child: Container(
padding: EdgeInsets.all(17.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
child: Text("Terminés"),
),
),
],
),
Container(width: 300, height: 200, color: Colors.black),
SizedBox(
height: 30,
),
Container(width: 300, height: 200, color: Colors.red),
SizedBox(
height: 30,
),
Container(width: 300, height: 200, color: Colors.yellow),
SizedBox(
height: 30,
),
Container(width: 300, height: 200, color: Colors.green),
SizedBox(
height: 30,
),
Container(width: 300, height: 200, color: Colors.brown),
SizedBox(
height: 30,
),
Container(width: 300, height: 200, color: Colors.red),
],
),
);
i have a Row inside a listview that it does not scroll with the rest of listview content i wanted to be scrollable, by the wat the cards inside the listView scrolls fine but not the row, i tried to put it inside a Stack , but still same problem
Thanks for your help.

Please try this:
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
GestureDetector(
onTap: () {
// Navigator.pushNamed(context, route.Prochaines_route);
},
child: Container(
padding: EdgeInsets.all(17.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Color(0xFFe0f2f1),
),
child: Container(
child: Text(
"Prochianes",
style: TextStyle(
color: Color(0xFF30a6ca),
),
),
),
),
),
GestureDetector(
onTap: () {
// Navigator.pushNamed(context, route.EnCours_route);
},
child: Container(
padding: EdgeInsets.all(17.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
child: Text("En cours"),
),
),
GestureDetector(
onTap: () {
// Navigator.pushNamed(context, route.Termines_route);
},
child: Container(
padding: EdgeInsets.all(17.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
child: Text("Terminés"),
),
),
],
),
Expanded(
child: ListView(
scrollDirection: Axis.vertical,
shrinkWrap: true,
children: [
Container(width: 300, height: 200, color: Colors.black),
SizedBox(
height: 30,
),
Container(width: 300, height: 200, color: Colors.red),
SizedBox(
height: 30,
),
Container(width: 300, height: 200, color: Colors.yellow),
SizedBox(
height: 30,
),
Container(width: 300, height: 200, color: Colors.green),
SizedBox(
height: 30,
),
Container(width: 300, height: 200, color: Colors.brown),
SizedBox(
height: 30,
),
Container(width: 300, height: 200, color: Colors.red),
],
),
),
],
),

You can change the widget row to a ListView and do the following:
Widget myWidget() {
return SizedBox(
height: 100, // Important to set a high
child: ListView(
scrollDirection: Axis.horizontal, // Set the scroll direction
shrinkWrap: true, // Set the shrinkWrap to true
children: <Widget>[
Container(width: 100, height: 100, color: Colors.red),
Container(width: 100, height: 100, color: Colors.red),
Container(width: 100, height: 100, color: Colors.red),
Container(width: 100, height: 100, color: Colors.red),
Container(width: 100, height: 100, color: Colors.red),
Container(width: 100, height: 100, color: Colors.red),
Container(width: 100, height: 100, color: Colors.red),
// You can add as many as you want ...
],
),
);
}

Related

SingleChildScrollView overflows instead of scrolls

Why does this SingleChildScrollView overflow instead of scroll when the screen height is resized too small? I've used this design because the bottom widget needs to be pushed to the bottom.
return NavigationListener(builder: (context, child) {
return SingleChildScrollView(
child: SizedBox(
height: MediaQuery.of(context).size.height,
width: maxSideMenuWidth,
child: Column(
children: [
Container(
height: 155, color: Colors.purple, child: const MenuHeader()),
Container(
color: Colors.red,
height: 327,
child: MainMenu(
primaryDestinations: primaryDestinations,
secondaryDestinations: secondaryDestinations,
onNavigate: onNavigate,
isSelected: isSelected,
)),
Spacer(),
Container(
color: Colors.green,
height: 135,
child: LoginContextWidget(user, userDetails, logOut)),
],
),
));
});
Try This code
return NavigationListener(builder: (context, child) {
return SizedBox(
height: MediaQuery.of(context).size.height,
width: maxSideMenuWidth,
child: SingleChildScrollView(
child: Column(
children: [
Container(
height: 155, color: Colors.purple, child: const MenuHeader()),
Container(
color: Colors.red,
height: 327,
child: MainMenu(
primaryDestinations: primaryDestinations,
secondaryDestinations: secondaryDestinations,
onNavigate: onNavigate,
isSelected: isSelected,
)),
Spacer(),
Container(
color: Colors.green,
height: 135,
child: LoginContextWidget(user, userDetails, logOut)),
],
),
),
);
});
wrap singlechildscrollview in expanded
return NavigationListener(builder: (context, child) {
return Expanded(
child:SingleChildScrollView(
child: SizedBox(
height: MediaQuery.of(context).size.height,
width: maxSideMenuWidth,
child: Column(
children: [
Container(
height: 155, color: Colors.purple, child: const MenuHeader()),
Container(
color: Colors.red,
height: 327,
child: MainMenu(
primaryDestinations: primaryDestinations,
secondaryDestinations: secondaryDestinations,
onNavigate: onNavigate,
isSelected: isSelected,
)),
Spacer(),
Container(
color: Colors.green,
height: 135,
child: LoginContextWidget(user, userDetails, logOut)),
],
),
));
};
});

flutter : How to make Card Radio Button?

I want make card Radio Button.
I want make card Radio Button.I want make card Radio Button.
I want make card Radio Button.I want make card Radio Button.
I want make card Radio Button.
I want make card Radio Button.I want make card Radio Button.I want make card Radio Button.I want make card Radio Button.I want make card Radio Button.I want make card Radio Button.I want make card Radio Button.I want make card Radio Button.
This is my code
import 'package:cwc/ui/Home/homePage.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class LandingPage extends StatefulWidget {
const LandingPage({Key? key}) : super(key: key);
#override
_LandingPageState createState() => _LandingPageState();
}
class _LandingPageState extends State<LandingPage> {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
height: MediaQuery.of(context).size.height,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/bg.png"),
fit: BoxFit.cover,
),
),
width: double.infinity,
child: SafeArea(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: 80,
),
Text(
'Membership Packages',
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.white),
),
Padding(
padding: const EdgeInsets.all(20.0),
child: Text(
'Choose a membership plan to unlock all the features of the CWC Wellness Resource App',
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 13,
),
InkWell(
onTap: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => HomePage(),
),
);
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: Container(
decoration: const BoxDecoration(
// borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: AssetImage("assets/ona.png"),
fit: BoxFit.fill,
),
),
height: 147,
width: MediaQuery.of(context).size.width,
child: Row(
children: [
Container(
width: MediaQuery.of(context).size.width / 1.75,
color: Colors.transparent,
),
Image.asset(
'assets/onaa.png',
height: 114,
width: 114,
),
],
)),
),
),
const SizedBox(
height: 32,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/onb.png"),
fit: BoxFit.fill,
),
),
height: 147,
width: MediaQuery.of(context).size.width,
child: Row(
children: [
Container(
width: MediaQuery.of(context).size.width / 1.75,
color: Colors.transparent,
),
Image.asset(
'assets/onbb.png',
height: 114,
width: 114,
),
],
)),
),
const SizedBox(
height: 32,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/onc.png"),
fit: BoxFit.fill,
),
),
height: 147,
width: MediaQuery.of(context).size.width,
child: Row(
children: [
Container(
width: MediaQuery.of(context).size.width / 1.75,
color: Colors.transparent,
),
Image.asset(
'assets/oncc.png',
height: 114,
width: 114,
),
],
),
),
),
],
),
],
),
),
),
),
bottomNavigationBar: GestureDetector(
onTap: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => HomePage(),
),
);
},
child: Container(
color: Color(0xff3a99a4),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(topLeft: Radius.circular(60))),
width: double.infinity,
height: 57,
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(27, 0, 0, 0),
child: Container(
width: 18,
height: 18,
),
),
Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
child: Text(
'Continue',
style: GoogleFonts.poppins(
fontSize: 14,
color: Color(0xFF158998),
fontWeight: FontWeight.w600),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 27, 0),
child: const Icon(
Icons.arrow_right_alt_outlined,
size: 18,
color: Color(0xFF158998),
),
),
],
),
)))));
}
}
I Created this.
But I want like this.
To achieve that you need to wrap your widgets inside Stack widget and also have to assign position to each like below code below. Just replace you Column with this :
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
InkWell(
onTap: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => HomePage(),
),
);
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: SizedBox(
height: 147,
width: MediaQuery.of(context).size.width,
child: Stack(
alignment: Alignment.center,
children: [
Positioned(
left: 0,
right: 0,
bottom: 8,
top: 0,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: NetworkImage(
"https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg"),
fit: BoxFit.fill,
),
),
height: 147,
width: MediaQuery.of(context).size.width,
child: Row(
children: [
Container(
width: MediaQuery.of(context)
.size
.width /
1.75,
color: Colors.transparent,
),
Image.network(
"https://cdn.pixabay.com/photo/2017/07/08/09/49/red-2483933_960_720.jpg",
height: 114,
width: 114,
),
],
)),
),
Positioned(
width: 18,
bottom: 0,
child: Center(
child: Container(
height: 15,
width: 15,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(50),
),
child: Radio(
activeColor: Colors.green,
overlayColor: MaterialStateProperty.all(
Colors.red),
value: 1,
groupValue: 1,
onChanged: (int? value) {},
),
),
),
),
],
),
),
),
),
Divider(color: Colors.transparent,),
InkWell(
onTap: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => HomePage(),
),
);
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: SizedBox(
height: 147,
width: MediaQuery.of(context).size.width,
child: Stack(
alignment: Alignment.center,
children: [
Positioned(
left: 0,
right: 0,
bottom: 8,
top: 0,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: NetworkImage(
"https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg"),
fit: BoxFit.fill,
),
),
height: 147,
width: MediaQuery.of(context).size.width,
child: Row(
children: [
Container(
width: MediaQuery.of(context)
.size
.width /
1.75,
color: Colors.transparent,
),
Image.network(
"https://cdn.pixabay.com/photo/2017/07/08/09/49/red-2483933_960_720.jpg",
height: 114,
width: 114,
),
],
)),
),
Positioned(
width: 18,
bottom: 0,
child: Center(
child: Container(
height: 15,
width: 15,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(50),
),
child: Radio(
activeColor: Colors.green,
overlayColor: MaterialStateProperty.all(
Colors.red),
value: 1,
groupValue: 1,
onChanged: (int? value) {},
),
),
),
),
],
),
),
),
),
Divider(color: Colors.transparent,),
InkWell(
onTap: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => HomePage(),
),
);
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: SizedBox(
height: 147,
width: MediaQuery.of(context).size.width,
child: Stack(
alignment: Alignment.center,
children: [
Positioned(
left: 0,
right: 0,
bottom: 8,
top: 0,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: NetworkImage(
"https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg"),
fit: BoxFit.fill,
),
),
height: 147,
width: MediaQuery.of(context).size.width,
child: Row(
children: [
Container(
width: MediaQuery.of(context)
.size
.width /
1.75,
color: Colors.transparent,
),
Image.network(
"https://cdn.pixabay.com/photo/2017/07/08/09/49/red-2483933_960_720.jpg",
height: 114,
width: 114,
),
],
)),
),
Positioned(
width: 18,
bottom: 0,
child: Center(
child: Container(
height: 15,
width: 15,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(50),
),
child: Radio(
activeColor: Colors.green,
overlayColor: MaterialStateProperty.all(
Colors.red),
value: 1,
groupValue: 1,
onChanged: (int? value) {},
),
),
),
),
],
),
),
),
),
],
),

Instagram style Listview in flutter

I am experimenting on creating Instagram style of listview in Flutter, where the top horizontal scrolling is of stories and the scroll section right below is a vertical one for the posts. I am just using a listview now and not a listview builder. But I somehow do not get the vertical scrolling in my output. Also, in the upper listview, the container size takes the size 100 of the parent container but not the height 80. How do I fix that?
Here is the code for :
body: Column(
children: [
Container(
height: 100,
child: ListView(
scrollDirection: Axis.horizontal,
children: [
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.red,
),
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.blue,
),
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.green,
),
],
),
),
SizedBox(
height: 10,
),
ListView(
scrollDirection: Axis.vertical,
children: [
Container(
height: 100,
color: Colors.red,
),
Container(
height: 100,
color: Colors.blue,
),
Container(
height: 100,
color: Colors.green,
),
],
)
],
)
And here is my output:
Please check this code below.
Column(
children: [
Container(
height: 100,
child: ListView(
scrollDirection: Axis.horizontal,
children: [
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.red,
),
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.blue,
),
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.green,
),
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.green,
),
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.green,
),
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.green,
),
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.green,
),
],
),
),
SizedBox(
height: 10,
),
SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height - 180,
child: ListView(
scrollDirection: Axis.vertical,
shrinkWrap: true,
children: [
Container(
height: 100,
color: Colors.red,
),
Container(
height: 100,
color: Colors.blue,
),
Container(
height: 100,
color: Colors.green,
),
Container(
height: 100,
color: Colors.red,
),
Container(
height: 100,
color: Colors.blue,
),
Container(
height: 100,
color: Colors.green,
),
Container(
height: 100,
color: Colors.red,
),
Container(
height: 100,
color: Colors.blue,
),
Container(
height: 100,
color: Colors.green,
),
],
),
),
)
],
)
Wrap vertical List View with an Expanded widget.
Column(
mainAxisSize: MainAxisSize.max,
children: [
Container(
height: 100,
child: ListView(
scrollDirection: Axis.horizontal,
children: [
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.red,
),
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.blue,
),
SizedBox(
width: 10,
),
Container(
width: 80,
height: 80,
color: Colors.green,
),
],
),
),
SizedBox(
height: 10,
),
Expanded(
child: ListView(
scrollDirection: Axis.vertical,
children: [
Container(
height: 100,
color: Colors.red,
),
Container(
height: 100,
color: Colors.blue,
),
Container(
height: 100,
color: Colors.green,
),
],
),
)
],
)

Flutter Positioning Stack Complex Design

I am struggling with this, How Can I achieve this design? My code included stack widget with container background image but it's not showing properly.
I tried and it's showing like bellow image,
I want to design exactly like first image, I am stucking on positioning of small camera icon, background image, buy now banner etc, here's my code-
Stack(
children: [
Container(
decoration: new BoxDecoration(
// color: Colors.transparent,
image: new DecorationImage(
fit: BoxFit.fill,
image: new AssetImage(
'images/icons/egle2.png',
),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
children: [
Stack(
alignment: Alignment.topCenter,
children: [
Container(
height: 100,
width: 100,
),
Positioned(
// right: 1.0,
child: Material(
elevation: 8.0,
color: Colors.blue,
shape: CircleBorder(),
child: CircleAvatar(
maxRadius: 50,
minRadius: 40,
backgroundColor: Colors.transparent,
backgroundImage: AssetImage(
'images/icons/jully.png'),
),
),
),
// SizedBox(
// width: 20,
// ),
Positioned(
right: 0.0,
top: 0.0,
child: Align(
alignment: Alignment.topRight,
child: Image.asset(
'images/icons/camera.png',
// height: ,
// width: 25,
),
),
),
],
),
SizedBox(
height: 5,
),
Text(
'Jully',
style: TextStyle(
color: Colors.white, fontSize: 18),
),
SizedBox(
height: 5,
),
GestureDetector(
onTap: null,
child: Container(
padding: EdgeInsets.all(5),
height: 25,
// width: 30,
decoration: BoxDecoration(
color: UniversalVariables.yellowColor,
borderRadius: BorderRadius.circular(4),
),
child: Row(
children: [
Icon(
Icons.card_giftcard,
size: 15,
),
SizedBox(
width: 2,
),
Text(
'ID: 123875',
style: TextStyle(fontSize: 12),
),
],
),
),
),
SizedBox(
height: 200,
),
],
),
Column(
children: [
Stack(
alignment: Alignment.topCenter,
children: [
Container(
height: 100,
width: 100,
),
Positioned(
right: 1.0,
child: Material(
elevation: 8.0,
color: Colors.blue,
shape: CircleBorder(),
child: CircleAvatar(
maxRadius: 50,
minRadius: 40,
backgroundColor: Colors.transparent,
backgroundImage:
AssetImage('images/icons/king.png'),
),
),
),
SizedBox(
width: 20,
),
Positioned(
right: 0.0,
top: 0.0,
child: Align(
alignment: Alignment.topRight,
child: Image.asset(
'images/icons/camera.png',
// height: ,
// width: 25,
),
),
),
],
),
SizedBox(
height: 5,
),
Text(
'King_20',
style: TextStyle(
color: Colors.white, fontSize: 18),
),
SizedBox(
height: 5,
),
GestureDetector(
onTap: null,
child: Container(
padding: EdgeInsets.all(5),
height: 25,
// width: 30,
decoration: BoxDecoration(
color: UniversalVariables.yellowColor,
borderRadius: BorderRadius.circular(4),
),
child: Row(
children: [
Icon(
Icons.card_giftcard,
size: 15,
),
SizedBox(
width: 2,
),
Text(
'ID: 123875',
style: TextStyle(fontSize: 12),
),
],
),
),
),
],
),
Column(
children: [
Stack(
alignment: Alignment.topCenter,
children: [
Container(
height: 100,
width: 100,
),
Positioned(
right: 1.0,
child: Material(
elevation: 8.0,
color: Colors.blue,
shape: CircleBorder(),
child: CircleAvatar(
maxRadius: 50,
minRadius: 40,
backgroundColor: Colors.transparent,
backgroundImage:
AssetImage('images/icons/hulk.png'),
),
),
),
SizedBox(
width: 20,
),
Positioned(
// top: 5.0,
right: 0.0,
child: Container(
child: Image.asset(
'images/icons/camera.png',
// height: ,
// width: 25,
),
),
),
],
),
SizedBox(
height: 5,
),
Text(
'Hulk',
style: TextStyle(
color: Colors.white, fontSize: 18),
),
SizedBox(
height: 5,
),
GestureDetector(
onTap: null,
child: Container(
padding: EdgeInsets.all(5),
height: 25,
// width: 30,
decoration: BoxDecoration(
color: UniversalVariables.yellowColor,
borderRadius: BorderRadius.circular(4),
),
child: Row(
children: [
Icon(
Icons.card_giftcard,
size: 15,
),
SizedBox(
width: 2,
),
Text(
'ID: 123875',
style: TextStyle(fontSize: 12),
),
],
),
),
),
SizedBox(
height: 200,
),
// Stack(
// alignment: Alignment.topCenter,
// children: [
// Container(
// height: 100,
// width: 100,
// ),
// Positioned(
// right: 1.0,
// child: Material(
// elevation: 8.0,
// color: Colors.blue,
// shape: CircleBorder(),
// child: CircleAvatar(
// maxRadius: 50,
// minRadius: 40,
// backgroundColor: Colors.transparent,
// backgroundImage: AssetImage(
// 'images/icons/happyman.png'),
// ),
// ),
// ),
// SizedBox(
// width: 20,
// ),
// Positioned(
//// top: 5.0,
// right: 0.0,
// child: Container(
// child: Image.asset(
// 'images/icons/camera.png',
//// height: ,
//// width: 25,
// ),
// ),
// ),
// ],
// ),
// SizedBox(
// height: 5,
// ),
// Text(
// 'Happy Man',
// style: TextStyle(
// color: Colors.white, fontSize: 18),
// ),
// SizedBox(
// height: 5,
// ),
// GestureDetector(
// onTap: null,
// child: Container(
// padding: EdgeInsets.all(5),
// height: 25,
//// width: 30,
// decoration: BoxDecoration(
// color: UniversalVariables.yellowColor,
// borderRadius: BorderRadius.circular(4),
// ),
// child: Row(
// children: [
// Icon(
// Icons.card_giftcard,
// size: 15,
// ),
// SizedBox(
// width: 2,
// ),
// Text(
// 'ID: 123875',
// style: TextStyle(fontSize: 12),
// ),
// ],
// ),
// ),
// ),
],
),
],
),
),
Positioned.fill(
top: 280,
child: Container(
color: Colors.yellow,
height: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(left: 20),
child: Container(
child: Row(
children: [
Image.asset('images/icons/badge4.png',),
SizedBox(width: 10,),
Text(
"X 70 = \$10",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold),
),
],
),
),
),
Padding(
padding: const EdgeInsets.only(right: 20),
child: GestureDetector(
onTap: null,
child: Container(
padding: EdgeInsets.all(8),
height: 35,
// width: 30,
decoration: BoxDecoration(
color: UniversalVariables.blackColor,
borderRadius: BorderRadius.circular(4),
),
child: Row(
children: [
Text(
'Buy Now',
textAlign: TextAlign.center,
style:
TextStyle(color: Colors.white),
),
],
),
),
),
),
],
),
),
),
],
),
As usual, there might be better examples on how to achieve this result.
Here's a fast attempt to recreate it. It needs some fine tuning to fit any screen size, using AutoSizeText and rewriting PersonDrawer to be responsive too.
But I hope that it will help you to move in the right direction.
class MySuperCoolStackWidget extends StatelessWidget {
final double baseWidth = 520.0;
final double baseHeight = 345.0;
double fromWidth(double size, BoxConstraints constraints) {
return size / baseWidth * constraints.maxWidth;
}
double fromHeight(double size, BoxConstraints constraints) {
return size / baseHeight * constraints.maxHeight;
}
#override
Widget build(BuildContext context) {
return AspectRatio(
aspectRatio: baseWidth / baseHeight,
child: LayoutBuilder(
builder: (context, constraints) {
return Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.black,
),
),
AspectRatio(
aspectRatio: 520.0 / 260.0,
child: Container(
padding: EdgeInsets.fromLTRB(
fromWidth(20.0, constraints),
fromHeight(40.0, constraints),
fromWidth(20.0, constraints),
fromHeight(20.0, constraints),
),
child: LayoutBuilder(
builder: (_, innerConstraints){
return Row(
children: <Widget>[
Expanded(
child: PersonDrawer(),
),
SizedBox(
width: fromWidth(20.0, constraints),
),
Expanded(
child: Transform.translate(
offset: Offset(0.0, innerConstraints.maxHeight / 2.0),
child: PersonDrawer(),
),
),
SizedBox(
width: fromWidth(20.0, constraints),
),
Expanded(
child: PersonDrawer(),
),
],
);
},
),
),
),
Positioned(
left: 0,
right: 0,
bottom: fromHeight(20.0, constraints),
child: AspectRatio(
aspectRatio: 520.0 / 65.0,
child: Container(
padding: EdgeInsets.symmetric(
vertical: fromHeight(16.0, constraints),
horizontal: fromWidth(32.0, constraints),
),
color: Colors.orange[400],
child: Row(
children: <Widget>[
Expanded(
child: Row(
children: <Widget>[
Icon(Icons.local_florist),
Text('x 70 = \$10'),
],
),
),
RaisedButton(
color: Colors.black,
textColor: Colors.white,
onPressed: () {},
child: Text('Buy now'),
),
],
),
),
),
),
],
);
},
),
);
}
}
class PersonDrawer extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Colors.white10,
border: Border.all(color: Colors.white12),
borderRadius: BorderRadius.circular(10.0),
),
child: Column(
children: <Widget>[
Expanded(
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Container(
padding: EdgeInsets.all(10.0),
child: AspectRatio(
aspectRatio: 1.0,
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
),
),
),
Positioned(
top: 5.0,
right: 5.0,
child: Icon(
Icons.camera,
color: Colors.white,
),
),
],
),
),
SizedBox(height: 5.0),
Container(
padding: EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
Text(
'King_20',
style: TextStyle(
color: Colors.white,
),
),
SizedBox(height: 5.0),
Container(
padding: EdgeInsets.all(2.0),
decoration: BoxDecoration(
color: Colors.orange[400],
borderRadius: BorderRadius.circular(5.0),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Icon(Icons.perm_identity, size: 10.0),
Text(
'ID: 1234567',
style: TextStyle(
fontSize: 10.0,
),
),
],
),
),
],
),
)
],
),
);
}
}

Problem in set position with Stack and Positioned in flutter

I'm trying to make a card with "balloon" in top of card Here a example of what i'm trying to do
I'm doin'g in Flutter, the last update, i've tried add stack with positioned, but i got this horrible thing
My code about this is:
Column(
children: <Widget>[
Stack(
children: <Widget>[
Container(
width: 40,
height: 40,
alignment: Alignment.center,
child: Text('1'),
decoration:
BoxDecoration(color: Colors.redAccent, shape: BoxShape.circle),
),
Positioned(
left: 19,
top: 37,
child: Container(
height: 20,
width: 20,
color: Colors.green,
),
),
],
),
Card(
child: Container(
color: Colors.blue,
child: Text('aaaaaaaa'),
),
)
],
);
And my expected response was the link above
Please try this :-
Column(
children: <Widget>[
Container(
alignment: Alignment.topLeft,
child: Column(
children: <Widget>[
Container(
width: 40,
height: 40,
alignment: Alignment.center,
child: Text('1'),
decoration: BoxDecoration(
color: Colors.redAccent, shape: BoxShape.circle),
),
Container(
height: 40,
width: 2,
color: Colors.green,
),
],
),
),
Container(
width: double.infinity,
child: Card(
child: Container(
color: Colors.blue,
child: Text('aaaaaaaa'),
),
),
)
],
)