Another exception was thrown: RenderBox was not laid out: RenderFlex#6ac69 - flutter

I want to display list and the data come from API. And I got error
Another exception was thrown: RenderBox was not laid out: RenderPadding#64692 relayoutBoundary=up5
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
I don't know what kind of error is this..
Bellow is my issue code
return AlertDialog(
insetPadding: EdgeInsets.only(bottom: 520),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
title: Container(
color: Color.fromARGB(255, 253, 253, 253),
child: Text('Comment', style: TextStyle(color: Color.fromARGB(255, 4, 4, 4))),
padding: const EdgeInsets.all(17),
margin: const EdgeInsets.all(0),
),
titlePadding: const EdgeInsets.all(0),
content: SingleChildScrollView(
child: Column(mainAxisSize: MainAxisSize.min, children: < Widget > [
GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
),
itemCount: commentList.length,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.all(2.0),
child: Container(
child: InkWell(
child: Container(
padding: EdgeInsets.only(bottom: 10, top: 10, left: 20, right: 20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Color(0xffD4D4D4), width: 2.0)),
child: Column(
children: < Widget > [
SizedBox(height: 15),
Expanded(
child: Text(
"test",
textAlign: TextAlign.justify,
style: TextStyle(fontSize: 15, fontWeight: FontWeight.normal),
))
],
)),
)),
);
},
),
])),
);

The SingleChildScrollView can only have one child, and the GridView expands to fill the available space.
To fix the problem, wrap your GridView with a SizedBox and give it some height/width:
AlertDialog(
insetPadding: EdgeInsets.only(bottom: 520),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
title: Container(
color: Color.fromARGB(255, 253, 253, 253),
child: Text('Comment',
style: TextStyle(color: Color.fromARGB(255, 4, 4, 4))),
padding: const EdgeInsets.all(17),
margin: const EdgeInsets.all(0),
),
titlePadding: const EdgeInsets.all(0),
content: SingleChildScrollView(
child: Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
// <--- Add SizedBox here
SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 0.5,
child: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
),
itemCount: commentList.length,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.all(2.0),
child: Container(
child: InkWell(
child: Container(
padding: EdgeInsets.only(
bottom: 10, top: 10, left: 20, right: 20),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border:
Border.all(color: Color(0xffD4D4D4), width: 2.0)),
child: Column(
children: <Widget>[
SizedBox(height: 15),
Expanded(
child: Text(
"test",
textAlign: TextAlign.justify,
style: TextStyle(
fontSize: 15, fontWeight: FontWeight.normal),
))
],
)),
)),
);
},
),
),
])),
);

Related

How to set children heights in GridView to the maximum height among children?

I'd like to set the heights of the children of a GridView to the maximum height among all the children. I don't want to type a fixed value in childrenAspectRatio or in mainAxisExtent, I need the heights to adapt to the biggest child.
Code:
GridView.builder(
shrinkWrap: true,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisExtent: 256, // don't want to set this because could cause overflow or waste of blank space
),
itemCount: prizes.length,
itemBuilder: (context, index){
return Card(
elevation: 3.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Stack(
children: [
Image.asset(prizes[index]["image"]),
]
),
Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Text(
prizes[index]["name"],
style: const TextStyle(fontWeight: FontWeight.bold, ),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
prizes[index]["cost"].toString(),
style: const TextStyle(fontWeight: FontWeight.normal),
),
Padding(
padding: const EdgeInsets.only(left : 4.0),
child: SizedBox(
width: 14,
height: 14,
child: svg),
),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 10),
child: ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.blue),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
)
)
),
onPressed: () async {
},
child: Padding(
padding: EdgeInsets.all(15.0),
child: Text(AppLocalizations.of(context)!.riscuoti,
style: TextStyle(
fontSize: 16
),
),
),
),
),
],
),
),
);
},
),

Flutter GridView.builder how to put children symmetric

