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

senior

What are the similarities and differences of Future and Stream?

middle

How do you check if an async void method is completed in Dart?

middle

Differentiate StatelessWidget and StatefulWidget ?

Bình luận

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

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