0
 itemBuilder: (context, index) => MyImage( image: API.image +'/' `your text`+snapshot.data[index['MainPicture'].toString(), title: snapshot.data[index]['productName'],`your text`
                      subname: snapshot.data[index]['productSubname'],`your text`
                      price: snapshot.data[index][price].toString(),`your text`
                      discount: '% ' +
                          snapshot.data[index]['productDiscount'].toString(),`your text`
           

     ),

I want these parametres to make them to another Screen your text

Gwhyyy
  • 7,554
  • 3
  • 8
  • 35
Cr HN
  • 1
  • What do you mean by ```your text```. Which all are the parameters you require to be send to another screen? Can you give some more details related to the question. – viki Jan 17 '23 at 15:48

1 Answers1

0

Use a navigator like go_router

Later follow the steps accordingly to pass your parameters.

Definition

  GoRoute(
    path: '/sample/:id1/:id2',   Defination of params in the path is important
    name: 'sample',
    builder: (context, state) => SampleWidget(
      id1: state.params['id1'],
      id2: state.params['id2'],
    ),
  ),

Passing the params

 ElevatedButton(
            onPressed: () {
              var param1 = "param1";
              var param2 = "param2";
              context.goNamed("sample", params: {'id1': param1, 'id2': param2});
            },
            child: const Text("Hello"),
          ),

Receiver widget:

class SampleWidget extends StatelessWidget {
  String? id1;
  String? id2;
  SampleWidget({super.key, this.id1, this.id2});

  @override
  Widget build(BuildContext context) {
     ...
  }
}

And refer this answer: Flutter: go_router how to pass multiple parameters to other screen?

krishnaacharyaa
  • 14,953
  • 4
  • 49
  • 88