I'm trying to pass a title to the next page.
Keep in mind that FIRST and SECOND page are on two different dart file
First page:
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Museo(title: newMuseo[index]['title'])
)
);
Second page:
class Museo extends StatelessWidget {
final String title;
Museo({Key key, @required this.title}) : super(key: key);
Widget build(BuildContext context){
...
}
}
It works but Android Studio keeps telling me this:
The named parameter 'title' isn't defined.
I tried to remove the title:
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Museo(newMuseo[index]['title'])
)
);
But it doesn't work anymore.
lib/Home.dart:110:70: Error: Too many positional arguments: 0 allowed, but 1 found.
Try removing the extra positional arguments.
builder: (context) => Museo(newMuseo[index]['title'])
^
lib/Museo.dart:294:3: Context: Found this candidate, but the arguments don't match.
Museo({Key key, @required this.title}) : super(key: key);
^^^^^
I followed this guide:
https://flutter.dev/docs/cookbook/navigation/passing-data
question from:
https://stackoverflow.com/questions/65950883/flutter-send-data-to-a-new-route-saying-that-the-parameter-isnt-defined 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…