In a named route navigation I need to pass some arguments, but on destination the value is null. Here my code:
onSelected: (value){
Navigator.pushNamed(context, '${value['namedRoute']}', arguments: '${value['apiUrl']}');
},
On the destination screen I have:
class DetailList extends StatefulWidget {
final String apiUrl;
DetailList({Key key, @required this.apiUrl,}) : super(key: key);
@override
_DetailList createState() => _DetailList();
}
class _DetailList extends State<DetailList> {
final Color bgcolor = HexToColor('#ffffff');
ApiResponse<List<Detail>> detailList;
int countDetails = 0;
DetailListBloc _detailListBloc;
@override
void initState() {
print('init=${widget.apiUrl}');
super.initState();
_detailListBloc = DetailListBloc(widget.apiUrl);
}
.....
Here the print output is 'init=null'. I do not know where the problem is as I followed this link. Any help will be appreciated.
EDIT
Thank you for all your help. I found this link which describes exactly what I was looking for and it works like a charm.