Flutter-Renderflex overflow error on each item in GridView.builder() - flutter

In my project i need to display a grid of products,2 in each row. For that I am using GridView.builder() as follows :
#override
Widget build(BuildContext context) {
return Column(
children: [
const Text('New Arrivals'),
const SizedBox(height: 10),
Expanded(
child: Consumer<HomeViewModel>(
builder: (context, model, child) {
if (model.state == ViewState.idle) {
if (model.products.isEmpty) {
return const Center(
child: CircularProgressIndicator(color: Colors.black),
);
}
return GridView.builder(
shrinkWrap: true,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
),
itemBuilder: (context, index) =>
ProductItem(product: model.products[index]),
itemCount: model.products.length,
);
}
return const Center(
child: CircularProgressIndicator(color: Colors.black),
);
},
),
),
],
);
}
However, this is giving an A RenderFlex overflowed by 49 pixels on the bottom. error on each item. The no. of pixels overflowed is different for different item.I have attached the screenshot for reference. What am I doing wrong and how do I fix it?
product_item.dart:
class ProductItem extends StatelessWidget {
const ProductItem({Key? key, required this.product}) : super(key: key);
final Product product;
#override
Widget build(BuildContext context) {
return Container(
width: 200,
color: Colors.white,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 200,
height: 150,
child: Image.network(product.imageUrl!),
),
const SizedBox(height: 13),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
product.category!,
softWrap: true,
style: const TextStyle(
fontSize: 10,
color: Colors.deepPurple,
height: 1.5,
fontWeight: FontWeight.w500,
),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
product.title!,
softWrap: true,
style: const TextStyle(
color: Colors.black54,
fontSize: 12,
height: 1.8,
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(height: 10),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'\$ ${product.price!}',
style: const TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.w600,
height: 2.4,
),
),
Image.asset('assets/icons/cart_icon.png',
width: 40, height: 40),
],
),
)
],
),
);
}
}

the problem "should" lie within:
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
product.title!,
softWrap: true,
style: const TextStyle(
color: Colors.black54,
fontSize: 12,
height: 1.8,
fontWeight: FontWeight.w500,
),
),
),
try using: AutoSizeText instead of Text
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: AutoSizeText(
product.title!,
softWrap: true,
maxLines: 1,
style: const TextStyle(
color: Colors.black54,
fontSize: 12,
height: 1.8,
fontWeight: FontWeight.w500,
),
),
),

Default childAspectRatio is 1 on GridView. The issue arise because it is not fitting inside the square. Item's size is depending on screen width. And width is controlling the height,=> aspect ratio.
You can play with size of grid item using childAspectRatio:width/height. Alternative, you can follow #Maurizio Mancini's answer.
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 3 / 4,//this
),

I have used your code to reproduce the issue. If I understood your needs right, here is the fix:
The main problem is related to childAspectRatio.
return GridView.builder(
shrinkWrap: true,
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
childAspectRatio: 0.75,
),
itemBuilder: (context, index) =>
ProductItem(product: model.products[index]),
itemCount: model.products.length,
);
So you need to set the aspect ratio similar to this to fix the problem.
You can access the working source code through GitHub.

Related

How can I build a gridview with a dynamic height in Dart?

