skills/coding/coding-dart/SKILL.md
Dart 3: null safety, async/await, streams, isolates, Flutter integration, pub package manager
npx skillsauth add alphaonedev/openclaw-graph coding-dartInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides expertise in Dart 3 programming, focusing on features like null safety, async/await, streams, isolates, Flutter integration, and pub package management, to assist in writing efficient, safe code for apps and tools.
Use this skill for Dart 3 projects involving mobile apps (e.g., Flutter), concurrent processing, asynchronous operations, or package dependencies. Apply it when null safety is critical to avoid runtime errors, or for handling real-time data with streams.
late for lazy initialization and required for parameters, e.g., late String name; to declare a variable that must be initialized before use.Future and async functions, such as Future<void> fetchData() async { var data = await http.get('/api/data'); }.Stream from dart:async, e.g., Stream<int> countStream() async* { for (int i = 0; i < 5; i++) yield i; }.Isolate for CPU-bound operations, e.g., Isolate.spawn(workerFunction, args); to offload work.StatelessWidget for simple components.pub add package_name.To accomplish tasks, structure code with null safety by always specifying types (e.g., String? optionalString; for nullable values). For async operations, wrap I/O in async functions and use await for readability. Use isolates for background tasks to avoid UI blocking. Integrate Flutter by starting with MaterialApp in main.dart. For package management, run pub get after editing pubspec.yaml. Always test with dart test before deployment.
dart analyze with flags like --fatal-infos to enforce strict checks; run scripts with dart run bin/main.dart. For async, import dart:async and use Future.delayed(Duration(seconds: 1), () => print('Delayed'));.pub add http --major-version 1 for specific versions; update with pub upgrade; build packages with pub build --release.StreamController for custom streams, e.g., var controller = StreamController<int>(); controller.add(1);. For isolates, use Isolate.run for simple tasks: Isolate.run(() => computeHeavyTask());.pubspec.yaml for dependencies, e.g.:
dependencies:
http: ^1.0.0
Use environment variables for secrets, e.g., set $API_KEY and access via String.fromEnvironment('API_KEY').Integrate Dart with Flutter by adding Flutter dependencies in pubspec.yaml and running flutter pub get. For external APIs, set environment variables like $FLUTTER_API_KEY and access in code via Platform.environment['FLUTTER_API_KEY']. Combine with other tools by using Dart's FFI for C libraries or integrating with VS Code via the Dart extension (install with code --install-extension Dart-Code.dart-code). Ensure Dart SDK is in PATH; verify with dart --version.
Handle errors in async code with try-catch in async functions, e.g.:
try {
var result = await fetchData();
} catch (e) {
print('Error: $e');
}
For streams, use onError callbacks: stream.listen((data) => print(data), onError: (error) => print(error)). Check null safety errors with dart analyze, and use rethrow to propagate exceptions. For isolates, handle communication errors with ReceivePort and SendPort.
import 'package:http/http.dart' as http; Future<String?> getData() async { try { var response = await http.get(Uri.parse('https://api.example.com/data')); return response.body; } catch (e) { return null; } } Then call it with var data = await getData(); if (data != null) print(data);.import 'dart:async'; class MyWidget extends StatelessWidget { Stream<int> counter() async* { for (int i = 0; i < 5; i++) yield i; } @override Widget build(BuildContext context) { return StreamBuilder<int>( stream: counter(), builder: (context, snapshot) => Text(snapshot.data?.toString() ?? '0'), ); } }.tools
Root web development: project structure, tooling selection, deployment decisions
development
WebAssembly: Rust/Go/C to WASM, wasm-bindgen, Emscripten, WASM Component Model
development
Vue 3: Composition API script setup, Pinia, Vue Router 4, SFCs, Vite, Nuxt 3
tools
Tailwind CSS 4: utility classes, config, JIT, arbitrary values, darkMode, plugins, shadcn/ui