Skip to content

write your first app Part1. const keyword are disappearing between subparts 3 and 4 #3612

Description

@ngouy

Here https://codelabs.developers.google.com/codelabs/first-flutter-app-pt1/#2

We are told to copy-paste some code into our main.dart including :

        appBar: AppBar(
          title: const Text('Welcome to Flutter'),
        ),
        body: const Center(
          child: const Text('Hello World'),
        ),

On the next page, we are asking to paste new lines and update some others, but on line we don't have to touch, the const kw is disappearing from appBar title and body
https://codelabs.developers.google.com/codelabs/first-flutter-app-pt1/#3

our old pice of code became :

        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          //child: Text('Hello World'),   // Replace this text...
          child: Text(wordPair.asPascalCase),  // With this text.
        ),

As a noob in Dart, I was a bit lost because I manually updated my code as following :

   final wordPair = WordPair.random();
   //...
   child: const Text('Hello World'),        // from
   child: const Text(wordPair.asPascalCase) // to

and it's not working (for some reason I don't yet understand precisely but can guess, as wordPair is holding a "final" variable)

We have to remove both const from body and child, yet it's not indicated (at least for the body) nor explained, + it's also removed from appBar.title

Metadata

Metadata

Assignees

No one assigned

    Labels

    a.tut.codelab-googleRelates to codelabs hosted on codelabs.developers.google.comp1-highMajor but not urgent concern: Resolve in months. Update each month.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions