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...
This commit is contained in:
Ian Hickson
2023-05-16 15:28:54 -07:00
committed by GitHub
parent 5235a0f092
commit 027bb84444
7 changed files with 100 additions and 75 deletions

View File

@@ -5,7 +5,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
/// Flutter code sample for [SlottedMultiChildRenderObjectWidgetMixin].
/// Flutter code sample for [SlottedMultiChildRenderObjectWidget].
/// Slots used for the children of [Diagonal] and [RenderDiagonal].
enum DiagonalSlot {
@@ -14,9 +14,9 @@ enum DiagonalSlot {
}
/// A widget that demonstrates the usage of
/// [SlottedMultiChildRenderObjectWidgetMixin] by providing slots for two
/// [SlottedMultiChildRenderObjectWidget] by providing slots for two
/// children that will be arranged diagonally.
class Diagonal extends RenderObjectWidget with SlottedMultiChildRenderObjectWidgetMixin<DiagonalSlot> {
class Diagonal extends SlottedMultiChildRenderObjectWidget<DiagonalSlot, RenderBox> {
const Diagonal({
super.key,
this.topLeft,
@@ -49,7 +49,7 @@ class Diagonal extends RenderObjectWidget with SlottedMultiChildRenderObjectWidg
// [SlottedRenderObjectElement.update].
@override
SlottedContainerRenderObjectMixin<DiagonalSlot> createRenderObject(
SlottedContainerRenderObjectMixin<DiagonalSlot, RenderBox> createRenderObject(
BuildContext context,
) {
return RenderDiagonal(
@@ -60,7 +60,7 @@ class Diagonal extends RenderObjectWidget with SlottedMultiChildRenderObjectWidg
@override
void updateRenderObject(
BuildContext context,
SlottedContainerRenderObjectMixin<DiagonalSlot> renderObject,
SlottedContainerRenderObjectMixin<DiagonalSlot, RenderBox> renderObject,
) {
(renderObject as RenderDiagonal).backgroundColor = backgroundColor;
}
@@ -70,7 +70,7 @@ class Diagonal extends RenderObjectWidget with SlottedMultiChildRenderObjectWidg
/// [SlottedContainerRenderObjectMixin] by providing slots for two children that
/// will be arranged diagonally.
class RenderDiagonal extends RenderBox
with SlottedContainerRenderObjectMixin<DiagonalSlot>, DebugOverflowIndicatorMixin {
with SlottedContainerRenderObjectMixin<DiagonalSlot, RenderBox>, DebugOverflowIndicatorMixin {
RenderDiagonal({Color? backgroundColor}) : _backgroundColor = backgroundColor;
// Getters and setters to configure the [RenderObject] with the configuration