i use GridView.builder to build my catalog and my catalog looks bad, how can i put my grid symmetrically :
i want my catalog to look like this :
it is my GridView.builder code:
Widget buildCatalog(List<Product> product) => GridView.builder(
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 300,
childAspectRatio: 3 / 5,
crossAxisSpacing: 5,
mainAxisSpacing: 10),
itemCount: product.length,
itemBuilder: (context, index) {
final productItem = product[index];
final media = product[index].media?.map((e) => e.toJson()).toList();
final photo = media?[0]['links']['local']['thumbnails']['350'];
return Container(
padding: EdgeInsets.only(left: 15, right: 15, top: 10),
margin: EdgeInsets.symmetric(vertical: 8, horizontal: 10),
decoration: BoxDecoration(color: Colors.white,
borderRadius: BorderRadius.circular(20)),
child: Column(
children: <Widget>[
InkWell(
child: Container(
margin: EdgeInsets.all(8),
child:
// Image.network(productItem.media),
Image.network(media != null ? 'https://cdn.yiwumart.org/${photo}' : 'https://yiwumart.org/images/shop/products/no-image-ru.jpg'),
),
),
SizedBox(height: 10,),
Text(productItem.name, textAlign: TextAlign.center, style: TextStyle(fontSize: 20),),
Container(
width: MediaQuery.of(context).size.width * 0.8,
child: ElevatedButton(onPressed: () {}, child: Text('5000 тг')))
],
),
);
},
);
Try this:
Container(
padding: EdgeInsets.only(left: 15, right: 15, top: 10),
margin: EdgeInsets.symmetric(vertical: 8, horizontal: 10),
decoration: BoxDecoration(
color: Colors.white, borderRadius: BorderRadius.circular(20)),
child: Column(
children: <Widget>[
InkWell(
child: Container(
margin: EdgeInsets.all(8),
child:
// Image.network(productItem.media),
Image.network(media != null
? 'https://cdn.yiwumart.org/${photo}'
: 'https://yiwumart.org/images/shop/products/no-image-ru.jpg'),
),
),
SizedBox(
height: 10,
),
Text(
productItem.name,
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 20),
),
Spacer(),
Container(
width: MediaQuery.of(context).size.width * 0.8,
child: ElevatedButton(
onPressed: () {}, child: Text('5000 тг')))
],
),
),

Flutter - RangeError (index)

