tezvyn:

📱Mobile Dev

Mobile app development across platforms

1323 bites

More in Mobile Dev — page 59

Flutter & Dart2 min read

Why hashCode and operator== Must Be Overridden Together

Overriding `==` without `hashCode` breaks collections like `Set` and `Map`. If two objects are equal, they MUST have the same hash code. This is vital for custom classes used as map keys or set elements.

Flutter & Dart2 min read

Dart: Abstract Classes & Implicit Interfaces

An abstract class is a blueprint that other classes must follow, but it can't be instantiated itself. Dart also lets any class act as an 'implicit interface,' forcing other classes to implement its public API without inheritance.

Flutter & Dart2 min read

Dart's Specialized Constructors: Named, Factory, and Constant

Dart constructors offer more than one way to create an object. Use named constructors for clarity (e.g., fromJSON), factory for caching or returning subtypes, and const for compile-time constant objects.

Flutter & Dart2 min read

Dart's Lazy Iterable Methods: map() and where()

Think of `map()` or `where()` not as instant transformations, but as recipes for a new list. They're lazy, only doing work when you iterate. Use them to chain operations without creating intermediate lists.

Flutter & Dart2 min read

Static Members: Belong to the Class, Not the Instance

A static member is shared across all instances of a class, belonging to the class itself. Use it for constants or utility functions that don't depend on an instance's state, like a global counter. The footgun: you cannot use `this` inside a static context.

Flutter & Dart2 min read

Dart Streams: Asynchronous Data Sequences

A Dart Stream is like a conveyor belt for asynchronous data, delivering events or file chunks as they arrive. Use them for continuous data flows like button clicks or reading large files.

Flutter & Dart2 min read

Dart Generics: Type-Safe Containers and Reusable Code

Generics let you define code that works with multiple types without sacrificing type safety. A `List<String>` is a list that only accepts strings. This is essential for collections.

Flutter & Dart2 min read

Dart's async/await: Non-Blocking Code That Reads Synchronously

Dart's `async`/`await` makes non-blocking code read like a simple script. Use it for network requests or file I/O to keep your UI from freezing. The biggest footgun is calling an async function but forgetting to `await` its `Future` result.

Flutter & Dart86 sec read

Dart's Cascade Notation: Chain Calls on One Object

Cascade notation (..) lets you perform a sequence of operations on the same object without repeating its name. It's ideal for configuring new instances in one block.

Dart's Null-Aware Operators: Safely Handle Nulls
Flutter & Dart2 min read

Dart's Null-Aware Operators: Safely Handle Nulls

Null-aware operators let you work with potentially null values without a cascade of `if (x != null)` checks. Use them to access properties, provide defaults, or assign values only when a variable is null. The footgun is confusing safe `?.` with unsafe `!`.

Flutter & Dart2 min read

Dart's Sound Null Safety: No More Null Errors

In Dart, variables can't be null unless you explicitly allow it. This flips the usual model, turning potential runtime null pointer crashes into compile-time errors you can fix immediately.

Flutter & Dart2 min read

Dart Collections: Choosing List, Set, or Map

Dart collections organize data: use a List for ordered items, a Set for unique items, and a Map for key-value pairs. This choice is fundamental for storing UI widgets or parsing JSON. The common footgun is using a List for lookups, which is slow; use.

Flutter & Dart2 min read

Dart Function Syntax: Block Body vs. Arrow Notation

Dart functions use a block body `{}` for multiple statements or arrow syntax `=>` for a single expression. Use `=>` for simple one-liners like `bool isEven(int n) => n % 2 == 0;`. The footgun is using `=>` for multi-step logic; it only works for.

Flutter & Dart2 min read

Dart's Control Flow: Telling Your Code What to Do Next

Control flow statements are the road signs for your code, directing execution beyond a simple top-to-bottom path. Use `if`/`else` for decisions, `for`/`while` for loops, and `try`/`catch` to handle errors. The footgun is forgetting `break` in a `switch` case.

Flutter & Dart2 min read

Dart's Core Data Types: Everything is an Object

In Dart, everything is an object, from numbers to functions. This means even a simple `int` or `String` has methods and properties, unlike primitive types in other languages. The main footgun is forgetting that `null` itself is a type, `Null`.

Flutter & Dart2 min read

Dart Variables: var, final, and const

In Dart, `var` creates a mutable variable, while `final` and `const` are for single-assignment. Use `var` for changing state, `final` for runtime values set once, and `const` for compile-time constants. The footgun is confusing `final` with `const`.

ProGuard Keep Rules: A "Do Not Remove" List for Your Code
Android & Kotlin2 min read

ProGuard Keep Rules: A "Do Not Remove" List for Your Code

ProGuard keep rules are a "do not remove" list for Android's code shrinker, telling it what to spare when it can't detect usage. This is crucial for code accessed via reflection or JNI.

Android Work Chaining: An Assembly Line for Tasks
Android & Kotlin2 min read

Android Work Chaining: An Assembly Line for Tasks

Chaining work in Android is like an assembly line for background tasks, ensuring one task finishes successfully before the next begins. It's used for multi-step operations like fetching, processing, and saving data.

Android Overdraw: Stop Painting Pixels Twice
Android & Kotlin2 min read

Android Overdraw: Stop Painting Pixels Twice

Overdraw is wasted GPU work, painting the same pixel multiple times in one frame. It causes UI stutter and drains battery. Fix it by removing unneeded backgrounds and flattening your UI layouts.

Android & Kotlin2 min read

Google Play Release Tracks: A Funnel for Quality

Google Play's release tracks are a funnel for quality, moving from a small trusted group to the public. Use them to get feedback, from internal QA (Internal track) to a wider audience (Closed/Open tracks), before a full production launch.