I am trying to build a GridView that adjusts its height automatically according to the data provided. However, I am encountering a problem where an additional line (Top Discount of the Sale) appears after the rating bar for some products, but the space for that line is not reserved for other products that do not have it. As a result, I get a RenderFlex error when I try to implement this. How can I properly handle this situation?
GridView.builder(
padding: const EdgeInsets.all(12.0),
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 6.0,
childAspectRatio: .60,
mainAxisSpacing: 6.0,
),
itemCount: state
.productListModel!.productModel!.length,
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return InkWell(
splashFactory: NoSplash.splashFactory,
onTap: () {
Helper.push(
context,
ProductView(
productId: state.productListModel!
.productModel![index].sId,
));
},
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Stack(
alignment:
Alignment.bottomRight,
children: [
SizedBox(
width: WidgetStyles()
.theWidth(context),
height: WidgetStyles()
.theHeight(
context) /
4,
child: ImageView(
imageUrl: state
.productListModel!
.productModel![index]
.photos![0],
fit: BoxFit.contain,
),
),
Positioned(
right: 5,
bottom: 5,
child: Container(
padding:
const EdgeInsets
.all(8.0),
decoration:
const BoxDecoration(
color: Colors
.white,
shape: BoxShape
.circle),
child: InkWell(
onTap: () async {
String deepLink = await FirebaseDynamiclinkService
.createDynamicLink(
true,
state
.productListModel!
.productModel![
index]
.sId!);
log(deepLink);
Helper.shareProduct(
context,
'MyEComApp\n♥️ Proudly made for kerala\n\n${state.productListModel!.productModel![index].productname!}\n${state.productListModel!.productModel![index].seller!.organization!}\n*INR ${state.productListModel!.productModel![index].price!}*\n$deepLink',
state
.productListModel!
.productModel![
index]
.photos![0]);
},
child: const Icon(
Icons.share,
size: 18,
),
),
))
],
),
Helper.allowHeight(context, 5.0),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Flexible(
child: Text(
state
.productListModel!
.productModel![
index]
.productname!
.toString(),
overflow:
TextOverflow.clip,
maxLines: 1,
style:
const TextStyle(
fontSize: 13,
fontWeight:
FontWeight.w500,
),
),
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Flexible(
child: Text(
state
.productListModel!
.productModel![
index]
.seller!
.organization!
.toString(),
overflow:
TextOverflow.clip,
style: TextStyle(
fontSize: 10,
color: AppColors
.greyAA,
fontWeight:
FontWeight.w500,
),
),
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text(
"\u{20B9} ${state.productListModel!.productModel![index].price!}",
style: TextStyle(
fontSize: 14,
color:
AppColors.black,
fontWeight:
FontWeight.bold,
),
),
Helper.allowWidth(
context, 15),
state
.productListModel!
.productModel![
index]
.price !=
state
.productListModel!
.productModel![
index]
.orginalprice
? Text(
"\u{20B9} ${state.productListModel!.productModel![index].orginalprice}",
maxLines: 1,
style:
const TextStyle(
overflow:
TextOverflow
.ellipsis,
decoration:
TextDecoration
.lineThrough,
fontSize: 14,
color:
Colors.red,
fontWeight:
FontWeight
.bold,
),
)
: const SizedBox
.shrink(),
],
),
const SizedBox(height: 8),
],
),
]),
);
},
// separatorBuilder: (context, index) {
// return const SizedBox(
// width: 10.0,
// );
// },
);
i would like to use StaggeredGridView plugins, this is my code that i've tried to use and it work properly that you might needed to create a responsive gridview that contain sort list of data
Padding(
padding: const EdgeInsets.fromLTRB(8, 8, 8, 0),
child: SizedBox(
width: double.infinity,
child: StaggeredGridView.countBuilder(
padding: EdgeInsets.zero,
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
staggeredTileBuilder: (index) => const StaggeredTile.fit(1),
mainAxisSpacing: 10,
crossAxisCount: 2,
crossAxisSpacing: 10,
itemCount: ...,
itemBuilder: (ctx, i) {
....
},
),
),
)

how create GridView with ViewPager in flutter

