Loading...
Loading...
Apply design principles to create intuitive and robust library interfaces.
npx skill4agent add dart-lang/skills dart-api-designlist.lengthisEmptycanCloselist.add()to___()list.toSet()as___()map.asMap()EKVRTSUabstract classinterface classabstract interface classbase classbasefinalsealedsealed classfinal classcalltypedefiscanhas// GOOD
void configure(String name, {bool paused = false, bool growable = true}) {}
var sub = items.sublist(0, 3);
// BAD
void configure(String name, bool isPaused, bool canGrow) {}finallate final// GOOD
class Rectangle {
double _width;
Rectangle(this._width);
double get width => _width;
set width(double value) => _width = value;
double get area => _width * _width; // Idempotent, no side effects
}this.xFuture<void>voidFuture<Null>FutureOr<T>Future<T>// GOOD
typedef Comparison<T> = int Function(T a, T b);
class FilteredObservable {
final bool Function(Event) _predicate; // Inline function type
FilteredObservable(this._predicate);
}==hashCode====ObjectObject?// GOOD
class Person {
final String name;
Person(this.name);
bool operator ==(Object other) => other is Person && name == other.name;
int get hashCode => name.hashCode;
}typedef name(args)typedef Name = ReturnType Function(args)isFutureStreamthisthis..List numbers = []dart-effective-styledart-package-management