I am getting "RangeError (index): Invalid value: Not in inclusive range 0..4: 5" error in my flutter app.
Error
This is my code and I hope somebody is able to help me fixing the error:
import 'package:fluttertravelapp/models/beach_model.dart';
import 'package:fluttertravelapp/models/popular_model.dart';
import 'package:fluttertravelapp/screens/selected_place_screen.dart';
import 'package:fluttertravelapp/widgets/bottom_navigation_bar.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:fluttertravelapp/models/recommended_model.dart';
import 'package:fluttertravelapp/widgets/custom_tab_indicator.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:cached_network_image/cached_network_image.dart';
class HomeScreen extends StatefulWidget {
#override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
// Page Controller
final _pageController = PageController(viewportFraction: 0.877);
#override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: BottomNavigationBarTravel(),
body: SafeArea(
child: Container(
child: ListView(
physics: BouncingScrollPhysics(),
// Custom Navigation Drawer and Search Button
children: [
Container(
height: 57.6,
margin: EdgeInsets.only(top: 28.8, left: 28.8, right: 28.8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
height: 57.6,
width: 57.6,
padding: EdgeInsets.all(18),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(9.6),
color: Color(0x080a0928),
),
child: SvgPicture.asset('assets/svg/icon_drawer.svg'),
),
Container(
height: 57.6,
width: 57.6,
padding: EdgeInsets.all(18),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(9.6),
color: Color(0x080a0928),
),
child: SvgPicture.asset('assets/svg/icon_search.svg'),
),
],
),
),
// Text Widget for Title
Padding(
padding: EdgeInsets.only(top: 48, left: 28.8),
child: Text('Explore\nthe Nature', style: GoogleFonts.playfairDisplay(
fontSize: 45.6,
fontWeight: FontWeight.w700,
),),
),
//Custom Tab bar with Custom Indicator
Container(
height: 30,
margin: EdgeInsets.only(left: 14.4, top: 28.8),
child: DefaultTabController(
length: 4,
child: TabBar(labelPadding: EdgeInsets.only(left: 14.4, right: 14.4),
indicatorPadding: EdgeInsets.only(left: 14.4, right: 14.4),
isScrollable: true,
labelColor: Color(0xFF000000),
unselectedLabelColor: Color(0xFF8a8a8a),
labelStyle: GoogleFonts.lato(
fontSize: 14,
fontWeight: FontWeight.w700,
),
unselectedLabelStyle: GoogleFonts.lato(
fontSize: 14,
fontWeight: FontWeight.w700,
),
indicator: RoundedRectangleTabIndicator(
color: Color(0xFF000000), weight: 2.4, width: 14.4
),
tabs: [
Tab(
child: Container(
child: Text('Recommended'),
),
),
Tab(
child: Container(
child: Text('Popular'),
),
),
Tab(
child: Container(
child: Text('New Destination'),
),
),
Tab(
child: Container(
child: Text('Hidden Gems'),
),
),
],),),
),
//ListView Widget with PageView
//Recommendations section
Container(
height: 218.4,
margin: EdgeInsets.only(top: 16,),
child: PageView(
physics: BouncingScrollPhysics(),
controller: _pageController,
scrollDirection: Axis.horizontal,
children: List.generate(
recommendations.length,
(int index) => GestureDetector(
onTap: (){
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => SelectedPlaceScreen(
recommendedModel: recommendations[index])));
},
child: Container(
margin: EdgeInsets.only(right: 28.8),
width: 333.6,
height: 218.4,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(9.6),
image: DecorationImage(
fit: BoxFit.cover,
image: CachedNetworkImageProvider(recommendations[index].image),
),
),
child: Stack(
children: [
Positioned(
bottom: 19.2,
left: 19.2,
child: ClipRRect(
borderRadius: BorderRadius.circular(4.8),
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaY: 19.2, sigmaX: 19.2),
child: Container(
height: 36,
padding: EdgeInsets.only(
left: 16.72, right: 14.4),
alignment: Alignment.centerLeft,
child: Row(
children: [
SvgPicture.asset('assets/svg/icon_location.svg'),
SizedBox(width: 9.52,),
Text(recommendations[index].name,
style: GoogleFonts.lato(
fontWeight: FontWeight.w700,
color: Colors.white,
fontSize: 16.8,),
),
],
),
),
),
),
)
],
),
),
)),
),
),
//Dots Indicator
//Using SmoothPageIndicator Library
Padding(padding: EdgeInsets.only(left: 28.8, top: 28.8),
child: SmoothPageIndicator(
controller: _pageController,
count: recommendations.length,
effect: ExpandingDotsEffect(
activeDotColor: Color(0xFF8a8a8a),
dotColor: Color(0xFFabababab),
dotHeight: 4.8,
dotWidth: 6,
spacing: 4.8,
),
),
),
//Text Widget for Popular Categories
Padding(
padding: EdgeInsets.only(top: 48, left: 28.8, right: 28.8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Popular Categories',
style: GoogleFonts.playfairDisplay(
fontSize: 28,
fontWeight: FontWeight.w700,
color: Color(0xFF000000),
),
),
Text(
'Show All',
style: GoogleFonts.lato(
fontSize: 16.8,
fontWeight: FontWeight.w500,
color: Color(0xFF8a8a8a),
),
),
],
),
),
//ListView for Popular Categories Section
Container(
margin: EdgeInsets.only(top: 33.6,),
height: 45.6,
child: ListView.builder(
itemCount: populars.length,
scrollDirection: Axis.horizontal,
physics: BouncingScrollPhysics(),
padding: EdgeInsets.only(left: 28.8, right: 9.6),
itemBuilder: (context, index){
return Container(
margin: EdgeInsets.only(right: 19.2),
height: 45.6,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(9.6),
color: Color(populars[index].color),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(width: 19.2,),
Image.asset(populars[index].image,height: 16.8,),
SizedBox(width: 19.2,),
],
),
);
},
),
),
//ListView for Beach Section
Container(
margin: EdgeInsets.only(top: 28.8, bottom: 16.8),
height: 124.8,
child: ListView.builder(
itemCount: beaches.length,
padding: EdgeInsets.only(left: 28.8, right: 12),
scrollDirection: Axis.horizontal,
physics: BouncingScrollPhysics(),
itemBuilder: (context, index){
return Container(
height: 124,
width: 188.4,
margin: EdgeInsets.only(right: 16.8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(9.6),
image: DecorationImage(
fit: BoxFit.cover,
image: CachedNetworkImageProvider(beaches[index].image),
)
),
);
},
),
)
],
),
),
),
);
}
}
If you want the full code you can see the code from https://github.com/abdulazizahwan/flutter_travel_app
I tried the same code.

Cannot scroll to the bottom of the page flutter (bounces back)

SingleChildScrollView can't scroll to the bottom of the page (bounced back). I have try to adding padding bottom inset as the following link but it did nothing. I dont want to use SizedBox as last childern of the column for this case. Maybe you guys have other solution? Thank you
Edit : I try to wrap ListView.builder with Containerand its work as I expected. But sometimes I have a same problem with scrolling, can you guys explain why it`s happen?
More Edit: I try to run it in different sreen size (4inch). And it bounces back again
Codes
ListView(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
children: <Widget>[
Container(
width: size.width,
height: size.height,
color: kSecondaryColor,
child: Container(
// margin: EdgeInsets.only(top: 20),
width: size.width,
height: size.height,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(35),
topRight: Radius.circular(35),
),
),
child: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(35),
topRight: Radius.circular(35),
),
child: ScrollConfiguration(
behavior: MyBehavior(),
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.only(top: 20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// PageView.builder(
// scrollDirection: Axis.horizontal,
// onPageChanged: _onchanged,
// controller: _controller,
// itemCount: _newsSlider.length,
// itemBuilder: (context, int index) {
// return _newsSlider[index];
// },
// ),
Padding(
padding:
const EdgeInsets.fromLTRB(20, 20, 0, 20),
child: Text(
'Highlights',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16),
),
),
CarouselSlider(
items: imageSliders,
options: CarouselOptions(
autoPlay: true,
enlargeCenterPage: true,
enableInfiniteScroll: false,
aspectRatio: 2.0,
onPageChanged: (index, reason) {
setState(() {
_current = index;
});
}),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: imgList.map((url) {
int index = imgList.indexOf(url);
return Container(
width: 8.0,
height: 8.0,
margin: EdgeInsets.symmetric(
vertical: 10.0, horizontal: 2.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _current == index
? kSecondaryColor
: Color.fromRGBO(0, 0, 0, 0.4),
),
);
}).toList(),
),
Padding(
padding:
const EdgeInsets.fromLTRB(20, 20, 0, 0),
child: Text(
'News Update',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16),
),
),
ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: 5,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
NewsDetailsView()),
);
},
child: Padding(
padding: const EdgeInsets.fromLTRB(
20, 20, 20, 0),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(5)),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey
.withOpacity(0.1),
spreadRadius: 2,
blurRadius: 2,
offset: Offset(0,
2),
),
],
),
child: ListTile(
leading: Image.network(
'https://source.unsplash.com/random/200x200?sig=1'),
title: Padding(
padding: const EdgeInsets.only(
top: 10.0),
child: Text(
'My News Title',
style: TextStyle(
color: Colors.black),
),
),
subtitle: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text('1 May 2021'),
Text(''),
Text(''),
],
),
isThreeLine: true,
),
),
),
);
}),
// SizedBox(height: 100)
],
),
),
)),
),
))
],
));

Could not load Images in GridView builder()

i am beginner in Flutter , i am trying to create a gridview builder with a card that contains an image, the gridview. builder in the bottom works fine but the gridview builder on the top do not load any image, the difference of the both gridviews is that the one that have problem : the image is inside a card,
I do not have any idea why the second works and the one on the top do not do that even they use the same assets
the error i am getting is about Invalid argument(s): No host specified in URI for every asset
import 'package:flutter/material.dart';
import 'package:footyappp/clubs/Clubs.dart';
import 'package:footyappp/results/results.dart';
import 'package:footyappp/schedules/schedules.dart';
import 'package:footyappp/stats/player_goals.dart';
import 'package:footyappp/tables%20copy/league_board.dart';
import 'package:footyappp/stats/player_assists.dart';
import 'package:footyappp/stats/player_red_cards.dart';
import 'package:footyappp/stats/player_yellow_cards.dart';
class Statss extends StatelessWidget {
List<String> images = [
"Assets/tt.jpg",
"Assets/qatarairways.jpg",
"Assets/LOGO_Danao.jpg",
"Assets/delice.jpg"
];
List<String> menu = [
"Assets/tt.jpg",
"Assets/qatarairways.jpg",
"Assets/LOGO_Danao.jpg",
"Assets/delice.jpg"
];
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Stats"),
backgroundColor: Colors.blue[300],
elevation: 0.0,
),
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [Colors.purple, Colors.blue])),
child: ListView(
children: [
SizedBox(
height: 20,
),
Container(
margin: EdgeInsets.fromLTRB(10, 0, 0, 0),
child: Text(
"Statistiques",
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.w900,
color: Colors.white),
),
),
SizedBox(
height: 30,
),
Container(
padding: EdgeInsets.all(12.0),
child: GridView.builder(
shrinkWrap: true,
itemCount: menu.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 1.0,
mainAxisSpacing: 1.0),
itemBuilder: (BuildContext context, int index) {
return Card(
elevation: 4.0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0),
),
child: Padding(
padding: const EdgeInsets.all(16.0),
child:
Column(
children: <Widget>[
Container(
height: 60,
width: 60,
child:
Image.network(menu[index]),
),
const SizedBox(width:10.0),
],
),
),
);
},
),
),
Container(
margin: EdgeInsets.fromLTRB(15, 30, 15, 0),
child: Column(
children: [
SizedBox(
height: 1,
),
ButtonTheme(
minWidth: double.infinity,
height: 40,
child: RaisedButton(
child: Align(
child: Text(
"Top Scorers",
style: TextStyle(fontSize: 17),
textAlign: TextAlign.right,
),
alignment: Alignment.centerLeft,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Scorers()),
);
},
color: Colors.grey.shade300,
textColor: Colors.black,
padding: EdgeInsets.fromLTRB(15, 8, 8, 8),
splashColor: Colors.green,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(30.0))),
),
SizedBox(
height: 1,
),
ButtonTheme(
minWidth: double.infinity,
height: 40,
child: RaisedButton(
child: Align(
child: Text(
"Top Assists",
style: TextStyle(fontSize: 17),
textAlign: TextAlign.right,
),
alignment: Alignment.centerLeft,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Assists()),
);
},
color: Colors.grey.shade300,
textColor: Colors.black,
padding: EdgeInsets.fromLTRB(15, 8, 8, 8),
splashColor: Colors.green,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(30.0))),
),
SizedBox(
height: 1,
),
ButtonTheme(
minWidth: double.infinity,
height: 40,
child: RaisedButton(
child: Align(
child: Text(
"Yellow Cards",
style: TextStyle(fontSize: 17),
textAlign: TextAlign.right,
),
alignment: Alignment.centerLeft,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => YellowCards()),
);
},
color: Colors.grey.shade300,
textColor: Colors.black,
padding: EdgeInsets.fromLTRB(15, 8, 8, 8),
splashColor: Colors.green,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(30.0))),
),
SizedBox(
height: 1,
),
ButtonTheme(
minWidth: double.infinity,
height: 40,
child: RaisedButton(
child: Align(
child: Text(
"Red Cards",
style: TextStyle(fontSize: 17),
textAlign: TextAlign.right,
),
alignment: Alignment.centerLeft,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => RedCards()),
);
},
color: Colors.grey.shade300,
textColor: Colors.black,
padding: EdgeInsets.fromLTRB(15, 8, 8, 8),
splashColor: Colors.green,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(30.0))),
),
SizedBox(
height: 30,
)
],
),
),
Container(
padding: EdgeInsets.all(12.0),
child: GridView.builder(
shrinkWrap: true,
itemCount: images.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 4.0,
mainAxisSpacing: 4.0),
itemBuilder: (BuildContext context, int index) {
return Image.asset(images[index]);
},
),
),
SizedBox(
height: 30,
)
],
),
));
}
}
here how it looks:
i am tryin to make it works
This is because you are using Image.network(menu[index]) for the top gridview.
change it to
Image.asset(menu[index]), it'll work, because you are loading your images from your assets, and not anything from the network.