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
If you are using Dart 3.0 or later versions, do not forget to use the new list extensions when working with them.

What they are: nonNulls, firstOrNull, lastOrNull, singleOrNull, elementAtOrNull and indexed on Iterables.

It brings more functional code and no more index out-of-bounds issues when trying to access first, last, or finding elements.

#tip
6
If you are utilizing Bloc as a state management solution, it's crucial to avoid using multiple on statements in the constructor. Each on statement operates independently with its own queue and transformer without any specific order enforced. Doing so can lead to inconsistent states or race conditions.

Here are some tips for effectively handling events in Bloc:

- Try to use only one on event handler.
- Utilize pattern matching from freezed or sealed classes.
- Organize event handling using sequential transformer.
- Avoid using Cubit to handle complex state changes.

Clear explanation in comments...

#tip #bloc
3
What will be printed, and in what order, when you run this code?

#interview #question
Does didChangeDependencies trigger again when hot reloading a Stateful Widget in Flutter?
Anonymous Quiz
58%
yes
42%
no
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
Blocs and streams (emit.forEach)

Occasionally, we utilize blocs that observe a continuous flow of data. Typically, this flow originates from a repository within our domain layer, where it can be observed by several blocs. These blocs then leverage the data stream to inform their operational decisions based on business logic.

When dealing with streams in Bloc versions 7.2.0 and above, we can leverage the functionalities offered by the emit object to streamline our interaction with streams. The emit.forEach method enables us to receive a callback whenever there is data in the stream. Moreover, when our event handler is terminated or completes its task, it automatically handles the cleanup process by ending the stream subscription.

Here's an example illustrating how much emit.forEach method saves us from writing repetitive boilerplate code when utilizing stream in bloc.

#info #tip
4👍3
Will the variables m1 and m2 refer to the same memory location?

output:
228
228
true

#interview #question
Will the variables m1 and m2 refer to the same memory location?
Anonymous Quiz
58%
yes
42%
no
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
This media is not supported in your browser
VIEW IN TELEGRAM
Implemented this sticky/stretching/elastic icon button using CustomPainter in Flutter.

#widget #animation
🔥13🆒3
Should I publish the source code?
Anonymous Poll
94%
yeap
6%
nope