i am getting error of "incorrect use of parent data widget" in debug console while clicking these buttons specifically error shows when clicking buttons..i am mentioning about the square buttons generated with List & Inkwell widget...pls help
class DetailsPage extends StatefulWidget {
@override
_DetailsPageState createState() => _DetailsPageState();
}
class _DetailsPageState extends State<DetailsPage> {
int isselected = -1;
int starvalue = 4;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
height: double.maxFinite,
width: double.maxFinite,
child: Stack(children: [
Positioned(
child: Container(
width: double.maxFinite,
height: 360,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/mountain.jpeg',
),
fit: BoxFit.cover)),
)),
Positioned(
top: 50,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
onPressed: () {},
icon: Icon(Icons.menu),
color: Colors.white,
),
],
)),
Positioned(
top: 270,
child: Container(
padding: EdgeInsets.only(left: 10, top: 20, right:10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30))),
height: 430,
width: MediaQuery.of(context).size.width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ApplargeText(
text: 'Yesomi',
color: Colors.black.withOpacity(0.8),
),
AppText(
text: '250',
size: 20,
color: AppColors.mainColor,
)
],
),
SizedBox(
height: 10,
),
Row(
children: [
const Icon(Icons.location_on),
SizedBox(
width: 5,
),
AppText(
text: 'USA, California',
color: AppColors.mainColor,
size: 15)
],
),
SizedBox(
height: 10,
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Wrap(
children: List.generate(
5,
(index) => Icon(Icons.star,
color: index < starvalue
? AppColors.starColor
: AppColors.textColor2)),
),
SizedBox(
width: 5,
),
AppText(
text: '4.0',
size: 12,
color: AppColors.mainColor,
),
],
),
SizedBox(
height: 15,
),
ApplargeText(
text: 'people',
color: Colors.black.withOpacity(0.8),
size: 25,
),
AppText(
text: 'Number of people in your group',
size: 15,
color: Colors.black26,
),
SizedBox(
height: 10,
),
Expanded(
child: Wrap(
children: List.generate(
5,
(index) => InkWell(
onTap: () {
setState(() {
isselected = index;
});
},
child: SquareButton(
size: 45,
isIcon: false,
iconn: Icons.search,
text: (index 1).toString(),
textcolor: isselected == index
? Colors.white
: Colors.orange,
backgroundColor: isselected ==index
? Colors.black
: Colors.white,
),
))),
),
SizedBox(
height: 15,
),
ApplargeText(
text: 'Description',
color: Colors.black,
size: 25,
),
AppText(
text:
'Yesomi, the famed hill station of south India, is a romantic locale where natural beauty is everywhere to visit, explore and to enjoy.',
size: 12,
color: Colors.black,
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
SquareButton(
iconn: Icons.favorite_border,
size: 50,
backgroundColor: Colors.white,
isIcon: true,
),
DefaultButtons(
width: 220,
text: 'Book now',
)
],
)
],
),
))
]),
),
);
}
}
// Squarebutton widget
enter code here
import 'package:flutter/material.dart'; import 'package:new_project/constants/appcolors.dart';
class SquareButton extends StatelessWidget {
final String? text;
final Color? textcolor;
final Color backgroundColor;
bool isIcon;
final IconData? iconn;
final Color? colorr;
double size;
SquareButton({
this.colorr,
this.text,
required this.size,
this.textcolor,
required this.backgroundColor,
this.isIcon = false,
this.iconn,
});
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(left: 10, right: 10),
width: size,
height: size,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: backgroundColor,
border: Border.all(color: AppColors.mainColor, width:1.0)),
child: isIcon == false
? Center(
child: Text(
text.toString(),
style: TextStyle(
color: isIcon == false ? textcolor : Colors.white),
)): Icon(iconn));
}
}
CodePudding user response:
You can't use Expanded
inside Wrap
widget.