How to add some space to row items in flutter? - flutter

I have a screen that contains a Row widget with 3 Column children. I want to add a space for the first children and another space for the second children. In general, I want a screen like this:
I try with these codes but not work correctly.
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(top: 10),
child: Column(
children: [
item(),
item(),
item(),
],
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(top: 20),
child: Column(
children: [
item(),
item(),
item(),
],
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(top: 5),
child: Column(
children: [
item(),
item(),
item(),
],
),
),
),
],
);
Can you help me?

Add a SizedBox to the children of the Rows, each with different height.

I hope this will help you and I just modified it with some Container().
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(top: 10),
child: Column(
children: [
Container(
height: 50,
color: Colors.red,
),
Container(
color: Colors.red,
height: 50,
),
Container(
color: Colors.red,
height: 50,
),
],
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(top: 20),
child: Column(
children: [
//////here you have to add SizedBox widget with different heights
const SizedBox(
height: 40,
),
Container(
color: Colors.red,
height: 50,
),
Container(
color: Colors.red,
height: 50,
),
Container(
color: Colors.red,
height: 50,
),
],
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(top: 5),
child: Column(
children: [
Container(
color: Colors.red,
height: 50,
),
Container(
color: Colors.red,
height: 50,
),
Container(
color: Colors.red,
height: 50,
),
],
),
),
),
],
)
Output:

You can add a SizedBox between the items. Like:
Expanded(
child: Padding(
padding: const EdgeInsets.only(top: 5),
child: Column(
children: [
item(),
SizedBox(height:20),
item(),
SizedBox(height:20),
item(),
],
),
),
),
I think that is simple, but works.
You can use a Container with margins in the items too.
If you want a more complex item, you can use ListView.separated.
ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
itemCount: 20,
itemBuilder: (context, index) => Padding(
padding: EdgeInsets.all(8.0),
child: Center(child: Text("Index $index")),
),
)

Related

A RenderFlex overflowed by 230 pixels on the bottom

I keep getting this error and I know how to fix it I've tried wrapping my column inside an Expanded and a Flexible widget but it doesn't seem to be working.
Here's my code :
return Scaffold(
body: Column(
children: [
//To Show Current Date
Container(
height: 30,
margin: EdgeInsets.only(left: 10),
alignment: Alignment.centerLeft,
),
SizedBox(height: 10),
//To show Calendar Widget
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
flex : 2,
child: SingleChildScrollView(
child: Center(
child: Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const ListTile(
title: Text(
'MISSIONS',
style: TextStyle(
fontStyle: FontStyle.italic,
fontSize: 20),
textAlign: TextAlign.center,
),
),
],
),
),
),
),
),
Expanded(
flex : 8,
child: SizedBox(
height: 600.0,
child: ListView.builder(
itemCount:
3,
itemBuilder: (BuildContext context, int index) {
// box.put('missionName', missionName);
//box.put("entries",entries);
//var name = box.get('missionName');
//print('Name: $name');
return GestureDetector(
child: Card(
child: Center(
child: Container(
height: 110,
child: Row(
children: <Widget>[
Expanded(
child: Text(
'mission'),
),
SizedBox(height: 30),
Expanded(
child: GestureDetector(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
children: <Widget>[
// Just a top space
// main content
Container(
child: Stack(
children: <Widget>[
// Box and icons
Stack(
children: <Widget>[
// Box
renderBox(),
// Icons
renderIcons(),
],
alignment: Alignment.bottomCenter,
),
// Button like
renderBtnLike(),
// Icons when jump
// Icon like
whichIconUserChoose == 1 && !isDragging
? Container(
child: Transform.scale(
child: Image.asset(
"images/close.png",
width: 20.0,
height: 20.0,
),
scale: this.zoomIconWhenRelease.value,
),
margin: EdgeInsets.only(
top: processTopPosition(this.moveUpIconWhenRelease.value),
left: this.moveLeftIconLikeWhenRelease.value,
),
)
: Container(),
// Icon love
whichIconUserChoose == 2 && !isDragging
? Container(
child: Transform.scale(
child: Image.asset(
"images/nowork.png",
width: 20.0,
height: 20.0,
),
scale: this.zoomIconWhenRelease.value,
),
margin: EdgeInsets.only(
top: processTopPosition(this.moveUpIconWhenRelease.value),
left: this.moveLeftIconLoveWhenRelease.value,
),
)
: Container(),
// Icon haha
whichIconUserChoose == 3 && !isDragging
? Container(
child: Transform.scale(
child: Image.asset(
"images/sunny.png",
width: 20.0,
height: 20.0,
),
scale: this.zoomIconWhenRelease.value,
),
margin: EdgeInsets.only(
top: processTopPosition(this.moveUpIconWhenRelease.value),
left: this.moveLeftIconHahaWhenRelease.value,
),
)
: Container(),
],
),
margin: EdgeInsets.only(left: 20.0, right: 20.0),
// Area of the content can drag
// decoration: BoxDecoration(border: Border.all(color: Colors.grey)),
width: double.infinity,
),
],
),
),
onHorizontalDragEnd: onHorizontalDragEndBoxIcon,
onHorizontalDragUpdate: onHorizontalDragUpdateBoxIcon,
),
)
],
),
),
),
),
);
}),
),
),
SizedBox(height: 30),
],
)),
],
),
);
This is the renderBtnLike() widget :
Widget renderBtnLike() {
return Container(
child: GestureDetector(
onTapDown: onTapDownBtn,
onTapUp: onTapUpBtn,
onTap: onTapBtn,
child: Container(
child: Row(
children: <Widget>[
// Icon like
Expanded(
child: Transform.scale(
child: Transform.rotate(
child: Image.asset(
getImageIconBtn(),
width: 10.0,
height: 10.0,
fit: BoxFit.contain,
color: getTintColorIconBtn(),
),
angle:
!isLongPress ? handleOutputRangeTiltIconLike(tiltIconLikeInBtn2.value) : tiltIconLikeInBtn.value,
),
scale:
!isLongPress ? handleOutputRangeZoomInIconLike(zoomIconLikeInBtn2.value) : zoomIconLikeInBtn.value,
),
),
// Text like
Expanded(
child: Transform.scale(
child: Text(
getTextBtn(),
style: TextStyle(
color: getColorTextBtn(),
fontSize: 8.0,
fontWeight: FontWeight.bold,
),
),
scale:
!isLongPress ? handleOutputRangeZoomInIconLike(zoomIconLikeInBtn2.value) : zoomTextLikeInBtn.value,
),
),
],
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
),
padding: EdgeInsets.all(8.0),
color: Colors.transparent,
),
),
width: 100.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.0),
color: Colors.white,
border: Border.all(color: getColorBorderBtn()),
),
margin: EdgeInsets.all(20.0),
);
}
If anyone seems to know the answer please tell me how to fix this and thank you in advance.
you just need to wrap your Column widget into SingleChildScrollView widget to get rid of and Expanded and Flexible widgets works inside Column or Row
return Scaffold(
body: SingleChildScrollView(
child : Column(
children: [
//To Show Current Date
Container(
height: 30,
margin: EdgeInsets.only(left: 10),
alignment: Alignment.centerLeft,
),
SizedBox(height: 10),
//To show Calendar Widget
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
flex : 2,
child: SingleChildScrollView(
child: Center(
child: Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const ListTile(
title: Text(
'MISSIONS',
style: TextStyle(
fontStyle: FontStyle.italic,
fontSize: 20),
textAlign: TextAlign.center,
),
),
],
),
),
),
),
),
Expanded(
flex : 8,
child: SizedBox(
height: 600.0,
child: ListView.builder(
itemCount:
3,
itemBuilder: (BuildContext context, int index) {
// box.put('missionName', missionName);
//box.put("entries",entries);
//var name = box.get('missionName');
//print('Name: $name');
return GestureDetector(
child: Card(
child: Center(
child: Container(
height: 110,
child: Row(
children: <Widget>[
Expanded(
child: Text(
'mission'),
),
SizedBox(height: 30),
Expanded(
child: GestureDetector(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
children: <Widget>[
// Just a top space
// main content
Container(
child: Stack(
children: <Widget>[
// Box and icons
Stack(
children: <Widget>[
// Box
renderBox(),
// Icons
renderIcons(),
],
alignment: Alignment.bottomCenter,
),
// Button like
renderBtnLike(),
// Icons when jump
// Icon like
whichIconUserChoose == 1 && !isDragging
? Container(
child: Transform.scale(
child: Image.asset(
"images/close.png",
width: 20.0,
height: 20.0,
),
scale: this.zoomIconWhenRelease.value,
),
margin: EdgeInsets.only(
top: processTopPosition(this.moveUpIconWhenRelease.value),
left: this.moveLeftIconLikeWhenRelease.value,
),
)
: Container(),
// Icon love
whichIconUserChoose == 2 && !isDragging
? Container(
child: Transform.scale(
child: Image.asset(
"images/nowork.png",
width: 20.0,
height: 20.0,
),
scale: this.zoomIconWhenRelease.value,
),
margin: EdgeInsets.only(
top: processTopPosition(this.moveUpIconWhenRelease.value),
left: this.moveLeftIconLoveWhenRelease.value,
),
)
: Container(),
// Icon haha
whichIconUserChoose == 3 && !isDragging
? Container(
child: Transform.scale(
child: Image.asset(
"images/sunny.png",
width: 20.0,
height: 20.0,
),
scale: this.zoomIconWhenRelease.value,
),
margin: EdgeInsets.only(
top: processTopPosition(this.moveUpIconWhenRelease.value),
left: this.moveLeftIconHahaWhenRelease.value,
),
)
: Container(),
],
),
margin: EdgeInsets.only(left: 20.0, right: 20.0),
// Area of the content can drag
// decoration: BoxDecoration(border: Border.all(color: Colors.grey)),
width: double.infinity,
),
],
),
),
onHorizontalDragEnd: onHorizontalDragEndBoxIcon,
onHorizontalDragUpdate: onHorizontalDragUpdateBoxIcon,
),
)
],
),
),
),
),
);
}),
),
),
SizedBox(height: 30),
],
)),
],
),
),
);
return Scaffold(
body: singlechildscrollview(
child:Column(
children: [
//To Show Current Date
Container(
height: 30,
margin: EdgeInsets.only(left: 10),
alignment: Alignment.centerLeft,
),
SizedBox(height: 10),
//To show Calendar Widget
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
flex : 2,
child: SingleChildScrollView(
child: Center(
child: Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const ListTile(
title: Text(
'MISSIONS',
style: TextStyle(
fontStyle: FontStyle.italic,
fontSize: 20),
textAlign: TextAlign.center,
),
),
],
),
),
),
),
),
Expanded(
flex : 8,
child: SizedBox(
height: 600.0,
child: ListView.builder(
itemCount:
3,
itemBuilder: (BuildContext context, int index) {
// box.put('missionName', missionName);
//box.put("entries",entries);
//var name = box.get('missionName');
//print('Name: $name');
return GestureDetector(
child: Card(
child: Center(
child: Container(
height: 110,
child: Row(
children: <Widget>[
Expanded(
child: Text(
'mission'),
),
SizedBox(height: 30),
Expanded(
child: GestureDetector(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
children: <Widget>[
// Just a top space
// main content
Container(
child: Stack(
children: <Widget>[
// Box and icons
Stack(
children: <Widget>[
// Box
renderBox(),
// Icons
renderIcons(),
],
alignment: Alignment.bottomCenter,
),
// Button like
renderBtnLike(),
// Icons when jump
// Icon like
whichIconUserChoose == 1 && !isDragging
? Container(
child: Transform.scale(
child: Image.asset(
"images/close.png",
width: 20.0,
height: 20.0,
),
scale: this.zoomIconWhenRelease.value,
),
margin: EdgeInsets.only(
top: processTopPosition(this.moveUpIconWhenRelease.value),
left: this.moveLeftIconLikeWhenRelease.value,
),
)
: Container(),
// Icon love
whichIconUserChoose == 2 && !isDragging
? Container(
child: Transform.scale(
child: Image.asset(
"images/nowork.png",
width: 20.0,
height: 20.0,
),
scale: this.zoomIconWhenRelease.value,
),
margin: EdgeInsets.only(
top: processTopPosition(this.moveUpIconWhenRelease.value),
left: this.moveLeftIconLoveWhenRelease.value,
),
)
: Container(),
// Icon haha
whichIconUserChoose == 3 && !isDragging
? Container(
child: Transform.scale(
child: Image.asset(
"images/sunny.png",
width: 20.0,
height: 20.0,
),
scale: this.zoomIconWhenRelease.value,
),
margin: EdgeInsets.only(
top: processTopPosition(this.moveUpIconWhenRelease.value),
left: this.moveLeftIconHahaWhenRelease.value,
),
)
: Container(),
],
),
margin: EdgeInsets.only(left: 20.0, right: 20.0),
// Area of the content can drag
// decoration: BoxDecoration(border: Border.all(color: Colors.grey)),
width: double.infinity,
),
],
),
),
onHorizontalDragEnd: onHorizontalDragEndBoxIcon,
onHorizontalDragUpdate: onHorizontalDragUpdateBoxIcon,
),
)
],
),
),
),
),
);
}),
),
),
SizedBox(height: 30),
],
)),
],
),
);
);

