Câu hỏi phỏng vấn Flutter
Câu hỏi

What does non-nullable ...

Câu trả lời

In Dart, when you opt into null safety, types are non-nullable by default, meaning that values can't be null unless you explicitly say they can be[1][3]. This design principle was chosen after research found that non-null was by far the most common choice in APIs[3].

Some key points about non-nullable by default in Dart:

  • Unless you add a ? after a type to make it nullable, variables are considered non-nullable[1][3]. For example, int is non-nullable, while int? is nullable.

  • Non-nullable variables must be initialized with a non-null value before they can be used[3]. The Dart analyzer enforces this.

  • Assigning null to a non-nullable variable results in a compile-time error[3]. This prevents null dereference errors at runtime.

  • The default for parameters, return types, fields, a...

senior

senior

Gợi ý câu hỏi phỏng vấn

middle

Explain the different types of Streams?

expert

What are StatefulWidget and State Separate Classes?

senior

Why is exit(0) not preferred for closing an app?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào