8000 [CP-beta]Unbreak https://github.com/flutter/flutter/pull/164034 (#167… · flutter/flutter@030e2a5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 030e2a5

Browse files
[CP-beta]Unbreak #164034 (#167736)
This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request) Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request. ### Issue Link: What is the link to the issue this cherry-pick is addressing? #167247 We identified a breaking change in beta, this change un-breaks it. ### Changelog Description: Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples Restore RenderConstrainedLayoutBuilder with default layoutInfo implementation to undo a breaking change. ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch) A class was renamed, which left developers with a "class not found" error as their only guide. ### Workaround: Is there a workaround for this issue? Nope. ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### Validation Steps: What are the steps to validate that this fix works? Classes that mixin RenderConstrainedLayoutBuilder are no longer broken and the code can compile.
1 parent a2e3722 commit 030e2a5

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

packages/flutter/lib/src/widgets/layout_builder.dart

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,12 @@ class _LayoutBuilderElement<LayoutInfoType> extends RenderObjectElement {
302302
/// Provides a [layoutCallback] implementation which, if needed, invokes
303303
/// [AbstractLayoutBuilder]'s builder callback.
304304
///
305-
/// Implementers must provide a [layoutInfo] implementation that is safe to
306-
/// access in [layoutCallback], which is called in [performLayout].
305+
/// Implementers can override the [layoutInfo] implementation with a value
306+
/// that is safe to access in [layoutCallback], which is called in
307+
/// [performLayout]. The default [layoutInfo] returns the incoming
308+
/// [Constraints].
309+
///
310+
/// This mixin replaces [RenderConstrainedLayoutBuilder].
307311
mixin RenderAbstractLayoutBuilderMixin<LayoutInfoType, ChildType extends RenderObject>
308312
on RenderObjectWithChildMixin<ChildType>, RenderObjectWithLayoutCallbackMixin {
309313
LayoutCallback<Constraints>? _callback;
@@ -334,11 +338,18 @@ mixin RenderAbstractLayoutBuilderMixin<LayoutInfoType, ChildType extends RenderO
334338
///
335339
/// This is typically the information that are only made available in
336340
/// [performLayout], which is inaccessible for regular [Builder] widget,
337-
/// such as the incoming [Constraints].
341+
/// such as the incoming [Constraints], which are the default value.
338342
@protected
339-
LayoutInfoType get layoutInfo;
343+
LayoutInfoType get layoutInfo => constraints as LayoutInfoType;
340344
}
341345

346+
/// Generic mixin for [RenderObject]s created by an [AbstractLayoutBuilder] with
347+
/// the the same `LayoutInfoType`.
348+
///
349+
/// Use [RenderAbstractLayoutBuilderMixin] instead, which replaces this mixin.
350+
typedef RenderConstrainedLayoutBuilder<LayoutInfoType, ChildType extends RenderObject> =
351+
RenderAbstractLayoutBuilderMixin<LayoutInfoType, ChildType>;
352+
342353
/// Builds a widget tree that can depend on the parent widget's size.
343354
///
344355
/// Similar to the [Builder] widget except that the framework calls the [builder]
@@ -476,10 +487,6 @@ class _RenderLayoutBuilder extends RenderBox
476487

477488
return true;
478489
}
479-
480-
@protected
481-
@override
482-
BoxConstraints get layoutInfo => constraints;
483490
}
484491

485492
FlutterErrorDetails _reportException(

packages/flutter/lib/src/widgets/sliver_layout_builder.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class SliverLayoutBuilder extends ConstrainedLayoutBuilder<SliverConstraints> {
2929
const SliverLayoutBuilder({super.key, required super.builder});
3030

3131
@override
32-
RenderAbstractLayoutBuilderMixin<SliverConstraints, RenderSliver> createRenderObject(
32+
RenderConstrainedLayoutBuilder<SliverConstraints, RenderSliver> createRenderObject(
3333
BuildContext context,
3434
) => _RenderSliverLayoutBuilder();
3535
}
@@ -38,17 +38,13 @@ class _RenderSliverLayoutBuilder extends RenderSliver
3838
with
3939
RenderObjectWithChildMixin<RenderSliver>,
4040
RenderObjectWithLayoutCallbackMixin,
41-
RenderAbstractLayoutBuilderMixin<SliverConstraints, RenderSliver> {
41+
RenderConstrainedLayoutBuilder<SliverConstraints, RenderSliver> {
4242
@override
4343
double childMainAxisPosition(RenderObject child) {
4444
assert(child == this.child);
4545
return 0;
4646
}
4747

48-
@protected
49-
@override
50-
SliverConstraints get layoutInfo => constraints;
51-
5248
@override
5349
void performLayout() {
5450
runLayoutCallback();

packages/flutter/test/widgets/layout_builder_test.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,10 +1067,6 @@ class _RenderSmartLayoutBuilder extends RenderProxyBox
10671067
onChildWasPainted(extraOffset);
10681068
}
10691069
}
1070-
1071-
@protected
1072-
@override
1073-
BoxConstraints get layoutInfo => constraints;
10741070
}
10751071

10761072
class _LayoutSpy extends LeafRenderObjectWidget {

0 commit comments

Comments
 (0)
0