Music Creation Page: - Vinyl 3D flip to view lyrics, tonearm animation, glow rotation effect - Circular SVG progress ring, speech bubble feedback, confirm dialog - Playlist modal, free creation input, lyrics formatting optimization - MiniMax API real music generation with SSE streaming progress Backend: - FastAPI proxy server.py for MiniMax API calls - Music + lyrics file persistence to Capybara music/ directory - GET /api/playlist endpoint for auto-building playlist from files UI/UX Refinements: - frontend-design skill compliance across all pages - Glassmorphism effects, modal interactions, scroll tap prevention - iPhone 12 Pro responsive layout (390x844) Flutter Development Preparation: - Installed flutter-expert skill with 6 reference docs - Added 5 Cursor Rules: official Flutter, clean architecture, UI performance, testing, Dart standards Assets: - 9 Capybara music MP3 files + lyrics TXT files - MiniMax API documentation Co-authored-by: Cursor <cursoragent@cursor.com>
53 lines
2.2 KiB
Plaintext
53 lines
2.2 KiB
Plaintext
---
|
|
description: Flutter UI patterns, widget best practices, and performance optimization. Apply to all presentation-layer Dart files.
|
|
globs: "lib/**/{widgets,pages,screens,components}/**/*.dart"
|
|
---
|
|
|
|
# Flutter UI & Performance Rules
|
|
|
|
## Widget Best Practices
|
|
- Create small, private widget classes instead of methods like `Widget _buildXxx()`.
|
|
- Use const constructors for all immutable widgets.
|
|
- Implement proper widget keys for lists and conditional widgets.
|
|
- Keep widget tree flat — avoid nesting deeper than necessary.
|
|
- Use composition: combine small widgets into complex ones.
|
|
|
|
## Performance Optimization
|
|
- Use ListView.builder / GridView.builder for long scrollable lists.
|
|
- Use const wherever possible to skip unnecessary rebuilds.
|
|
- Avoid expensive operations (network calls, parsing) in build().
|
|
- Use compute() to run heavy work in a background isolate.
|
|
- Use RepaintBoundary to isolate expensive paint operations.
|
|
- Cache images: AssetImage for local, cached_network_image for remote.
|
|
- Profile regularly with Flutter DevTools; target 60fps.
|
|
|
|
## Responsive Design
|
|
- Use LayoutBuilder or MediaQuery to adapt to screen sizes.
|
|
- Use Expanded/Flexible in Row/Column to prevent overflow.
|
|
- Use Wrap for content that may overflow horizontally.
|
|
- Use FittedBox to scale a child within its parent.
|
|
|
|
## Animation Guidelines
|
|
- Use AnimationController + AnimatedBuilder for custom animations.
|
|
- Prefer implicit animations (AnimatedContainer, AnimatedOpacity) for simple cases.
|
|
- Use physics-based animations (SpringSimulation) for natural feel.
|
|
- Always dispose AnimationControllers in dispose().
|
|
|
|
## Theming in Widgets
|
|
- Access colors via Theme.of(context).colorScheme.
|
|
- Access text styles via Theme.of(context).textTheme.
|
|
- Never hardcode colors or font sizes — always reference theme.
|
|
- Use Theme.of(context).extension<T>() for custom design tokens.
|
|
|
|
## Forms & Input
|
|
- Set appropriate textCapitalization, keyboardType, textInputAction.
|
|
- Always include errorBuilder when using Image.network.
|
|
- Implement RefreshIndicator for pull-to-refresh.
|
|
- Use Form + GlobalKey<FormState> for validation.
|
|
|
|
## Accessibility
|
|
- Use Semantics widget for all interactive elements.
|
|
- Ensure touch targets ≥ 48x48 dp.
|
|
- Test with screen readers (TalkBack / VoiceOver).
|
|
- Support dynamic type scaling.
|