I am trying to create the grid view inside the page view, what I want is,
In grid view, I want to display only 6 items and other items I want go to another page of the page view, what I mean is I only want 6 items on each page of the page view,
To clarify more, if I have 6 items, the page view will create only one page in which 6 items will appear from the gridview, or if I have 12 items, the page view will create two pages and each page will display 6 items from the gridview, or if I have 16 items, the page view will create three Pages per page 6 items, etc.,
This is the code that I tried to do, but it did not work. Can someone help me with it? Thank you
Expanded(
child: Container(
decoration: const BoxDecoration(
color: Color(0xFFE6E6E6),
image: DecorationImage(
image: AssetImage('assets/images/background_image.png'),
fit: BoxFit.fill,
),
),
child: PageView.builder(
controller: _controller,
physics: const BouncingScrollPhysics(),
itemCount: items.length % 6,
itemBuilder: (context, index) => GridView.builder(
padding:
EdgeInsets.symmetric(horizontal: 20.w, vertical: 20.h),
physics: const ClampingScrollPhysics(),
shrinkWrap: true,
scrollDirection: Axis.vertical,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 20.w,
mainAxisSpacing: 20.h,
childAspectRatio: 4 / 1.5,
),
itemCount: items.length,
primary: false,
itemBuilder: (context, index) => Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15.r),
),
child: Row(
children: [
Container(
width: 140.w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.r),
image: DecorationImage(
image: NetworkImage(
items[index].photoUrl,
),
fit: BoxFit.cover,
),
),
),
Expanded(
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 16.w,
vertical: 18.h,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
items[index].categoryName,
style: TextStyle(
fontSize: 10.sp,
color: const Color(0xFFBCBCBC),
),
),
Text(
items[index].itemName,
style: TextStyle(
fontSize: 12.sp,
color: const Color(0xFFFC4747),
fontWeight: FontWeight.bold,
),
),
const Spacer(),
Text(
'${items[index].price}د.ع',
style: TextStyle(
color: const Color(0xFF40484E),
fontSize: 12.sp,
),
),
Row(
children: [
Icon(
CupertinoIcons.time,
size: 8.sp,
color: const Color(0xFFBCBCBC),
),
Text(
'${items[index].time}m',
style: TextStyle(
fontSize: 8.sp,
color: const Color(0xFFBCBCBC),
),
),
],
)
],
),
),
)
],
),
),
),
),
),
),
A picture showing the shape of the elements
I modified your code the way you wanted Here is the solution :
My modified code will divide your main list into to small lists with 6 items. Here I take main list length is 16 so it's divide into 6 : 6 : 4 items lists.
Output :
Code :
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
#override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
List<int> items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
var gridViewLists = [];
int listBreakerSize = 6;
#override
void initState() {
for (var i = 0; i < items.length; i += listBreakerSize) {
gridViewLists.add(items.sublist(
i, i + listBreakerSize > items.length ? items.length : i + listBreakerSize));
}
super.initState();
}
#override
Widget build(BuildContext context) {
return Column(
children: [
Expanded(
child: Container(
margin: EdgeInsets.only(top: 40),
decoration: const BoxDecoration(
color: Color(0xFFE6E6E6),
),
child: PageView.builder(
// controller: _controller,
physics: const BouncingScrollPhysics(),
itemCount: (items.length / 6).ceil(),
itemBuilder: (context, i) => GridView.builder(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 20),
physics: const ClampingScrollPhysics(),
shrinkWrap: true,
scrollDirection: Axis.vertical,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 20,
mainAxisSpacing: 20,
childAspectRatio: 4 / 1.5,
),
itemCount: gridViewLists[i].length,
primary: false,
itemBuilder: (context, index) => Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15),
),
child: Row(
children: [
Container(
width: 116,
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(15),
),
),
Expanded(
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 16,
vertical: 18,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
//items[index].categoryName,
'categoryName',
style: TextStyle(
fontSize: 10,
color: const Color(0xFFBCBCBC),
),
),
Text(
//items[index].itemName,
'itemName',
style: TextStyle(
fontSize: 12,
color: const Color(0xFFFC4747),
fontWeight: FontWeight.bold,
),
),
const Spacer(),
Text(
// '${items[index].price}د.ع',
'price',
style: TextStyle(
color: const Color(0xFF40484E),
fontSize: 12,
),
),
Row(
children: [
Icon(
CupertinoIcons.time,
size: 8,
color: const Color(0xFFBCBCBC),
),
Text(
//'${items[index].time}m',
'time',
style: TextStyle(
fontSize: 8,
color: const Color(0xFFBCBCBC),
),
),
],
)
],
),
),
)
],
),
),
),
),
),
),
],
);
}
}

Scrollbar is not visible when wrapping listView Builder with SingleChildScrollView or ListView

**> Here is my code. it contains a ListView builder which is wrapped with
RawScrollBar widget and they both wrapped with SingleChildScrollView
Widget. I want a show ScrollBar in ListView.Builder**
Scaffold(
backgroundColor: kPrimaryColor,
body: SafeArea(
child: SizedBox(
height: kGetSize(context).height,
child: Column(
children: [
const SizedBox(
height: 16,
),
const Center(
child: UserLevelDetailsContainer(),
),
Expanded(
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 24, vertical: 24),
**child: SingleChildScrollView(
physics: const ScrollPhysics(),
controller: _scrollController,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'General Subjects',
style: GoogleFonts.openSans(
fontWeight: FontWeight.w700,
fontSize: 20,
color: const Color(0xfff3c304)),
),
const SizedBox(
height: 8,
),
RawScrollbar(
thumbVisibility: true,
interactive: true,
thumbColor: Colors.black,
controller: _scrollController,
radius: const Radius.circular(60),
thickness: 6,
child: ListView.builder(
controller: _scrollController,
physics: const NeverScrollableScrollPhysics(),
itemCount: SubjectDetail.listOfSubjects.length,
shrinkWrap: true,
itemBuilder: (context, index) {
return SizedBox(
width: 344,
height: 96,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
),
child: ListTile(
contentPadding: const EdgeInsets.symmetric(
horizontal: 24, vertical: 8),
title: Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Text(
SubjectDetail
.listOfSubjects[index].name,
style: GoogleFonts.openSans(
fontWeight: FontWeight.w700,
fontSize: 15),
),
),
subtitle: Text(
SubjectDetail
.listOfSubjects[index].description,
style: GoogleFonts.openSans(
fontWeight: FontWeight.w400,
fontSize: 10),
),
trailing: Image.asset(SubjectDetail
.listOfSubjects[index].imageUrl),
),
),
);
},
),
),**
const SizedBox(
height: 8,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'General Subjects',
style: GoogleFonts.openSans(
fontWeight: FontWeight.w700,
fontSize: 20,
color: const Color(0xfff3c304)),
),
Text(
'*select one subject',
style: GoogleFonts.openSans(
fontWeight: FontWeight.w300,
fontSize: 14,
color: const Color(0xfff3c304)),
)
],
),
],
),
),
),
)
],
),
),
),
);
I have given same ScrollController object to ListView builder,
RawScrollBar and SingleChildScollView widget.Altough I had given
different ScrollController objects to them

Flutter : Card with Gridview

