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
This media is not supported in your browser
VIEW IN TELEGRAM
๐Ÿ”ฅ UIKit in-progress

Will be incredibly useful article.
Please open Telegram to view this post
VIEW IN TELEGRAM
1๐Ÿ”ฅ22๐Ÿฅฐ2
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
7โค22๐Ÿ‘7๐Ÿ”ฅ7
Creating the Perfect UI Kit in Flutter, Part One! Theme, typography, buttons, text fields and more in this comprehensive article:

https://lazebny.io/creating-ui-kit-in-flutter-1
51โค9๐Ÿ”ฅ3๐Ÿ‘2
#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
How to implement design breakpoints correctly:

Define a class that contains breakpoints for your app, usually it contains 2-3 values:


enum WindowSize {
compact._(0, 600),
medium._(600, 839),
expanded._(840, 1199),
large._(1200, 1599),
extraLarge._(1600, double.infinity);

/// The minimum width of the breakpoint.
final double min;

/// The maximum width of the breakpoint.
final double max;

const WindowSize._(this.min, this.max);
}


Define a scope that provides this WindowSize down the context:


/// Scope that provides [WindowSize] to its descendants.
class WindowSizeScope extends StatefulWidget {
/// Creates a [WindowSizeScope] that provides [WindowSize] to its descendants.
const WindowSizeScope({
required this.child,
super.key,
});

/// The widget below this widget in the tree.
final Widget child;

/// Returns the [WindowSize] of the nearest [WindowSizeScope] ancestor.
static WindowSize of(BuildContext context, {bool listen = true}) {
final inherited = listen
? context.dependOnInheritedWidgetOfExactType<_InheritedWindowSize>()
: context.findAncestorWidgetOfExactType<_InheritedWindowSize>();

return inherited?.windowSize ??
(throw FlutterError('WindowSizeScope was not found in the widget tree'));
}

@override
State<WindowSizeScope> createState() => _WindowSizeScopeState();
}

class _WindowSizeScopeState extends State<WindowSizeScope> with WidgetsBindingObserver {
late WindowSize _windowSize;

Size _getScreenSize() {
final view = PlatformDispatcher.instance.views.first;
return view.physicalSize / view.devicePixelRatio;
}

@override
void initState() {
_windowSize = WindowSize.fromWidth(_getScreenSize().width);
WidgetsBinding.instance.addObserver(this);
super.initState();
}

@override
void didChangeMetrics() {
final windowSize = WindowSize.fromWidth(_getScreenSize().width);

if (_windowSize != windowSize) {
setState(() => _windowSize = windowSize);
}
super.didChangeMetrics();
}

@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}

@override
Widget build(BuildContext context) => _InheritedWindowSize(
windowSize: _windowSize,
child: widget.child,
);
}


Then get this value from the BuildContext and do whatever you want:


final windowSize = WindowSize.of(context);

if (windowSize.isExpanded) return ExpandedWidget();

if (windowSize.isMedium) return MediumWidget();


Here are the sources
7๐Ÿ”ฅ13โคโ€๐Ÿ”ฅ5๐Ÿ‘4๐Ÿ‘1
Let's talk about dependency injection (DI) in the next article?

๐Ÿ‘ / ๐Ÿ‘Ž
๐Ÿ‘91โค3๐Ÿ”ฅ3๐Ÿ’ฏ1
Forwarded from Oh, my Flutter [ENG] (Theodor)
A very cool presentation by Vyacheslav Egorov about the inner workings of Dart.

Using the example of two for-loops, he explains and demonstrates how to determine when the compiler generates suboptimal code and how to deal with it.

Additionally, the speaker showcases how to achieve Hot Reload by integrating Dart with SwiftUI and Jetpack Compose through FFI.

Highly recommended for viewing.

๐Ÿ“Œ Presentation

#video
#ohmyteam
#ohmyfedukenukem
โค5
This media is not supported in your browser
VIEW IN TELEGRAM
๐ŸคŸ We've recently developed a simple plugin for Flutter that allows you to create custom wraps for the widgets you want!

Grab it here
1๐Ÿ”ฅ13๐Ÿ‘5โค3
If you need to create instances of your objects, use Factory Pattern.

Extremely clean and scalable solution.

#tip
๐Ÿ‘10๐Ÿฅด7โค3๐Ÿ‘Ž1
Article about dependency injection comes tomorrow! ๐Ÿ’ช
Please open Telegram to view this post
VIEW IN TELEGRAM
1๐Ÿ‘13๐Ÿ”ฅ13โค3
Great news! I have launched boosty, so if you had problems with payments, you can now try this method.

https://boosty.to/mlazebny
๐Ÿ‘8โค3๐Ÿ”ฅ3โคโ€๐Ÿ”ฅ1
Mobile Tech
Next Article Topic
So, next article will be about state management and business logic! ๐Ÿ˜Ž
Please open Telegram to view this post
VIEW IN TELEGRAM
๐Ÿ‘19๐Ÿ”ฅ3
๐Ÿ˜Ž Exciting news! Audo, the #AI Career Assistant I've been pouring my heart into, has just gone live.

I'd love it if you could check it out, give it a try and consider showing your support with an upvote. Your feedback would mean the world to us!

https://www.producthunt.com/posts/audo
Please open Telegram to view this post
VIEW IN TELEGRAM
๐Ÿ‘6โค3
Coming tomorrow
๐Ÿ‘9๐Ÿ”ฅ4โค3