提交 b633f578 authored 作者: PDeer's avatar PDeer

feat: 由于分享小程序到微信必须包含 thumbnail 故 thumbnail 改为必填参数

上级 8a2973e7
...@@ -84,7 +84,7 @@ class WeChatShareMiniProgramModel implements WeChatShareBaseModel { ...@@ -84,7 +84,7 @@ class WeChatShareMiniProgramModel implements WeChatShareBaseModel {
this.title, this.title,
this.description, this.description,
this.withShareTicket = false, this.withShareTicket = false,
this.thumbnail, required this.thumbnail,
this.hdImagePath, this.hdImagePath,
this.mediaTagName, this.mediaTagName,
this.messageAction, this.messageAction,
...@@ -102,7 +102,7 @@ class WeChatShareMiniProgramModel implements WeChatShareBaseModel { ...@@ -102,7 +102,7 @@ class WeChatShareMiniProgramModel implements WeChatShareBaseModel {
final WeChatImage? hdImagePath; final WeChatImage? hdImagePath;
final String? title; final String? title;
final String? description; final String? description;
final WeChatImage? thumbnail; final WeChatImage thumbnail;
final bool withShareTicket; final bool withShareTicket;
final String? messageExt; final String? messageExt;
final String? messageAction; final String? messageAction;
...@@ -120,7 +120,7 @@ class WeChatShareMiniProgramModel implements WeChatShareBaseModel { ...@@ -120,7 +120,7 @@ class WeChatShareMiniProgramModel implements WeChatShareBaseModel {
"title": title, "title": title,
_description: description, _description: description,
"withShareTicket": withShareTicket, "withShareTicket": withShareTicket,
_thumbnail: thumbnail?.toMap(), _thumbnail: thumbnail.toMap(),
"hdImagePath": hdImagePath?.toMap(), "hdImagePath": hdImagePath?.toMap(),
_messageAction: messageAction, _messageAction: messageAction,
_mediaTagName: mediaTagName, _mediaTagName: mediaTagName,
......
...@@ -22,8 +22,7 @@ import 'package:fluwx/fluwx.dart'; ...@@ -22,8 +22,7 @@ import 'package:fluwx/fluwx.dart';
void main() { void main() {
group("construct", () { group("construct", () {
test("non default values", () { test("non default values", () {
var thumbnail = var thumbnail = WeChatImage.network("http://openflutter.dev/fluwx.png");
WeChatImage.network("http://openflutter.dev/fluwx.png");
var model = WeChatShareMiniProgramModel( var model = WeChatShareMiniProgramModel(
webPageUrl: "http://openflutter.dev", webPageUrl: "http://openflutter.dev",
miniProgramType: WXMiniProgramType.PREVIEW, miniProgramType: WXMiniProgramType.PREVIEW,
...@@ -41,8 +40,11 @@ void main() { ...@@ -41,8 +40,11 @@ void main() {
}); });
test("default values", () { test("default values", () {
var thumbnail = WeChatImage.network("http://openflutter.dev/fluwx.png");
var model = WeChatShareMiniProgramModel( var model = WeChatShareMiniProgramModel(
webPageUrl: "http://openflutter.dev", userName: "userName"); webPageUrl: "http://openflutter.dev",
userName: "userName",
thumbnail: thumbnail);
expect(model.webPageUrl, "http://openflutter.dev"); expect(model.webPageUrl, "http://openflutter.dev");
expect(model.miniProgramType, WXMiniProgramType.RELEASE); expect(model.miniProgramType, WXMiniProgramType.RELEASE);
expect(model.thumbnail, null); expect(model.thumbnail, null);
...@@ -53,8 +55,7 @@ void main() { ...@@ -53,8 +55,7 @@ void main() {
group("toMap", () { group("toMap", () {
test("with thumbnail", () { test("with thumbnail", () {
var thumbnail = var thumbnail = WeChatImage.network("http://openflutter.dev/fluwx.png");
WeChatImage.network("http://openflutter.dev/fluwx.png");
var map = WeChatShareMiniProgramModel( var map = WeChatShareMiniProgramModel(
webPageUrl: "http://openflutter.dev", webPageUrl: "http://openflutter.dev",
miniProgramType: WXMiniProgramType.PREVIEW, miniProgramType: WXMiniProgramType.PREVIEW,
...@@ -71,10 +72,12 @@ void main() { ...@@ -71,10 +72,12 @@ void main() {
}); });
test("without thumbnail", () { test("without thumbnail", () {
var thumbnail = WeChatImage.network("http://openflutter.dev/fluwx.png");
var map = WeChatShareMiniProgramModel( var map = WeChatShareMiniProgramModel(
webPageUrl: "http://openflutter.dev", webPageUrl: "http://openflutter.dev",
miniProgramType: WXMiniProgramType.PREVIEW, miniProgramType: WXMiniProgramType.PREVIEW,
withShareTicket: true, withShareTicket: true,
thumbnail: thumbnail,
userName: "userName", userName: "userName",
path: "path") path: "path")
.toMap(); .toMap();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论