如何为每个 _buildcard 函数导航到不同的页面?下面是我的代码。我想使用 _buildcard 函数导航到不同的页面,但仍然会出错,因为它是函数而不是类。有什么办法吗?
_buildCard(3, "Azzahra\nVilla", 1400),
_buildCard(4, "Afsana\nVilla", 1300)
var rating = 0.0;
_buildCard(img, text, price)
{
return Card(
child: Row(children: <Widget>[
Container(
margin: EdgeInsets.all(8.0),
width: 120.0,
height: 180.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/$img.jpeg"), fit: BoxFit.cover),
borderRadius: BorderRadius.circular(10.0)),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"$text",
maxLines: 2,
textAlign: TextAlign.justify,
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 22.0),
),
SizedBox(height: 5.0),
Text(
"Janda Baik",
style:
TextStyle(fontSize: 11.0, color: Colors.grey),
),
SizedBox(height: 5.0),
SmoothStarRating(
rating: rating,
isReadOnly: false,
size: 14,
filledIconData: Icons.star,
halfFilledIconData: Icons.star_half,
defaultIconData: Icons.star_border,
color: Colors.yellow,
starCount: 5,
allowHalfRating: true,
spacing: 2.0,
onRated: (value) {
print("rating value -> $value");
// print("rating value dd -> ${value.truncate()}");
},
),
]),
Column(children: <Widget>[
Text(
"\RM$price",
style: TextStyle(
fontSize: 22.0, fontWeight: FontWeight.bold),
),
Text(
"per night",
style: TextStyle(fontSize: 11.0, color: Colors.grey),
)