Dart&Flutter with mizu
224 subscribers
22 photos
9 videos
20 links
Download Telegram
What will be printed first, after the widget is created in this Flutter application?

#interview #question
🥰4
Could you identify any potential issues or best practices that are not followed in this Flutter code snippet, particularly regarding the lifecycle methods and the management of a custom listener object?

#interview #question
🥰2🔥1😍1
What will be printed, and in what order, when you run this code?

#interview #question
How many times will "Hello World!" be printed in the didChangeDependencies method if the inherited widget's message changes 5 times?

don't count first build phase

#interview #question
👍3
Will the variables m1 and m2 refer to the same memory location?

output:
228
228
true

#interview #question
Why does Dart Type Promotion work with variables but not Object properties?

In Dart, type promotion works with variables because the compiler can guarantee that the type check condition holds for the duration of the variable's scope. However, for object properties, the compiler cannot ensure that the property value remains unchanged by other code after the type check. This inability to guarantee immutability or consistent state prevents type promotion for object properties.

#interview #question
👍5
Could you identify any potential issues?

#interview #question
Dart&Flutter with mizu
Could you identify any potential issues? #interview #question
The problem is in Closures. Closures can unintentionally capture references to short-lived object (such as a BuildContext). In that case, it prevents the garbage collector from reclaiming that memory as long as the closure exists.

Capturing a BuildContext would prevent the context from being garbage collected, potentially leading to a memory leak if the closure outlives the widget's lifecycle.

Now, the next question is - How to prevent BuildContext not being garbage collected, without breaking the logic of printPrevRouteName?

#interview #question