Cannot add column inside a card below a row Flutter

I am implementing a card where I have rows, I want to add column below rows inside the card in flutter. I am unable to add column at the bottom inside the card.
Column buildWorkshopSection() {
return Column(
children: [
Card(
margin: EdgeInsets.symmetric(horizontal: 20.0, vertical: 5.0),
clipBehavior: Clip.antiAlias,
color: Colors.white,
elevation: 5.0,
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 8.0, vertical: 22.0),
child: Row(
children: <Widget>[
Expanded(
child: Column(
children: <Widget>[
SizedBox(
height: 5.0,
),
buildStartTimeWorkshop(),
],
),
),
Expanded(
child: Column(
children: <Widget>[
SizedBox(
height: 5.0,
),
buildCloseTimeWorkshop(),
],
),
),
],
),
),
)
],
);
}
Add submit button like this
Card(
margin:
EdgeInsets.symmetric(horizontal: 20.0, vertical: 5.0),
clipBehavior: Clip.antiAlias,
color: Colors.white,
elevation: 5.0,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8.0, vertical: 22.0),
child: Column(
children: [
Row(
children: <Widget>[
Expanded(
child: Column(
children: <Widget>[
SizedBox(
height: 5.0,
),
buildStartTimeWorkshop(),
],
),
),
Expanded(
child: Column(
children: <Widget>[
SizedBox(
height: 5.0,
),
buildCloseTimeWorkshop(),
],
),
),
],
),
SizedBox(
height: 20,
),
RaisedButton(
onPressed: () {},
child: Text("Submit"),
)
],
),
),
),
It look like this

