Mobile Tech
1.19K subscribers
103 photos
10 videos
6 files
144 links
Michael Lazebny's blog about @dart and @flutter
lazebny.io
Download Telegram
Enhancing Image Rendering Efficiency

Handling large images often leads to excessive consumption of device memory. To tackle this issue, DevTools offers valuable insights into identifying images that are too large.

To optimize, consider setting 'cacheWidth' or 'cacheHeight' properties on your images. This approach decodes and stores images in memory at a designated size.

There is also a ResizeImage class in the SDK that can be used to resize the image.

See how the GSkinner team utilized AppImage in the Wonderous project, offering a real-world example of these techniques in action - https://buff.ly/46sE71y

#FlutterDev #Flutter #Performance
πŸ‘9
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
Avoid these dart libraries. Briefly about their drawbacks and better alternatives.
https://lazebny.io/avoid-these-dart-libraries/

#flutter #flutterdev #dart
πŸ‘15πŸ”₯6πŸ€”4πŸ‘2πŸ‘Œ1πŸ’―1
This media is not supported in your browser
VIEW IN TELEGRAM
Created a minimal example of custom AppBars using SliverPersistentHeaderDelegate.Take a look here https://github.com/hawkkiller/pageheader/blob/main/lib/page_header.dart

#flutter #flutterdev
πŸ‘13❀‍πŸ”₯2πŸ”₯2
When updating dependencies in a Pub Workspace, use "dart pub upgrade," which automatically resolves to the correct version and updates it in every package.

#flutter #FlutterDev #dart #tip
πŸ‘6
This media is not supported in your browser
VIEW IN TELEGRAM
I created a Shimmer animation in Flutter in 100 lines without libraries.

It is performant and minimizes rebuilds, based on a CustomPaint, a LinearGradient, and a Transform.

https://gist.github.com/hawkkiller/2ed40b43d6372fc322080e0c8ce76521

#dart #flutter #flutterdev
πŸ‘20
Don't use SVGs for Icons in Flutter. There are better and more performant ways.

Rendering SVG requires several time-consuming operations: reading from memory, parsing the SVG to a binary format, parsing the binary format to Dart structures, and only then rendering.

Instead, opt for icon fonts, similar to the Icons class in Flutter. A Flutter engine processes all the fonts during startup and makes them available throughout the whole app lifecycle. The performance of rendering an icon font is the same as rendering text.

#dart #flutter #flutterdev
πŸ‘6πŸ”₯3🌚1
Mobile Tech
Don't use SVGs for Icons in Flutter. There are better and more performant ways. Rendering SVG requires several time-consuming operations: reading from memory, parsing the SVG to a binary format, parsing the binary format to Dart structures, and only then…
I have created SVG vs Iconfont Performance Benchmark

It tracks the rasterization, which is the process of rendering UI objects as pixels on the screen.

The icon font is much better on the GPU thread. SVG's complexity leads to expensive rasterization, which easily overwhelms the GPU and causes stutters.

You can check the full benchmark here https://github.com/hawkkiller/svg_iconfont_benchmark

Note that I tested on my MacBook, which is extremely performant. Testing on a low-end Android device may provide even more insights.

I also tried to add some readmes for better understanding.

#flutter #flutterdev
πŸ”₯9πŸ‘5
There is an easy way to speed up Flutter tests in CI.

If you have a large test suite, use sharding. It distributes the number of tests between multiple shards, so you can create multiple parallel jobs in CI.

#flutter #FlutterDev
πŸ‘8πŸ‘1
Do not hardcode paths to assets; use the path generator!

The generator ensures that assets exist and removes the possibility of a typo.
Explore what fits your needs, but I would recommend flutter_gen/spider.

#flutter #flutterdev
πŸ‘8❀4
It is better to wait before updating Flutter to the latest stable version.

After a new stable, there are usually multiple fixes published – 3.32 had 8 patches!

I recommend staying 1 stable version behind the latest release. This ensures that you won't be affected by regressions and new bugs.

#flutter #flutterdev
πŸ‘15
Is your layout ready for RTL languages?

A common mistake is using a fixed left/right EdgeInsets or Alignment.

Instead, use their directional counterparts. They provide logical start and end properties, allowing the UI to adapt automatically.

#flutter #flutterdev
πŸ‘11❀2