mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Optimize out LayoutBuilder from ReorderableList children (#153987)
PR #147863 used a `LayoutBuilder` to ensure `ReorderableList` proxy items are built with the same constraints as their normal counterparts. However we don't actually need the `LayoutBuilder`, we can just grab the constraints from the `RenderBox` at proxy-creation-time.
This commit is contained in:
parent
9920a8727d
commit
418fa9d626
@ -14,7 +14,6 @@ import 'basic.dart';
|
||||
import 'debug.dart';
|
||||
import 'framework.dart';
|
||||
import 'inherited_theme.dart';
|
||||
import 'layout_builder.dart';
|
||||
import 'localizations.dart';
|
||||
import 'media_query.dart';
|
||||
import 'overlay.dart';
|
||||
@ -1087,8 +1086,6 @@ class _ReorderableItemState extends State<_ReorderableItem> {
|
||||
}
|
||||
}
|
||||
bool _dragging = false;
|
||||
BoxConstraints? get childLayoutConstraints => _childLayoutConstraints;
|
||||
BoxConstraints? _childLayoutConstraints;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -1120,13 +1117,10 @@ class _ReorderableItemState extends State<_ReorderableItem> {
|
||||
return SizedBox.fromSize(size: size);
|
||||
}
|
||||
_listState._registerItem(this);
|
||||
return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
||||
_childLayoutConstraints = constraints;
|
||||
return Transform(
|
||||
transform: Matrix4.translationValues(offset.dx, offset.dy, 0.0),
|
||||
child: widget.child,
|
||||
);
|
||||
});
|
||||
return Transform.translate(
|
||||
offset: offset,
|
||||
child: widget.child,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -1346,7 +1340,7 @@ class _DragInfo extends Drag {
|
||||
dragOffset = itemRenderBox.globalToLocal(initialPosition);
|
||||
itemSize = item.context.size!;
|
||||
itemExtent = _sizeExtent(itemSize, scrollDirection);
|
||||
itemLayoutConstraints = item.childLayoutConstraints!;
|
||||
itemLayoutConstraints = itemRenderBox.constraints;
|
||||
scrollable = Scrollable.of(item.context);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user