I'm New to flutter I want to make this design , it take me awhile to find what to use , but ever time i try to code it and use Listview it give me error ,or the card dont aligns to Gridview.
Try below code hope its helpful to you.refer GridView here
Center(
child: GridView.builder(
shrinkWrap: true,
padding: const EdgeInsets.symmetric(horizontal: 30),
itemCount: 4,
itemBuilder: (ctx, i) {
return Card(
child: Container(
height: 290,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20)),
margin: EdgeInsets.all(5),
padding: EdgeInsets.all(5),
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: Image.network(
'https://tech.pelmorex.com/wp-content/uploads/2020/10/flutter.png',
fit: BoxFit.fill,
),
),
Text(
'Title',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
Row(
children: [
Text(
'Subtitle',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15,
),
),
],
)
],
),
],
),
),
);
},
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 1.0,
crossAxisSpacing: 0.0,
mainAxisSpacing: 5,
mainAxisExtent: 264,
),
),
),
Your result screen->
You can use Gridview and return a Card of your custom style in Gridview Builder I will build your Required Design.
Here is the GridView Official Documentation.
[Documentation1

Flutter cannot fix the overflowed issue of a component

This the issue I have, but I want to keep the text
I dont want to change the layout of the widget, I need to know is the a way to change the height of the widget
widget class that have the issue
class CategoryView extends StatelessWidget {
const CategoryView(
{Key key,
this.category,
this.animationController,
this.animation,
this.callback})
: super(key: key);
final void Function(int id) callback;
final Category category;
final AnimationController animationController;
final Animation<dynamic> animation;
#override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: animationController,
builder: (BuildContext context, Widget child) {
return FadeTransition(
opacity: animation,
child: Transform(
transform: Matrix4.translationValues(
0.0, 50 * (1.0 - animation.value), 0.0),
child: InkWell(
splashColor: Colors.transparent,
onTap: () {
callback(category.id);
},
child: SizedBox(
child: Stack(
alignment: AlignmentDirectional.bottomCenter,
children: <Widget>[
Container(
child: Column(
children: <Widget>[
Expanded(
child: Container(
decoration: BoxDecoration(
color: HexColor('#f7f7f7'),
borderRadius: const BorderRadius.all(
Radius.circular(16.0)),
// border: new Border.all(
// color: BlogSiteAppTheme.notWhite),
),
child: Column(
children: <Widget>[
Expanded(
child: Container(
height: 280,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
top: 16, left: 16, right: 16),
child: Text(
category.title,
textAlign: TextAlign.left,
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
letterSpacing: 0.27,
color:
BlogSiteAppTheme.darkerText,
),
),
),
Padding(
padding: const EdgeInsets.only(
top: 8,
left: 16,
right: 16,
bottom: 4),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Text(
'${category.date.substring(0, 10)}',
textAlign: TextAlign.left,
style: TextStyle(
fontWeight: FontWeight.w200,
fontSize: 12,
letterSpacing: 0.27,
color:
BlogSiteAppTheme.grey,
),
),
Container(
child: Row(
children: <Widget>[
Text(
'${category.excelentCount}',
textAlign:
TextAlign.left,
style: TextStyle(
fontWeight:
FontWeight.w200,
fontSize: 18,
letterSpacing: 0.27,
color:
BlogSiteAppTheme
.grey,
),
),
Icon(
Icons.star,
color: BlogSiteAppTheme
.brightBlue,
size: 20,
),
],
),
)
],
),
),
Padding(
padding: const EdgeInsets.only(
top: 8,
left: 16,
right: 16,
bottom: 10),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Text(
'${category.addedBy}',
textAlign: TextAlign.left,
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 18,
letterSpacing: 0.27,
color: BlogSiteAppTheme
.nearlyBlue,
),
),
Container(
child: Row(
children: <Widget>[
Text(
'${category.goodCount}',
textAlign:
TextAlign.left,
style: TextStyle(
fontWeight:
FontWeight.w200,
fontSize: 18,
letterSpacing: 0.27,
color:
BlogSiteAppTheme
.grey,
),
),
Icon(
Icons.star,
color: BlogSiteAppTheme
.nearlyBlue,
size: 20,
),
],
),
)
],
),
),
],
),
),
),
const SizedBox(
width: 48,
),
],
),
),
),
const SizedBox(
height: 48,
),
],
),
),
Container(
child: Padding(
padding:
const EdgeInsets.only(top: 24, right: 16, left: 16),
child: Container(
decoration: BoxDecoration(
borderRadius:
const BorderRadius.all(Radius.circular(16.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: BlogSiteAppTheme.grey.withOpacity(0.2),
offset: const Offset(0.0, 0.0),
blurRadius: 6.0),
],
),
child: ClipRRect(
borderRadius:
const BorderRadius.all(Radius.circular(16.0)),
child: AspectRatio(
aspectRatio: 1.28,
child: Image.asset(category.imagePath)),
),
),
),
),
],
),
),
),
),
);
},
);
}
}
Featured blog posts Container part
Padding(
padding: const EdgeInsets.only(top: 8),
child: FutureBuilder<bool>(
future: getData(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
} else {
return GridView(
padding: const EdgeInsets.all(8),
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.vertical,
children: List<Widget>.generate(
posts.length,
(int index) {
final int count = posts.length;
final Animation<double> animation =
Tween<double>(begin: 0.0, end: 1.0).animate(
CurvedAnimation(
parent: animationController,
curve: Interval((1 / count) * index, 1.0,
curve: Curves.fastOutSlowIn),
),
);
animationController.forward();
return CategoryView(
callback: (int id) {
widget.callBack(id);
},
category: posts[index],
animation: animation,
animationController: animationController,
);
},
),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 32.0,
crossAxisSpacing: 32.0,
childAspectRatio: 0.8,
),
);
}
},
),
);
Does anyone have a way to fixed this.
I need to keep the text as it gets, so I need a way to expand the widget when it need to expand
GridView must have a childAspectRatio property, try to play around with that and see if you have the wanted result
try wrapping your stack with Expanded with flex:1