Skip to content

Allow null String for Text widget #40459

Closed

Description

@ScottPierce

Text shouldn't throw an error if I give it a null String. It should handle that gracefully and display the same as if I gave it an empty String. Otherwise, you create more work for me, processing null Strings to empty Strings, and from what I've found so far, Dart is bad at things like that compared to Kotlin.

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: proposalA detailed proposal for a change to Flutter
    on Sep 13, 2019
  2. sma commented on Sep 13, 2019

    @sma

    You can use Text(variable ?? "") which is the same with Swift and Kotlin, I think. And once Dart NNBD support lands, you will hopefully catch most of not all "optional type" problems at compile time.

  3. changed the title [-]Allow null text for `Text` widget[/-] [+]Allow null `String` for `Text` widget[/+] on Sep 14, 2019
  4. ScottPierce commented on Sep 14, 2019

    @ScottPierce
    Author

    I didn't know about the ?? operator. Thank you. That's far more convenient than what I've been doing.

  5. github-actions commented on Aug 28, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  6. locked as resolved and limited conversation to collaborators on Aug 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions