【发布时间】:2021-08-04 19:50:18
【问题描述】:
我使用 multi_image_picker 包从图库中获取图像。现在我想实现编辑页面,我需要将我的图像 url 列表转换为资产并将资产列表设置为 multi_image_picker。 这是我的多图像选择器:
List<Asset> resultList = <Asset>[];
String error = 'No Error Detected';
try {
resultList = await MultiImagePicker.pickImages(
maxImages: 300,
enableCamera: true,
selectedAssets: _imagesAssets,
cupertinoOptions: CupertinoOptions(takePhotoIcon: "chat"),
materialOptions: MaterialOptions(
actionBarColor: "#abcdef",
actionBarTitle: "صندوق شهدای موردک",
allViewTitle: "تمام تصاویر",
useDetailsView: false,
selectCircleStrokeColor: "#000000",
),
);
} on Exception catch (e) {
error = e.toString();
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_imagesAssets = resultList;
});
}
以及用于显示所选图像的网格视图:
return GridView.count(
crossAxisCount: 2,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
padding: EdgeInsets.all(10),
children: List.generate(_imagesAssets.length, (index) {
Asset asset = _imagesAssets[index];
return AssetThumb(
asset: asset,
width: 100,
height: 100,
);
}),
);
【问题讨论】:
-
您在这里遇到的错误或问题是什么?有什么显示吗?什么都没有显示?显示错误?
-
我有一个 url 列表,我想将其转换为资产列表以在 gridview 中显示图像