From 0f936a46bf5d5cc932150274ddca7a029f807722 Mon Sep 17 00:00:00 2001 From: jiahao <283739569@qq.com> Date: Thu, 26 Mar 2020 16:49:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=9C=89=E5=8E=9F=E5=9B=BE=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=B8=85=E6=99=B0=E5=8E=9F=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/chat/ChatPageItem.dart | 7 +++++-- lib/chat/full_img_view.dart | 3 ++- lib/chat/group_chat_item.dart | 6 ++++-- lib/utils/HttpUtil.dart | 4 ++-- pubspec.yaml | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/chat/ChatPageItem.dart b/lib/chat/ChatPageItem.dart index b909cde..40237c0 100644 --- a/lib/chat/ChatPageItem.dart +++ b/lib/chat/ChatPageItem.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:io'; import 'dart:math'; import 'dart:typed_data'; @@ -483,6 +484,7 @@ class _ChatPageItemState extends State _imgMsg(List imgData) { var imgSize = _getImgSize(); + ImageProvider provider = MemoryImage(widget.msg.localFile==null?Uint8List.fromList(imgData):File(widget.msg.localFile).readAsBytesSync()); return GestureDetector( child: ClipRRect( @@ -494,7 +496,7 @@ class _ChatPageItemState extends State width: imgSize.width, child: Image( fit: BoxFit.contain, - image: MemoryImage(Uint8List.fromList(imgData)), + image: provider, ), )), borderRadius: BorderRadius.circular(5), @@ -1031,7 +1033,8 @@ class _ChatPageItemState extends State } _receiveImg(BuildContext context, List imgData, {String downloadData}) { - ImageProvider provider = MemoryImage(Uint8List.fromList(imgData)); + + ImageProvider provider = MemoryImage(widget.msg.localFile==null?Uint8List.fromList(imgData):File(widget.msg.localFile).readAsBytesSync()); var imgSize = _getImgSize(); diff --git a/lib/chat/full_img_view.dart b/lib/chat/full_img_view.dart index d4cd273..cdcface 100644 --- a/lib/chat/full_img_view.dart +++ b/lib/chat/full_img_view.dart @@ -56,8 +56,9 @@ class _PhotoPageState extends State Widget build(BuildContext context) { Uint8List fileData; if (widget.msg.localFile != null) { - print('本地了'); + fileData = File(widget.msg.localFile).readAsBytesSync(); +// print('本地了${fileData.lengthInBytes}'); } else { fileData = Uint8List.fromList(widget.msg.msgContent); } diff --git a/lib/chat/group_chat_item.dart b/lib/chat/group_chat_item.dart index 72980ee..42799d8 100644 --- a/lib/chat/group_chat_item.dart +++ b/lib/chat/group_chat_item.dart @@ -472,6 +472,7 @@ class _GroupChatPageItemState extends State _imgMsg(List imgData) { var imgSize = _getImgSize(); + ImageProvider provider = MemoryImage(widget.msg.localFile==null?Uint8List.fromList(imgData):File(widget.msg.localFile).readAsBytesSync()); return GestureDetector( child: ClipRRect( @@ -483,7 +484,7 @@ class _GroupChatPageItemState extends State width: imgSize.width, child: Image( fit: BoxFit.contain, - image: MemoryImage(Uint8List.fromList(imgData)), + image:provider, ), )), borderRadius: BorderRadius.circular(5), @@ -1041,7 +1042,8 @@ class _GroupChatPageItemState extends State } _receiveImg(BuildContext context, List imgData, {String downloadData}) { - ImageProvider provider = MemoryImage(Uint8List.fromList(imgData)); +// ImageProvider provider = MemoryImage(Uint8List.fromList(imgData)); + ImageProvider provider = MemoryImage(widget.msg.localFile==null?Uint8List.fromList(imgData):File(widget.msg.localFile).readAsBytesSync()); var imgSize = _getImgSize(); diff --git a/lib/utils/HttpUtil.dart b/lib/utils/HttpUtil.dart index 86d44dd..7661a77 100644 --- a/lib/utils/HttpUtil.dart +++ b/lib/utils/HttpUtil.dart @@ -44,9 +44,9 @@ class HttpUtil { //static const String BaseUrl = 'http://192.168.0.223:7001/'; //static const String BaseUrl = 'http://192.168.0.207:9080/'; - static const String BaseUrl = 'http://120.79.107.63:9080/'; +// static const String BaseUrl = 'http://120.79.107.63:9080/'; //static const String BaseUrl = 'http://192.168.0.177:9016/'; -// static const String BaseUrl = 'https://datasm.chengyouhd.com/'; + static const String BaseUrl = 'https://datasm.chengyouhd.com/'; static HttpUtil _getInstance() { if (_instance == null) { diff --git a/pubspec.yaml b/pubspec.yaml index bd5e123..a421854 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: chat description: A new Flutter project. #修改版本号后get-clean -version: 1.0.5+6 +version: 1.0.9+13 environment: sdk: ">=2.1.0 <3.0.0"