Non-nullable instance field '_Description' must be initialized

Asked

Viewed 388 times

3

"Non-nullable instance field '_Description' must be initialized."

As of version 2.12.0, Flutter always displays messages like this, how to solve this problem without downloading the version?

Researching, I saw that could put the "?" next to the guy:

String? _Description;

But I don’t really understand what it does and at the same time it generates other mistakes in my project

Briefly, such as declaring null objects on Dart without being required to pass value.

  • 1

    When you put the ?, you are saying that this object can be null, therefore, to access it in another part of the code, you need to verify whether that object is null or not. Surely, these other errors you are seeing are why, you are trying to access an object that can be null without any verification. You can solve quickly by putting ! in front of the object, for example: print(_Descricao!.toLowerCase())... if _Description is null, will give error. For n give error, you can use the ??, thus: print(_Descricao ?? 'descricao nula!')

  • The error in the title, _description nay is marked as null, meaning you has that initialize it, because it will never be null. They should not have closed their question... stack br closes the question and.e.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.