What is the late keyword in Dart?

Why Interviewers Ask This

This is a classic screening question for Flutter roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.

Answer

The late keyword is a modifier for non-nullable variables that are initialized after their declaration, not at the point of declaration. It tells the Dart compiler "I promise this will be set before it is used — trust me." If you access a late variable before it is initialized, a LateInitializationError is thrown at runtime. It is commonly used for controllers in StatefulWidgets: late TextEditingController _controller; initialized in initState().

Pro Tip

If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.