'how to get id sent with a Screen in flutter
i send an idd from another screen when i want to navigate to this WaitingScreen
Now when i want to use the idd , I get an error in the line
FirebaseFirestore.instance.collection('ambulance').doc(idd).get()
class WaitingScreen extends StatefulWidget {
final String idd;
String? Key;
WaitingScreen({required this.idd}) : super();
_WaitingScreenState createState () => _WaitingScreenState( ) ;
}
class _WaitingScreenState extends State<WaitingScreen> with SingleTickerProviderStateMixin{
late AnimationController _controller;
@override
void initState() {
super.initState();
_controller =
AnimationController(vsync: this, duration: Duration(minutes: 5));
_controller.forward();
}
@override
Widget build(BuildContext context) {
String? valuee;
return FutureBuilder<DocumentSnapshot>(
future: FirebaseFirestore.instance.collection('ambulance').doc(idd).get(),
Solution 1:[1]
When using a stateful widget, you need to reference variables on the widget itself by using the following construction:
widget.idd
By using the prefix widget., you make sure to access the variables on the widget, and not on the state you are in.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | George |
