I have a code that displays a list of devices. When a user clicks on a device, they are redirected to a page with a detailed description of the device.
phone_list.dart
.....
child: TextButton(
onPressed: (){{
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>const
DeviceDescription(),
settings: RouteSettings(
arguments: phones[index],
),
.....
device_description.dart
class DeviceDescription extends StatelessWidget {
const DeviceDescription({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final device = ModalRoute.of(context)!.settings.arguments as Phone;
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Text(device.name),
........
),
);
}
}
But my problem is that when updating the page with a description of the device, the user is again returned to the page with a list of all devices.
Is there any way to fix this problem? Perhaps I need to write a new route in main.dart?. Then tell me how to change the code so that information about a specific device is displayed on this page.