How to efficiently transform data using Codecs in Dart. Read in today's post :)
https://www.linkedin.com/feed/update/urn:li:activity:7130419429242224642/
https://www.linkedin.com/feed/update/urn:li:activity:7130419429242224642/
Linkedin
Michael Lazebny on LinkedIn: #dart #flutter #converter #json #utf8 #serialization
How to effectively serialize data in Dart & Flutter?
There is a very sophisticated way:
Dart has a built-in package called "dart:convert" that includesโฆ
There is a very sophisticated way:
Dart has a built-in package called "dart:convert" that includesโฆ
๐ฅ6
When to use InheritedModel in Flutter?
Inherited widgets are a powerful, natural way to propagate information down the tree in Flutter.
The crucial thing is that they are O(1). It means, that the time needed to obtain an inherited widget from the tree is equivalent to constant.
When InheritedWidget changes (i.e., some data is updated), dependent elements are notified via didChangeDependencies and eventually rebuilt.
However, when clients (modules that depend on a widget) are interested only in a certain part of its data things become a bit complicated as the inherited widget doesnโt support it.
In such a case, the Inherited Model comes to our help. Basically, they extend the functionality of InheritedWidget by adding an aspect field.
Clients declare the aspect theyโre interested in and are notified only if the data theyโre interested in changes!
Iโve enclosed an example of an inherited model used for settings. Basically, when the client is interested in the locale -> it will be notified if the locale changes.
There is also a widget called MediaQuery thatโs probably used by every #Flutter application. It also implements InheritedModel with its brightnessOf, sizeOf, and others.
LinkedIn
Inherited widgets are a powerful, natural way to propagate information down the tree in Flutter.
The crucial thing is that they are O(1). It means, that the time needed to obtain an inherited widget from the tree is equivalent to constant.
When InheritedWidget changes (i.e., some data is updated), dependent elements are notified via didChangeDependencies and eventually rebuilt.
However, when clients (modules that depend on a widget) are interested only in a certain part of its data things become a bit complicated as the inherited widget doesnโt support it.
In such a case, the Inherited Model comes to our help. Basically, they extend the functionality of InheritedWidget by adding an aspect field.
Clients declare the aspect theyโre interested in and are notified only if the data theyโre interested in changes!
Iโve enclosed an example of an inherited model used for settings. Basically, when the client is interested in the locale -> it will be notified if the locale changes.
There is also a widget called MediaQuery thatโs probably used by every #Flutter application. It also implements InheritedModel with its brightnessOf, sizeOf, and others.
Linkedin
When to use InheritedModel in Flutter? | Michael Lazebny
When to use InheritedModel in Flutter?
Inherited widgets are a powerful, natural way to propagate information down the tree in Flutter.
The crucial thing is that they are O(1). It means, that the time needed to obtain an inherited widget from the tree isโฆ
Inherited widgets are a powerful, natural way to propagate information down the tree in Flutter.
The crucial thing is that they are O(1). It means, that the time needed to obtain an inherited widget from the tree isโฆ
๐11
How does #Flutter draw a frame?
The process can be initiated by several sources - setState, render object, system, or engine.
When you call setState, it marks the element as dirty and asks the engine (C++) for a frame via FFI. Later, when the engine is ready, it calls the WidgetsBinding.drawFrame callback.
The drawFrame iterates through the element tree and rebuilds dirty elements. If dirty elements change their size, color, or orientation (generally something that render objects are interested in) - render objects are marked as dirty.
Then the framework performs layout and painting.
Finally, the scene (or frame) is built and sent to the painting engine.
The process can be initiated by several sources - setState, render object, system, or engine.
When you call setState, it marks the element as dirty and asks the engine (C++) for a frame via FFI. Later, when the engine is ready, it calls the WidgetsBinding.drawFrame callback.
The drawFrame iterates through the element tree and rebuilds dirty elements. If dirty elements change their size, color, or orientation (generally something that render objects are interested in) - render objects are marked as dirty.
Then the framework performs layout and painting.
Finally, the scene (or frame) is built and sent to the painting engine.
๐ฅ3๐2
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
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
Media is too big
VIEW IN TELEGRAM
Use extent to optimize scrolling
If all elements have the same length along their main axis, it is recommended to set the
#Flutter #Performance
If all elements have the same length along their main axis, it is recommended to set the
extent
or utilize prototypeItem
. This will prevent the scrolling engine from laying out these widgets.#Flutter #Performance
๐8๐ฅ4
formsf.png
648 KB
Implemented extremely simple forms for #Flutter that support asynchronous validators ๐
๐7๐ฅ4
A while ago compute function from flutter SDK has moved to dart.
Incredibly easy and efficient way to process something in a different thread.
https://youtu.be/PPwJ75vqP_s?si=bqjge122nwFCBkIw
Incredibly easy and efficient way to process something in a different thread.
https://youtu.be/PPwJ75vqP_s?si=bqjge122nwFCBkIw
YouTube
Isolates (Technique of the Week)
If your Flutter app has jank due to a heavy computation, use Isolate.run() to move that computation to a new isolate.
Isolate class โ https://goo.gle/3vvBKi4
Use isolates in your Flutter app โ https://goo.gle/43DiXxL
Article about Isolate.run โ httpsโฆ
Isolate class โ https://goo.gle/3vvBKi4
Use isolates in your Flutter app โ https://goo.gle/43DiXxL
Article about Isolate.run โ httpsโฆ
๐ฅ7๐6๐2
Screen Recording 2024-05-18 at 20.43.37.mov
3.3 MB
In the meantime, I have created a custom popup that positions follower widget relatively to a target and prevents it from overflowing the screen.
#flutter
Please open Telegram to view this post
VIEW IN TELEGRAM
๐ฅ11๐3
Avoid these dart libraries. Briefly about their drawbacks and better alternatives.
https://lazebny.io/avoid-these-dart-libraries/
#flutter #flutterdev #dart
https://lazebny.io/avoid-these-dart-libraries/
#flutter #flutterdev #dart
Michael Lazebny
Avoid These Dart Libraries
This article lists popular Dart and Flutter libraries that are not recommended, including Riverpod, Get, Get_it, Hive, and Stacked.
๐15๐ฅ6๐ค4๐2๐1๐ฏ1
Tomorrow, I'm launching a new article series on creating UI Kits.
Iโll guide you through developing various components like buttons, text fields, and more.
Youโll also learn about animations, transitions, iconography, responsive design tools, and best practices for layouts and custom components.
#article #uikit #flutter
Iโll guide you through developing various components like buttons, text fields, and more.
Youโll also learn about animations, transitions, iconography, responsive design tools, and best practices for layouts and custom components.
#article #uikit #flutter
7โค22๐7๐ฅ7
Navigation in Flutter
A bit of theory and my thoughts and tips on how the navigation should be implemented.
https://lazebny.io/navigation-in-flutter
#flutter #navigation
A bit of theory and my thoughts and tips on how the navigation should be implemented.
https://lazebny.io/navigation-in-flutter
#flutter #navigation
Michael Lazebny
Navigation in Flutter
Learn Flutter navigation with insights on Navigator, Router, and tips for seamless setup using go_router. Includes some theory and expert advice.
๐8๐ฅ3โค2
Learn how to build efficient sticky headers in Flutter using slivers for seamless scrolling. Includes code examples and best practices!
https://lazebny.io/sticky-headers
#flutter #article
https://lazebny.io/sticky-headers
#flutter #article
Michael Lazebny
Sticky headers in Flutter
Learn how to build efficient sticky headers in Flutter using slivers for seamless scrolling. Includes code examples and best practices!
๐9๐ฅ3
Modern Monorepo management in Dart and Flutter
https://lazebny.io/modern-monorepo-management
#dart #flutter #flutterdev
https://lazebny.io/modern-monorepo-management
#dart #flutter #flutterdev
Michael Lazebny
Modern Monorepo Management with Pub Workspaces and Melos in Dart
Efficiently manage Flutter/Dart monorepos using Pub Workspaces and Melos, with examples for dependency management and workflow automation.
๐6โ1โคโ๐ฅ1
Learn how scroll works in Flutter, the differences between scroll widgets, and how to build efficient layouts using slivers for best performance.
https://lazebny.io/flutter-slivers
#article #flutter #slivers
https://lazebny.io/flutter-slivers
#article #flutter #slivers
Michael Lazebny
Flutter Slivers: How Scrolling Works
Learn how scroll works in Flutter, the differences between scroll widgets, and how to build efficient layouts using slivers for best performance.
๐ฅ8โค2
I created a simple but much more powerful alternative to Widgetbook, Storybook, and similar tools.
It automatically generates routes for GoRouter (supports deep links).
It also makes it very easy to create configurations, fields, etc., for customizing widgets.
This is just an exampleโit will be improved over time and might eventually be added to sizzle starter or a separate package.
Github Link
#flutter
It automatically generates routes for GoRouter (supports deep links).
It also makes it very easy to create configurations, fields, etc., for customizing widgets.
This is just an exampleโit will be improved over time and might eventually be added to sizzle starter or a separate package.
Github Link
#flutter
๐11๐ฅฐ4๐ฅ3โค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
#flutter #flutterdev
๐13โคโ๐ฅ2๐ฅ2
If you want to make your VS Code indentation a bit more beautiful for #Flutter widgets, set "dart.previewFlutterUiGuides" to true
If I'm not mistaken, the same thing exists in IDEA :)
If I'm not mistaken, the same thing exists in IDEA :)
โค10๐4