From ac44260f2c5e0624e75d51e0bfea2bb70af35040 Mon Sep 17 00:00:00 2001 From: Lex Lim Date: Tue, 31 Jan 2023 16:37:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8D=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E7=9A=84hook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{auto_wrap.dart => responsive_pair.dart} | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) rename lib/components/{auto_wrap.dart => responsive_pair.dart} (89%) diff --git a/lib/components/auto_wrap.dart b/lib/components/responsive_pair.dart similarity index 89% rename from lib/components/auto_wrap.dart rename to lib/components/responsive_pair.dart index aa8eef8..dc32993 100644 --- a/lib/components/auto_wrap.dart +++ b/lib/components/responsive_pair.dart @@ -30,10 +30,6 @@ class _ResponsivePairState extends State { @override void initState() { super.initState(); - - WidgetsBinding.instance.addPostFrameCallback((_) { - refreshSize(); - }); } void refreshSize() { @@ -87,10 +83,18 @@ class _ResponsivePairState extends State { ); } else { if (_isRow) { + var i = -1; + var children = widget.children.map((child) { + i++; + if (i != 0) { + return Flexible(child: child); + } + return child; + }).toList(); inner = Row( mainAxisAlignment: widget.rowMainAxisAlignment, crossAxisAlignment: widget.rowCrossAxisAlignment, - children: widget.children, + children: children, ); } else { inner = Column( @@ -108,10 +112,10 @@ class _ResponsivePairState extends State { } } -typedef OnWidgetSizeChange = void Function(Size size, int id); +typedef WidgetSizeChangeCallback = void Function(Size size, int id); class WidgetSizeRenderObject extends RenderProxyBox { - final OnWidgetSizeChange onSizeChange; + final WidgetSizeChangeCallback onSizeChange; final int id; Size? currentSize; @@ -137,7 +141,7 @@ class WidgetSizeRenderObject extends RenderProxyBox { } class WidgetSizeOffsetWrapper extends SingleChildRenderObjectWidget { - final OnWidgetSizeChange onSizeChange; + final WidgetSizeChangeCallback onSizeChange; final int id; const WidgetSizeOffsetWrapper({