删除不必要的hook

main
落雨楓 2 years ago
parent 88fb284a6c
commit ac44260f2c

@ -30,10 +30,6 @@ class _ResponsivePairState extends State<ResponsivePair> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
refreshSize();
});
} }
void refreshSize() { void refreshSize() {
@ -87,10 +83,18 @@ class _ResponsivePairState extends State<ResponsivePair> {
); );
} else { } else {
if (_isRow) { if (_isRow) {
var i = -1;
var children = widget.children.map((child) {
i++;
if (i != 0) {
return Flexible(child: child);
}
return child;
}).toList();
inner = Row( inner = Row(
mainAxisAlignment: widget.rowMainAxisAlignment, mainAxisAlignment: widget.rowMainAxisAlignment,
crossAxisAlignment: widget.rowCrossAxisAlignment, crossAxisAlignment: widget.rowCrossAxisAlignment,
children: widget.children, children: children,
); );
} else { } else {
inner = Column( inner = Column(
@ -108,10 +112,10 @@ class _ResponsivePairState extends State<ResponsivePair> {
} }
} }
typedef OnWidgetSizeChange = void Function(Size size, int id); typedef WidgetSizeChangeCallback = void Function(Size size, int id);
class WidgetSizeRenderObject extends RenderProxyBox { class WidgetSizeRenderObject extends RenderProxyBox {
final OnWidgetSizeChange onSizeChange; final WidgetSizeChangeCallback onSizeChange;
final int id; final int id;
Size? currentSize; Size? currentSize;
@ -137,7 +141,7 @@ class WidgetSizeRenderObject extends RenderProxyBox {
} }
class WidgetSizeOffsetWrapper extends SingleChildRenderObjectWidget { class WidgetSizeOffsetWrapper extends SingleChildRenderObjectWidget {
final OnWidgetSizeChange onSizeChange; final WidgetSizeChangeCallback onSizeChange;
final int id; final int id;
const WidgetSizeOffsetWrapper({ const WidgetSizeOffsetWrapper({
Loading…
Cancel
Save