Skip to content

Commit 027bb84

Browse files
authored
Make SlottedMultiChildRenderObjectWidgetMixin a concrete class (#126108)
This is a proof of concept for renaming SlottedMultiChildRenderObjectWidgetMixin to SlottedMultiChildRenderObjectWidget and making it a concrete class. I also made SlottedContainerRenderObjectMixin generic instead of being specialized to RenderBox. I don't think this is something we can easily automigrate, but we may not need to, I don't know how common this is...
1 parent 5235a0f commit 027bb84

File tree

7 files changed

+100
-75
lines changed

7 files changed

+100
-75
lines changed

examples/api/lib/widgets/slotted_render_object_widget/slotted_multi_child_render_object_widget_mixin.0.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import 'package:flutter/material.dart';
66
import 'package:flutter/rendering.dart';
77

8-
/// Flutter code sample for [SlottedMultiChildRenderObjectWidgetMixin].
8+
/// Flutter code sample for [SlottedMultiChildRenderObjectWidget].
99
1010
/// Slots used for the children of [Diagonal] and [RenderDiagonal].
1111
enum DiagonalSlot {
@@ -14,9 +14,9 @@ enum DiagonalSlot {
1414
}
1515

1616
/// A widget that demonstrates the usage of
17-
/// [SlottedMultiChildRenderObjectWidgetMixin] by providing slots for two
17+
/// [SlottedMultiChildRenderObjectWidget] by providing slots for two
1818
/// children that will be arranged diagonally.
19-
class Diagonal extends RenderObjectWidget with SlottedMultiChildRenderObjectWidgetMixin<DiagonalSlot> {
19+
class Diagonal extends SlottedMultiChildRenderObjectWidget<DiagonalSlot, RenderBox> {
2020
const Diagonal({
2121
super.key,
2222
this.topLeft,
@@ -49,7 +49,7 @@ class Diagonal extends RenderObjectWidget with SlottedMultiChildRenderObjectWidg
4949
// [SlottedRenderObjectElement.update].
5050

5151
@override
52-
SlottedContainerRenderObjectMixin<DiagonalSlot> createRenderObject(
52+
SlottedContainerRenderObjectMixin<DiagonalSlot, RenderBox> createRenderObject(
5353
BuildContext context,
5454
) {
5555
return RenderDiagonal(
@@ -60,7 +60,7 @@ class Diagonal extends RenderObjectWidget with SlottedMultiChildRenderObjectWidg
6060
@override
6161
void updateRenderObject(
6262
BuildContext context,
63-
SlottedContainerRenderObjectMixin<DiagonalSlot> renderObject,
63+
SlottedContainerRenderObjectMixin<DiagonalSlot, RenderBox> renderObject,
6464
) {
6565
(renderObject as RenderDiagonal).backgroundColor = backgroundColor;
6666
}
@@ -70,7 +70,7 @@ class Diagonal extends RenderObjectWidget with SlottedMultiChildRenderObjectWidg
7070
/// [SlottedContainerRenderObjectMixin] by providing slots for two children that
7171
/// will be arranged diagonally.
7272
class RenderDiagonal extends RenderBox
73-
with SlottedContainerRenderObjectMixin<DiagonalSlot>, DebugOverflowIndicatorMixin {
73+
with SlottedContainerRenderObjectMixin<DiagonalSlot, RenderBox>, DebugOverflowIndicatorMixin {
7474
RenderDiagonal({Color? backgroundColor}) : _backgroundColor = backgroundColor;
7575

7676
// Getters and setters to configure the [RenderObject] with the configuration

packages/flutter/lib/src/material/chip.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ class _RenderChipRedirectingHitDetection extends RenderConstrainedBox {
13421342
}
13431343
}
13441344

1345-
class _ChipRenderWidget extends RenderObjectWidget with SlottedMultiChildRenderObjectWidgetMixin<_ChipSlot> {
1345+
class _ChipRenderWidget extends SlottedMultiChildRenderObjectWidget<_ChipSlot, RenderBox> {
13461346
const _ChipRenderWidget({
13471347
required this.theme,
13481348
this.value,
@@ -1393,7 +1393,7 @@ class _ChipRenderWidget extends RenderObjectWidget with SlottedMultiChildRenderO
13931393
}
13941394

13951395
@override
1396-
SlottedContainerRenderObjectMixin<_ChipSlot> createRenderObject(BuildContext context) {
1396+
SlottedContainerRenderObjectMixin<_ChipSlot, RenderBox> createRenderObject(BuildContext context) {
13971397
return _RenderChip(
13981398
theme: theme,
13991399
textDirection: Directionality.of(context),
@@ -1478,7 +1478,7 @@ class _ChipRenderTheme {
14781478
);
14791479
}
14801480

1481-
class _RenderChip extends RenderBox with SlottedContainerRenderObjectMixin<_ChipSlot> {
1481+
class _RenderChip extends RenderBox with SlottedContainerRenderObjectMixin<_ChipSlot, RenderBox> {
14821482
_RenderChip({
14831483
required _ChipRenderTheme theme,
14841484
required TextDirection textDirection,

packages/flutter/lib/src/material/input_decorator.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ class _RenderDecorationLayout {
693693
}
694694

695695
// The workhorse: layout and paint a _Decorator widget's _Decoration.
696-
class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin<_DecorationSlot> {
696+
class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin<_DecorationSlot, RenderBox> {
697697
_RenderDecoration({
698698
required _Decoration decoration,
699699
required TextDirection textDirection,
@@ -1637,7 +1637,7 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin
16371637
}
16381638
}
16391639

1640-
class _Decorator extends RenderObjectWidget with SlottedMultiChildRenderObjectWidgetMixin<_DecorationSlot> {
1640+
class _Decorator extends SlottedMultiChildRenderObjectWidget<_DecorationSlot, RenderBox> {
16411641
const _Decorator({
16421642
required this.textAlignVertical,
16431643
required this.decoration,

packages/flutter/lib/src/material/list_tile.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ enum _ListTileSlot {
967967
trailing,
968968
}
969969

970-
class _ListTile extends RenderObjectWidget with SlottedMultiChildRenderObjectWidgetMixin<_ListTileSlot> {
970+
class _ListTile extends SlottedMultiChildRenderObjectWidget<_ListTileSlot, RenderBox> {
971971
const _ListTile({
972972
this.leading,
973973
required this.title,
@@ -1049,7 +1049,7 @@ class _ListTile extends RenderObjectWidget with SlottedMultiChildRenderObjectWid
10491049
}
10501050
}
10511051

1052-
class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ListTileSlot> {
1052+
class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ListTileSlot, RenderBox> {
10531053
_RenderListTile({
10541054
required bool isDense,
10551055
required VisualDensity visualDensity,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,7 +1760,7 @@ abstract class InheritedWidget extends ProxyWidget {
17601760
///
17611761
/// * [MultiChildRenderObjectWidget], which configures a [RenderObject] with
17621762
/// a single list of children.
1763-
/// * [SlottedMultiChildRenderObjectWidgetMixin], which configures a
1763+
/// * [SlottedMultiChildRenderObjectWidget], which configures a
17641764
/// [RenderObject] that organizes its children in different named slots.
17651765
abstract class RenderObjectWidget extends Widget {
17661766
/// Abstract const constructor. This constructor enables subclasses to provide
@@ -1854,7 +1854,7 @@ abstract class SingleChildRenderObjectWidget extends RenderObjectWidget {
18541854
/// * [Stack], which uses [MultiChildRenderObjectWidget].
18551855
/// * [RenderStack], for an example implementation of the associated render
18561856
/// object.
1857-
/// * [SlottedMultiChildRenderObjectWidgetMixin], which configures a
1857+
/// * [SlottedMultiChildRenderObjectWidget], which configures a
18581858
/// [RenderObject] that instead of having a single list of children organizes
18591859
/// its children in named slots.
18601860
abstract class MultiChildRenderObjectWidget extends RenderObjectWidget {

0 commit comments

Comments
 (0)