Flutter API Fetch and Sending Data from One screen to another screen

You should try to declare constructor the first page accept the id and push this id to second page or screen like this below code is first page

Navigator.push(
context,
MaterialPageRoute(
  builder: (context) => ABC.withId(
    id,
  ),
 ),
)

the create constructor inside second page screen

class ABC extends StatefulWidget {
  @override
  _ABCState createState() => _ABCState();

  var id;
  
  ABC.withId(String uid) {
    id = uid;
   
  }
}

accept your id inside widget using widget.id

Leave a Comment