Skip to content

Stateless Widget template has warnings #3347

Closed
@eseidel

Description

@eseidel

Describe the bug
A clear and concise description of what the bug is.

If you use the stateless widget template (which I think comes from Dart-Code?) it now ends up with warnings as of the latest Flutter default template?

image

To Reproduce

  1. flutter create to start a new empty project.
  2. Type 'stls' and let it autocomplete to the stateless widget template.

Expected behavior
Should not have any analyzer warnings.

First it gives you a warning about missing "key" parameter in constructor:
"Use key in widget constructors."

image

Then, once you fix that, then it gives you a new warning:

image
"Prefer declaring const constructors on @immutable classes."

Versions (please complete the following information):

[√] Flutter (Channel master, 2.3.0-2.0.pre.237, on Microsoft Windows [Version 10.0.19041.928], locale en-US)
    • Flutter version 2.3.0-2.0.pre.237 at C:\Users\micro\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c71e8bacfd (76 minutes ago), 2021-05-16 17:44:01 -0400
    • Engine revision 0c9ffcc623
    • Dart version 2.14.0 (build 2.14.0-edge.a527411e5100a0a4f48c4009087a1b988aa784af)

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.4)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.9.31205.134
    • Windows 10 SDK version 10.0.19041.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions