I'm trying to use drawer with the body as ListView but when I try to click the drawer icon it gives my that error so I considered that there is a problem with the drawer hight so i wraped the drawer widget with size box of height but nothing changed
I tried to wrap the List View with a size box and give it fixed height but nothing changed
so is there any way to solve this
this the code of the bage
import 'package:flutter/material.dart';
import 'package:sakani/constants.dart';
import 'package:sakani/models/picture_cat_model.dart';
import 'package:sakani/widgets/custom_drawer.dart';
import '../widgets/image_cards_builder.dart';
class PrevieView extends StatelessWidget {
const PrevieView({
super.key,
required this.image,
});
static String id = 'Previeview';
final PicCat image;
@override
Widget build(BuildContext context) {
final List<String> type = image.type.split(',');
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(type.first),
elevation: 0,
foregroundColor: Colors.black,
backgroundColor: Colors.transparent,
),
drawer: const CustomDrawer(),
body: Padding(
padding: const EdgeInsets.all(5),
child:ListView(
children: [
SizedBox(
child: Stack(
children: [
SizedBox(
width: double.infinity,
child: ClipRRect(
borderRadius: BorderRadius.circular(kPrimaryPadding),
child: Image.network(
image.image,
),
),
),
Positioned(
child: IconButton(
onPressed: () {},
icon: const ImageIcon(
AssetImage("assets/icons/dots.png")),
color: Colors.white,
))
],
),
),
Padding(
padding: const EdgeInsets.only(
left: 10,
),
child: Row(
children: [
const Expanded(
child: Text(
"more similar photos",
style: TextStyle(
fontSize: 20,
color: Colors.black,
),
),
),
IconButton(
onPressed: () {},
icon: Icon(
Icons.favorite,
color: Colors.red[700],
))
],
),
),
ImagesBuilder(type: type.first),
],
),
));
}
}
and this is the drawer code
import 'package:flutter/material.dart';
import 'package:sakani/constants.dart';
import '../views/general_page.dart';
class CustomDrawer extends StatelessWidget {
const CustomDrawer({super.key});
@override
Widget build(BuildContext context) {
return Drawer(
width: 200,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
DrawerHeader(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end,
children: [
const Spacer(
flex: 100,
),
const Padding(
padding: EdgeInsets.only(top: 60),
child: Text(
kPrimaryAppName,
style: TextStyle(fontSize: 30),
),
),
const Spacer(),
IconButton(onPressed: () {}, icon: const Icon(Icons.light_mode)),
],
)),
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: const ListTile(
title: Text("General"),
),
),
GestureDetector(
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return const GeneralView(
type: "nature",
);
}));
},
),
],
),
);
}
}'
Bcoz you have added Spacer() in your DrawerHeader remove this spacer and use SizedBox(width: "your value") instead.
never use Spacer() in Row/Column without using Expanded