【发布时间】:2021-02-18 17:14:02
【问题描述】:
我的应用中有以下小部件:
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: BottomAppBar(
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
IconButton(
icon: Icon(
Icons.photo_library,
size: 30,
),
onPressed: () => _pickImage(ImageSource.gallery),
color: Colors.pink,
),
],
),
),
body: ListView(
children: <Widget>[
if (_imageFile != null) ...[
Container(
padding: EdgeInsets.all(32),
child: Image.file(_imageFile)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
FlatButton(
color: Colors.blue,
child: Icon(Icons.arrow_forward_ios),
onPressed: () =>
Get.toNamed(
AppRoutes.OCR_DETAILS,
arguments: {'image': _imageFile},
),
),
],
),
]
],
)
);
}
以及以下功能来选择图像:
Future _pickImage(ImageSource source) async {
File selected = await ImagePicker.pickImage(source: source);
_imageFile = selected;
_imageLoaded=true;
}
我想导入文件 (_imageFile) 并在导入后将其显示在当前小部件上。 我想使用 GetX 库。 非常感谢您的帮助。
【问题讨论】:
-
您找到解决方案了吗?
标签: flutter dart flutter-getx