title: How to navigate page using function in flutter?
body: <p>How to navigate to different page for each _buildcard function? Below are my code. I want to navigate to different page using _buildcard function but still get error since it is function and not class. Is there any way to do?</p>
  <pre><code>        _buildCard(3, &quot;Azzahra\nVilla&quot;, 1400),
          _buildCard(4, &quot;Afsana\nVilla&quot;, 1300)
  
          
   
  
  var rating = 0.0;
  
  
  
  _buildCard(img, text, price)
   {
    
      return Card(
          child: Row(children: &lt;Widget&gt;[
        Container(
          margin: EdgeInsets.all(8.0),
          width: 120.0,
          height: 180.0,
          decoration: BoxDecoration(
              image: DecorationImage(
                  image: AssetImage(&quot;assets/$img.jpeg&quot;), fit: BoxFit.cover),
              borderRadius: BorderRadius.circular(10.0)),
        ),
        Expanded(
            child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: &lt;Widget&gt;[
              Padding(
                  padding: EdgeInsets.all(8.0),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: &lt;Widget&gt;[
                      Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: &lt;Widget&gt;[
                            Text(
                              &quot;$text&quot;,
                              maxLines: 2,
                              textAlign: TextAlign.justify,
                              style: TextStyle(
                                  fontWeight: FontWeight.bold, fontSize: 22.0),
                            ),
                            SizedBox(height: 5.0),
                            Text(
                              &quot;Janda Baik&quot;,
                              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(&quot;rating value -&gt; $value&quot;);
                                // print(&quot;rating value dd -&gt; ${value.truncate()}&quot;);
                              },
                            ),
                          ]),
                      Column(children: &lt;Widget&gt;[
                        Text(
                          &quot;\RM$price&quot;,
                          style: TextStyle(
                              fontSize: 22.0, fontWeight: FontWeight.bold),
                        ),
                        Text(
                          &quot;per night&quot;,
                          style: TextStyle(fontSize: 11.0, color: Colors.grey),
                        )
                  
  </code></pre>