Skip to content

Issue in Flutter Tutorial -ListenableBuilder #13067

@SharkJ

Description

@SharkJ

Steps to reproduce

In the ListenableBuilder tutorial, the final ArticlePage class references nextArticleCallback, which is not defined. The earlier code defines onPressed, so this causes a compile error.

Additionally, wrapping ArticleWidget in Flexible inside SingleChildScrollView results in an unbounded constraints error. Removing Flexible resolves the issue.
(See the attached image.)

Expected results

The tutorial code should compile successfully when copied exactly as shown.

Actual results

Error: The getter 'nextArticleCallback' isn't defined for the type 'ArticlePage'.
RenderFlex children have non-zero flex but incoming height constraints are unbounded.

Code sample

Code sample
class ArticlePage extends StatelessWidget {
  const ArticlePage({
    super.key,
    required this.summary,
    required this.onPressed,
  });

  final Summary summary;
  final VoidCallback onPressed;

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Column(
        children: [
          Flexible(
            child: ArticleWidget(
              summary: summary,
            ),
          ),
          ElevatedButton(
            onPressed: nextArticleCallback,
            child: Text('Next random article'),
          ),
        ],
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration Image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Not applicable.

Metadata

Metadata

Assignees

Labels

a.tut.tutorialRelates to the Tutorial section of docs.flutter.deve0-minutesEffort: < 60 minp2-mediumNecessary but not urgent concern. Resolve when possible.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions