使用Getx Flutter在屏幕之间发送数据



我能够从产品页面发送特定索引的id到产品详细信息页面,但是当我从图库中选择图像时,它将参数设置为null

TO PASS ID:您需要使用Get.parameters而不是Get.arguments

因此,当导航到产品详细信息页面时,将id添加到parameters:

Get.toNamed('details-page-name', parameters: {'id': product.id});

当你在details-page-name路由时,你可以使用这个id:

id = Get.parameters['id'];

对于我来说,我只使用正常的东西

Get.off(()=>SecondPage(id : id));

then for the Secondpage

class SecondPage extends StatlessWidget{
final String? id;
SecondPage({this.id});
} 

最新更新