|
|
@ -290,6 +290,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
///图片/视频选择 |
|
|
|
///图片/视频选择 |
|
|
|
Future getImageOrVideo(GalleryMode galleryMode) async { |
|
|
|
Future getImageOrVideo(GalleryMode galleryMode) async { |
|
|
|
if (selectCount == 0) return; |
|
|
|
if (selectCount == 0) return; |
|
|
|
|
|
|
|
mediaPaths.clear(); |
|
|
|
List<Media> medias = await ImagePickers.pickerPaths( |
|
|
|
List<Media> medias = await ImagePickers.pickerPaths( |
|
|
|
galleryMode: galleryMode, |
|
|
|
galleryMode: galleryMode, |
|
|
|
selectCount: (galleryMode == GalleryMode.video) ? 1 : selectCount, |
|
|
|
selectCount: (galleryMode == GalleryMode.video) ? 1 : selectCount, |
|
|
@ -1193,7 +1194,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
}, |
|
|
|
}, |
|
|
|
onTap:(){}, |
|
|
|
onTap:(){}, |
|
|
|
child: FutureBuilder( |
|
|
|
child: FutureBuilder( |
|
|
|
future: fetchImageSize(messages[position].attach), |
|
|
|
future: fetchImageSize(messages[position]), |
|
|
|
builder: (BuildContext context, AsyncSnapshot snapshot) { |
|
|
|
builder: (BuildContext context, AsyncSnapshot snapshot) { |
|
|
|
if (snapshot.connectionState == ConnectionState.waiting || snapshot.hasError) { |
|
|
|
if (snapshot.connectionState == ConnectionState.waiting || snapshot.hasError) { |
|
|
|
return Image.file( |
|
|
|
return Image.file( |
|
|
@ -1231,7 +1232,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
}, |
|
|
|
}, |
|
|
|
onTap:(){}, |
|
|
|
onTap:(){}, |
|
|
|
child: FutureBuilder( |
|
|
|
child: FutureBuilder( |
|
|
|
future: fetchImageSize(messages[position].attach), |
|
|
|
future: fetchImageSize(messages[position]), |
|
|
|
builder: (BuildContext context, AsyncSnapshot snapshot) { |
|
|
|
builder: (BuildContext context, AsyncSnapshot snapshot) { |
|
|
|
if (snapshot.connectionState == ConnectionState.waiting || snapshot.hasError) { |
|
|
|
if (snapshot.connectionState == ConnectionState.waiting || snapshot.hasError) { |
|
|
|
return Image.file( |
|
|
|
return Image.file( |
|
|
@ -1286,13 +1287,18 @@ class _ChatDetailsPage extends State<ChatDetailsPage> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Future<Size> fetchImageSize(String imagePath) async { |
|
|
|
Future<Size> fetchImageSize(Message message) async { |
|
|
|
debugPrint("$imagePath"); |
|
|
|
String imageLocalPath = message.attach; |
|
|
|
|
|
|
|
debugPrint("$imageLocalPath"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File file = File(imageLocalPath); |
|
|
|
|
|
|
|
if (!(await file.exists())) { |
|
|
|
|
|
|
|
await qiniu.downloadFile(message.content, savePath: imageLocalPath); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Size size = Size.zero; |
|
|
|
Size size = Size.zero; |
|
|
|
Completer<Size> completer = Completer(); |
|
|
|
Completer<Size> completer = Completer(); |
|
|
|
Image.file( |
|
|
|
Image.file(file).image.resolve(ImageConfiguration()) |
|
|
|
File(imagePath), |
|
|
|
|
|
|
|
).image.resolve(ImageConfiguration()) |
|
|
|
|
|
|
|
.addListener(ImageStreamListener((image, synchronousCall) { |
|
|
|
.addListener(ImageStreamListener((image, synchronousCall) { |
|
|
|
size = Size((image.image.width ?? 0).toDouble(), (image.image.height ?? 0).toDouble()); |
|
|
|
size = Size((image.image.width ?? 0).toDouble(), (image.image.height ?? 0).toDouble()); |
|
|
|
size = resizeImage(size); |
|
|
|
size = resizeImage(size); |
|
|
|