Dart&Flutter with mizu
224 subscribers
22 photos
9 videos
20 links
Download Telegram
Here is the code:

• Interactive blob that stretches, rotates, and scales with gestures.
• Customizable behavior for elastic scaling and distance.
• Built using CustomPainter and ClipPath.

https://github.com/meeziest/elastic_blob/tree/main

#github #code
🔥8
I’ve noticed that many devs believe they can only deconstruct object classes and records starting from Dart 3. However, Dart’s pattern matching you can also deconstruct nested maps and lists.
Map patterns match values that implement Map, and then recursively match its subpatterns against the map's keys to destructure them

A list pattern matches values that implement List, and then recursively matches its subpatterns against the list's elements to destructure them by position

This destructuring also works with complex nested data. For example, if your map contains other maps or complex data structures, you can easily unpack them.

Don’t forget to utilize this when needed to make your code more elegant.

#tip
5😍4👍2
Media is too big
VIEW IN TELEGRAM
Recently, I decided to set myself a challenge: creating an animated solar system explorer. The app isn’t quite finished yet, but here is the progress.

In this project, I’m working on simulating planetary orbits, experimenting with animations, and refining proper zooming options with perspective transformations.
🔥20🤯3
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
Dart&Flutter with mizu
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…
To avoid this issue - It’s better to avoid directly capturing context in the closure. Instead, you can use values that are safe for long-term storage.

In the solution provided above, capturing a long-lived object like ModalRoute is safe. ModalRoute is retrieved once and stored in a variable, which is then used inside the closure. Now, the handler closure no longer contains a reference to context, preventing a potential memory leak.
I recently came across an interesting post about animation in Flutter – the RGB Split Distortion effect! This technique creates a mesmerizing distortion with an interactive visual flair that’s instantly eye-catching. The author used GLSL fragment shaders along with Flutter’s CustomPainter.

🤫 Link to the article: The Magical RGB Split Distortion Effect in Flutter
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥5
When importing icons into your Flutter app, it’s essential to consider visual alignment and icon's optical weight, not just technical centering. Icons are usually centered within their rectangular bounding box by default, but this often doesn’t look visually balanced within buttons.

Image 1: Default Centering
In this example, the icon is centered based on its bounding box. This is technically accurate, but it doesn’t look visually balanced. The triangle appears slightly off, creating a sense of imbalance within the button.

Image 2: Adjusted for Visual Balance
Here, we’ve adjusted the triangle’s position slightly to the right. This small offset makes the icon look more balanced within the circle, creating a better visual effect.

#ui
👍43
Dart&Flutter with mizu
When importing icons into your Flutter app, it’s essential to consider visual alignment and icon's optical weight, not just technical centering. Icons are usually centered within their rectangular bounding box by default, but this often doesn’t look visually…
How to align icon with optical weight within a button?

For example: A simple shape with symmetry, like a triangle for a “Play” button, is usually centered within a circle by designers. To achieve a balanced look, they align the circle itself according to the outer boundaries of its container. This careful positioning ensures the icon feels balanced within the button.

As a Flutter developer we can export the icon with correct positioning applied beforehand by designers. However, if the icon doesn’t have the proper positioning, we can use Padding widget or if you need more precise control over a complex shape icons, you can use Transform.translate. Adjusting the position by a few pixels can often make the button feel more balanced, even if it’s technically off-center.

This is called optical balance and takes into account the icon's optical weight within the button.

#ui
👍7🔥1
I really enjoyed this talk from apple on animating with springs! Especially the math part.

Animate with springs

In Flutter we have simular api which applies physics simulation to our widgets -> link
💯5
Stunning effect that uses hundreds of colorful particles that respond dynamically to touch, forming interactive experience.

https://x.com/philipcdavis/status/1562092691558735873

While this is iOS, animations like this can inspire developers across platforms. For Flutter devs, recreating something similar is totally doable with CustomPainter and animations. Imagine adding this to your next project 😳

Btw, i have seen simular animation before with many particles but in Flutter written by PlugFox. Check out this Sunflower pattern -> https://dartpad.dev/?sample=sunflower
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥3👍1
Just a heads up that I’ll soon be posting a Flutter version of this water wavy progress bar animation. Stay tuned if you’re interested in learning how to replicate this effect in your Flutter apps. I’ll share all the details with you soon! 😎
Please open Telegram to view this post
VIEW IN TELEGRAM
🐳10
This media is not supported in your browser
VIEW IN TELEGRAM
Here’s a quick preview of how it looks:

#widget #animation
🔥10🙏2
I just hit 💯 subscribers! Thank you for your support and interest. There’s plenty more to come, so stick around for more tutorials, deep-dives, and creative projects in Flutter!
Please open Telegram to view this post
VIEW IN TELEGRAM
💯12
Dart&Flutter with mizu
For more details-including the math, code and reasoning behind this effect, check out my Medium article: Complex Animations in Flutter: Creating a Dynamic Circular Water-Ripple Progress Bar #medium
💡 Tips: CustomPaint actually has two painting parameters: painter is the background painter, and foregroundPainter is the foreground painter. When you set the child property, the drawing content will be rendered either beneath or above the child widget, depending on the painter used.

painter: Content drawn here appears beneath the child widget.
foregroundPainter: Content drawn here appears above the child widget.
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥5
Dart&Flutter with mizu
Here’s a quick preview of how it looks: #widget #animation
This media is not supported in your browser
VIEW IN TELEGRAM
Btw while writing this demo, I encountered unexpected repainting with multiple CustomPainters 🤨. On the same page, there are multiple CustomPaint widgets, and the repainting of one of them (triggered by the paint() method of its CustomPainter instance) causes another widget to repaint.

If you face simular behavior you can temporarily solve this by wrapping the RepaintBoundary widget around to isolate the repainting area.

video example -> https://dartpad.dev/?id=7645ea5154a4bb24b5254f284cdbfb90
Please open Telegram to view this post
VIEW IN TELEGRAM
🤨5😁2