Implement GitOps workflows with ArgoCD and Flux for automated, declarative Kubernetes...
npx skills add aloisdeniel/skills --skill "dev-dart-patterns"
Install specific skill from multi-skill repository
# Description
Common Dart specific development patterns. Triggers: flutter, dart
# SKILL.md
name: dev-dart-patterns
description: "Common Dart specific development patterns. Triggers: flutter, dart"
Dart Development Patterns
This skill provides common development patterns to be used when developping programs using the Dart programming language.
In class declarations, put the constructors first, then the properties, then the methods
class Example {
const Example({
required this.name,
});
final String name;
void greet() {
print('Hello, $name!');
}
}
Use sealed classes for restricted class hierarchies
/// Define a sealed class with subclasses
sealed class Result<T> {
const Result();
const factory Result.success(T data) = Success<T>;
const factory Result.error(int code) = Error<T>;
}
class Success<T> extends Result<T> {
final T data;
const Success(this.data);
}
class Error<T> extends Result<T> {
final int code;
const Error(this.code);
}
Prefer async functions with await and try/catch blocks over chaining then calls
Future<String> fetchData() async {
try {
final response = await http.get(Uri.parse('https://api.example.com/data'));
if (response.statusCode == 200) {
return response.body;
} else {
throw FetchException('Failed to load data, statuc code: ${response.statusCode}', inner: e);
}
} catch (e) {
throw FetchException('Error fetching data', inner: e);
}
}
User pattern matching with switch statements and expressions when possible
/// Pattern matching expressions with `switch`
@override
Widget build(BuildContext context) {
return switch(result) {
Success(:final data) => Container(color: Colors.green, child: Text('Success with data: $data')),
Error(:final code) => Text('Error with code: $code'),
};
}
/// Pattern matching statements with `switch`
switch(result) {
case Success(:final data):
print('Success with data: $data');
case Error(:final code)
print('Error with code: $code');
}
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.