Define the DetailsPage widget that displays the details of
each person. In Flutter, you can pass arguments into the
widget when navigating to the new route.
Extract the arguments using ModalRoute.of():

    
 
   
     Test in DartPad
   
   
     View on GitHub
   
 
 

    
 class DetailsPage extends StatelessWidget {
   const DetailsPage({super.key});

   @override
   Widget build(BuildContext context) {
     // Read the person instance from the arguments.
     final Person person = ModalRoute.of(
       context,
     )?.settings.arguments as Person;
     // Extract the age.
     final age = '${person.age} years old';
     return Scaffold(
       // Display name and age.
       body: Column(children: [Text(person.name), Text(age)]),
     );
   }
 }

To create more advanced navigation and routing requirements,
use a routing package such as go_router.