flutter row widget space between doesn't work. how can i fix this?

I wanna give space between Math and A+.
I tried
mainAxisAlignment.spacebetween
insert Spacer()
wrap with Container() and give width : infinity
all doesn't work. don't know why
here's my code
body: Container(
margin: EdgeInsets.only(top: 5),
child: ListView.builder(
itemCount: 20,
itemBuilder: (context, index) {
return Container(
decoration: BoxDecoration(
color: kFadingBackgroundColor,
borderRadius: BorderRadius.all(Radius.circular(5.0)),
boxShadow: [
BoxShadow(
color: Colors.grey[200],
offset: Offset(0.0, 2.5), //(x,y)
blurRadius: 2.0,
),
],
),
margin: EdgeInsets.symmetric(horizontal: 70.w, vertical: 10.h),
padding: EdgeInsets.only(
top: 5.0, bottom: 8.0, left: 45.w, right: 45.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Column(
children: <Widget>[
// SizedBox(height: 5),
CircleAvatar(
backgroundColor: Colors.transparent,
child: Image.asset('assets/images/math.png'),
)
],
),
),
SizedBox(width: 30.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Row( ✅✅✅✅✅✅✅✅✅✅✅✅✅✅✅
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Math',
style: TextStyle(
fontSize: 100.sp, color: blueGray),
),
// SizedBox(
// width: double.infinity,
// ),
// Spacer(),
Text(
'A+',
style: TextStyle(color: blueGray),
),
],
),
),
Container(
width: 300,
child: Text(
'hellowoasasasasassssssssssssssssssssssssssssssssssssssssssssssssssssssssssssrld lroremkasdasdasdasdasdsadasdasdasdasdasdasdasdasdremmws',
softWrap: true,
),
),
],
)
],
));
},
),
),
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
you can wrap the second column in an Expanded widget and give the Row mainAxisSize.Max and try spacer or space between
or you can try wrapping the Text("Math") in an Expanded widget.
you can find more info on Expanded Widget Here

