Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MultiChildLayoutDelegate.hasChild doc #126433

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions examples/api/lib/widgets/basic/custom_multi_child_layout.0.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import 'package:flutter/material.dart';

/// Flutter code sample for [CustomMultiChildLayout].

void main() => runApp(const ExampleApp());
void main() => runApp(const CustomMultiChildLayoutApp());

class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
class CustomMultiChildLayoutApp extends StatelessWidget {
const CustomMultiChildLayoutApp({super.key});

@override
Widget build(BuildContext context) {
Expand All @@ -19,7 +19,7 @@ class ExampleApp extends StatelessWidget {
// see the layout change.
textDirection: TextDirection.ltr,
child: Scaffold(
body: ExampleWidget(),
body: CustomMultiChildLayoutExample(),
),
),
);
Expand Down Expand Up @@ -82,8 +82,8 @@ class _CascadeLayoutDelegate extends MultiChildLayoutDelegate {
}
}

class ExampleWidget extends StatelessWidget {
const ExampleWidget({super.key});
class CustomMultiChildLayoutExample extends StatelessWidget {
const CustomMultiChildLayoutExample({super.key});

static const Map<String, Color> _colors = <String, Color>{
'Red': Colors.red,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void main() {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: example.ExampleWidget(),
body: example.CustomMultiChildLayoutApp(),
),
),
);
Expand All @@ -24,7 +24,7 @@ void main() {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: example.ExampleWidget(),
body: example.CustomMultiChildLayoutExample(),
),
),
);
Expand All @@ -40,7 +40,7 @@ void main() {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: example.ExampleWidget(),
body: example.CustomMultiChildLayoutExample(),
),
),
);
Expand Down
8 changes: 5 additions & 3 deletions packages/flutter/lib/src/rendering/custom_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ abstract class MultiChildLayoutDelegate {

/// True if a non-null LayoutChild was provided for the specified id.
///
/// Call this from the [performLayout] or [getSize] methods to
/// determine which children are available, if the child list might
/// vary.
/// Call this from the [performLayout] method to determine which children
/// are available, if the child list might vary.
///
/// Avoid calling this from [getSize] as the child list is not available
/// until layout size is determined.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Avoid" is probably to weak here, this crashes if you call it from getSize, right? Maybe better:

"This method cannot be called from [getSize] as the size is not allowed to depend on the children" or something like that.

bool hasChild(Object childId) => _idToChild![childId] != null;

/// Ask the child to update its layout within the limits specified by
Expand Down