Best practices and conventions for developing Flutter games with proper widget composition, state management, and Dart patterns optimized for game development.
This skill provides workspace-specific instructions for developing Flutter game applications, focusing on Flutter/Dart best practices, widget composition patterns, and game-specific optimizations.
When working with Flutter game projects, follow these guidelines:
- `StatefulWidget` for simple local game state
- `StatelessWidget` for immutable game UI components
- Provider or other state management solutions for complex game state
- `camelCase` for variables and functions
- `PascalCase` for classes and widgets
When creating a new game widget:
```dart
// Use const constructors for performance
class GameButton extends StatelessWidget {
const GameButton({
Key? key,
required this.onPressed,
required this.label,
}) : super(key: key);
final VoidCallback onPressed;
final String label;
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: onPressed,
child: Text(label),
);
}
}
```
When managing game state:
```dart
class GameScreen extends StatefulWidget {
const GameScreen({Key? key}) : super(key: key);
@override
State<GameScreen> createState() => _GameScreenState();
}
class _GameScreenState extends State<GameScreen> {
int score = 0;
@override
void dispose() {
// Clean up game resources
super.dispose();
}
@override
Widget build(BuildContext context) {
// Build game UI
}
}
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/flutter-apple-game-development/raw