displaying matching id , flutter

I'm new to flutter, I'm trying to show cards in categories, I've made a module with the categories and items, including id for the categories and matching id for the item(one item can be in multiple categories ) but I don't know how to sort them
this is the main screen
Widget _buildIcon(int index) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: GestureDetector(
onTap: () {
setState(() {
_selectedIndex = index;
String id = DUMMY_CATEGORIES[index].id;
print(id);
});
},
child: Container(
height: 45,
width: 100,
decoration: BoxDecoration(
color: _selectedIndex == index
? Color.fromRGBO(126, 214, 223, 0.5)
: Color.fromRGBO(200, 214, 229,0.3),
borderRadius: BorderRadius.circular(80)),
child: Center(
child: Text(
DUMMY_CATEGORIES[index].title, style: TextStyle(color: _selectedIndex==index ?Color.fromRGBO(16, 172, 132, 1) : Colors.black, ),
),
),
),
),
);
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: <Widget>[
Column(
children: <Widget>[
Container(
padding: EdgeInsets.only(right: 10, top: 20),
alignment: Alignment.topRight,
child: IconButton(
icon: Icon(
Icons.search,
size: 25,
),
)),
Container(
padding: EdgeInsets.only(left: 10),
alignment: Alignment.topLeft,
child: Text(
'Make it Bread',
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
)),
],
),
SizedBox(
height: 30,
),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: DUMMY_CATEGORIES
.asMap()
.entries
.map((MapEntry map) => _buildIcon(map.key))
.toList()
),
),
NewMealIteam(),
],
),
);
}
}
and this is the item
Widget build(BuildContext context) {
return Padding(padding: EdgeInsets.symmetric(horizontal: 10, vertical: 45),
child: Container(
height: 450,
//color: Colors.orange,
child: ListView.builder(itemCount: mealList.length,
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context ,int index){
Meal mealLists = mealList[index];
return Container(
width: 280,
child: Stack(children: <Widget>[
Container(
height: 450,
margin: EdgeInsets.all(10),
padding: EdgeInsets.symmetric(horizontal: 20),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(20),
color: Colors.red,
image: DecorationImage(
image: AssetImage('assets/dough.png'
),fit: BoxFit.fill
),
boxShadow: [
BoxShadow(
color: Colors.grey,
blurRadius: 2.0,
spreadRadius: 0.0,
offset: Offset(3.0, 2.0), // shadow direction: bottom right
)
],),
),
Positioned(bottom :20 ,left: 20,child: Column(
children: <Widget>[
Container(width: 170,
padding: EdgeInsets.symmetric(vertical: 25),
child: Text(mealLists.title,style: TextStyle(color:Colors.white,fontSize: 32),textAlign: TextAlign.start,overflow: TextOverflow.fade
,),
),
Padding(
padding: EdgeInsets.all(2),
child: Container(width:220,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row( mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Icon(Icons.schedule),
SizedBox(
width: 6,
),
Text('${mealLists.duration} min'),
],
),
Row( mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Icon(Icons.work),
SizedBox(
width: 8,
),
],
),
Row( mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Icon(Icons.monetization_on),
SizedBox(
width: 6,
),
// Text('${durations} min'),
],
),
],
),
),
)
],
))
],),
);
},
),
),
);
}
}
this is example for the module list
Category(
id: 'c1',
title: 'sour bread',
),
Meal(
id: 'm1',
categories: [
'c1',
'c2',
],
title: 'Sour Dough',
),
thanks

