Mobile Tech
1.15K subscribers
92 photos
8 videos
6 files
138 links
Michael Lazebny's blog about @dart and @flutter
lazebny.io
Download Telegram
How do I unload an event loop in Dart? It is quite a common situation for us to have APIs like Future<List<T>>.

Imagine a method that returns a list of users. What you do there is parse the json into a dart list and then somehow convert it into a typed list of models. This conversion to models can be done lazily. Just change the API to Stream<T> and you will get the idea. You can put all the elements in the event loop to process them asynchronously.

Here is the link to the working flutter app, which gives you an example of how to do this:
https://gist.github.com/hawkkiller/932140079adfdcab2cfdd4b0292bb50a

#dart #flutter #async #eventloop #tip‍‍‍
πŸ‘2
How to work with Clipboard in flutter?

There is a class Clipboard for these purposes in flutter:services.

It has two simple methods: setData and getData.

#tip #flutter #clipboard
πŸ‘9
An iterator-like interface for stream values.

Allows more elegant and flexible solutions than default "for"

https://api.flutter.dev/flutter/dart-async/StreamIterator-class.html

#tip #dart #stream
πŸ‘4
The Double-Edged Sword of Perfectionism

Perfectionism is a trait that is often revered in our society, a kind of gold standard that many aspire to. But like the sheen of real gold, this trait has its allure and its pitfalls. It embodies the relentless pursuit of perfection, always shadowed by an inner critic and an innate fear of making mistakes. While it may seem like a noble quest, the relentless pursuit of perfection can weave a web of complications, both psychological and practical.

The Hidden Challenges of Perfectionism

At its core, perfectionism isn't just about producing flawless work. It's a mindset that can lead to a host of mental health issues. Numerous studies have linked perfectionism to depression, anxiety, and eating disorders. The reason is simple: when you constantly strive for an unattainable ideal, the frequent perceived failures can undermine your mental well-being.

Moreover, the fear of failing to live up to one's own high standards often spawns a twin demon: procrastination. The overwhelming weight of potential failure, or even the sheer magnitude of the effort required to achieve "perfection," can paralyze even the most passionate individuals, preventing them from initiating projects.

This inflexibility extends to other areas of life as well. For a perfectionist, deviations from the plan, whether in daily life or in larger projects, can cause disproportionate stress. Their world often operates in binaries of success or failure, with little room for the vast shades of gray in between.

In addition, relationships, both personal and professional, can bear the brunt of perfectionist tendencies. While perfectionists are incredibly hard on themselves, they may inadvertently project these high expectations onto others, causing tension and misunderstanding.

Read more in my new article here: https://lazebny.io/perfectionism/

#perfectionism #productivity #selfgrowth #philosophy #tip
πŸ‘2πŸ”₯2
Install dev dependencies with ease!

#tip
πŸ‘9πŸ†1
Five Questions for Middle Flutter Developer

How will you adapt UI to large/small screens?

Ephemeral vs app state.

How do you implement state management?

Tell about β€œConstraints go down, sizes go up”.

How will you communicate with Native platforms?

#flutter #tip
πŸ‘13
Enhance Your Flutter Apps with Autofill!

Autofill significantly boosts your app's user experience by allowing users to effortlessly complete forms (like credit card details, addresses, and login credentials).

To integrate autofill in Flutter, encase your input fields within an AutofillGroup widget. Then set up autofillHints in textfields.

For a seamless connection between your website and app, remember to configure associated domains for both Android and iOS platforms.

#flutterdev #tip
πŸ‘15❀3
User or Profile?

User and profile concepts are closely related yet serve distinct purposes.

In essence, a user refers to an account or identity used for accessing system resources, typically including attributes such as a username, password, email address, and role.

Conversely, a profile represents more detailed personal information and preferences associated with the user, which might include their first name, last name, age, and other settings specific to how they interact with the system.

#tip
πŸ‘13😁1😐1
#tip

If you're using SharedPreferences (or any other key-value storage) consider creating a separate class that manages the entry.

This way, you ensure that the key is the same during setting and reading as well as simply convenient and powerful as you may create custom codecs and support complex types.

See source code here
❀19πŸ”₯7πŸ’―4
If you need to create instances of your objects, use Factory Pattern.

Extremely clean and scalable solution.

#tip
πŸ‘10πŸ₯΄7❀3πŸ‘Ž1