after following the flutter documentation code to send data to a new screen, I want to retrieve the firestore id of the todo instance in the detail screen. is there a way to do that?
this is the detail screen:
const DetailScreen({super.key});
@override
Widget build(BuildContext context) {
final todo = ModalRoute.of(context)!.settings.arguments as Todo;
// Use the Todo to create the UI.
return Scaffold(
appBar: AppBar(
title: Text(todo.title),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Text(todo.description),
),
);
}
}
2
Answers
When storing or reading the item(s) from the database you should keep the handle of the document ID. Then, when you move to the detail page you can do a firebase lookup on the document ID of the
todo
instance like so:This answer covers sending data between flutter screens. See the Firebase docs here.
just use