Error displaying List view below container

I am trying to display Listview using Listview builder below the purple color(as seen in the image)container with the below code:
return Scaffold(
body: Column(
children: <Widget>[
Container(
height: 300,
decoration: BoxDecoration(
color: Colors.deepPurple,
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(75.0)),
),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(0, 10, 200, 0),
child: Container(
padding: EdgeInsets.fromLTRB(0, 30,200,0),
child: IconButton(icon: Icon(Icons.arrow_back,),
color: Colors.black,
onPressed: () {
Navigator.pop(context);
},
),
),
),
SizedBox(height: 20,),
Text('Semester 1',
style: TextStyle(color: Colors.white,
fontSize: 30),
)
],
)
),
Container(
child: ListView.builder(
itemCount: 1,
itemBuilder: (BuildContext context, int index) {
return new Container(
child: new Center(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
new Card(
child: new Container(
child: new Text("hello"),
padding: const EdgeInsets.all(20),
))
],
)));
}),
)
],
),
);
It returns a blank screen after running the code,without showing any error. I am not able to figure out the problem.
Please help!
If you use listview is small and inside Column then you should add
shrinkWrap: true in ListView
Column(
children: <Widget>[
ListView(
shrinkWrap: true, // use it
)
],
)
Or If your ListView Height is fix then use
Column(
children: <Widget>[
SizedBox(
height: 200, // constrain height
child: ListView(),
)
],
)
or If you want to fill all remaining space the use
Column(
children: <Widget>[
Expanded(
child: ListView(...),
)
],
)
Simply wrap the ListView in Expanded. The error here is that ListView doesn't know how to size itself (it has unbounded height from the Column). Using Expanded will tell it to fill up all the remaining space and fix the sizing problem
return Scaffold(
body: Column(
children: <Widget>[
Container(
height: 300,
decoration: BoxDecoration(
color: Colors.deepPurple,
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(75.0)),
),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(0, 10, 200, 0),
child: Container(
padding: EdgeInsets.fromLTRB(0, 30,200,0),
child: IconButton(icon: Icon(Icons.arrow_back,),
color: Colors.black,
onPressed: () {
Navigator.pop(context);
},
),
),
),
SizedBox(height: 20,),
Text('Semester 1',
style: TextStyle(color: Colors.white,
fontSize: 30),
)
],
)
),
Container(
child: Expanded( // <-- wrap with expanded
child: ListView.builder(
itemCount: 1,
itemBuilder: (BuildContext context, int index) {
return new Container(
child: new Center(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
new Card(
child: new Container(
child: new Text("hello"),
padding: const EdgeInsets.all(20),
))
],
)));
}),
),
)
],
),
);
Error is caused by Container that is wrapping ListView. You need to specify bounds for that Container.
return Scaffold(
body: Column(
children: <Widget>[
Container(
height: 300,
decoration: BoxDecoration(
color: Colors.deepPurple,
borderRadius:
BorderRadius.only(bottomLeft: Radius.circular(75.0)),
),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(0, 10, 200, 0),
child: Container(
padding: EdgeInsets.fromLTRB(0, 30, 200, 0),
child: IconButton(
icon: Icon(
Icons.arrow_back,
),
color: Colors.black,
onPressed: () {
Navigator.pop(context);
},
),
),
),
SizedBox(
height: 20,
),
Text(
'Semester 1',
style: TextStyle(color: Colors.white, fontSize: 30),
)
],
),
),
Container(
height: 300,
child: ListView.builder(
itemCount: 1,
itemBuilder: (BuildContext context, int index) {
return Container(
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Card(
child: Container(
child: Text("hello"),
padding: const EdgeInsets.all(20),
))
],
)));
}),
)
],
),
Above code should be working. Please note that, you don't need to specify "new" keyword in flutter.