我有以下 GetX 控制器将参数传递到 Flutter 中的页面:
更新
class HomeController extends GetxController {
File image;
String ocr_text;
onInit(){
super.onInit();
image = Get.arguments['image'];
ocr_text = Get.arguments['ocr_text'];
update();
}
}
Run Code Online (Sandbox Code Playgroud)
捆绑:
class HomeBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<HomeController>(() => HomeController());
}
}
Run Code Online (Sandbox Code Playgroud)
我想从 Ocr_details 页面传递图像:
FlatButton(
color: Colors.blue,
child: Icon(Icons.save_outlined),
onPressed: () {
Get.toNamed(
AppRoutes.HOME,
arguments: {'image': controller.image, 'ocr_text': controller.text},
);
}
),
Run Code Online (Sandbox Code Playgroud)
到主页:
更新:
Container(
padding: EdgeInsets.all(32),
child: GetBuilder<HomeController>(
builder: (_) {
return _.image != null
? Image.file(_.image)
: …Run Code Online (Sandbox Code Playgroud)