From 9da491cba764d6c84b5c9b276929b91ed58eb6a9 Mon Sep 17 00:00:00 2001 From: xiaodong <450468291@qq.com> Date: Thu, 10 Oct 2019 09:31:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=94=AF=E6=8C=81web?= =?UTF-8?q?=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/web/index.html | 10 ++++++++++ lib/widget/calendar_view.dart | 13 +++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 example/web/index.html diff --git a/example/web/index.html b/example/web/index.html new file mode 100644 index 0000000..f81f1ff --- /dev/null +++ b/example/web/index.html @@ -0,0 +1,10 @@ + + + + + flutter_demo + + + + + diff --git a/lib/widget/calendar_view.dart b/lib/widget/calendar_view.dart index e0a1ffa..b3e7a36 100644 --- a/lib/widget/calendar_view.dart +++ b/lib/widget/calendar_view.dart @@ -147,9 +147,14 @@ class CalendarContainerState extends State // }); //暂时先这样写死,提前计算布局的高度,不然会出现问题:a horizontal viewport was given an unlimited amount of I/flutter ( 6759): vertical space in which to expand. + + MediaQueryData mediaQueryData = + MediaQueryData.fromWindow(WidgetsBinding.instance.window); + itemHeight = calendarProvider.calendarConfiguration.itemSize ?? - MediaQueryData.fromWindow(WidgetsBinding.instance.window).size.width / - 7; + mediaQueryData.orientation == Orientation.landscape + ? mediaQueryData.size.height / 10 + : mediaQueryData.size.width / 7; if (calendarProvider.totalHeight == null) { calendarProvider.totalHeight = itemHeight * 6 + calendarProvider.calendarConfiguration.verticalSpacing * (6 - 1); @@ -165,8 +170,8 @@ class CalendarContainerState extends State Widget build(BuildContext context) { LogUtil.log(TAG: this.runtimeType, message: "CalendarContainerState build"); //暂时先这样写死,提前计算布局的高度,不然会出现问题:a horizontal viewport was given an unlimited amount of I/flutter ( 6759): vertical space in which to expand. - itemHeight = calendarProvider.calendarConfiguration.itemSize ?? - MediaQuery.of(context).size.width / 7; +// itemHeight = calendarProvider.calendarConfiguration.itemSize ?? +// MediaQuery.of(context).size.width / 7; if (totalHeight == null) { totalHeight = itemHeight * 6 + calendarProvider.calendarConfiguration.verticalSpacing * (6 - 1);