Code Review Guidelines for YouDown Mobile
Use this skill when asked to review code or before finalizing significant changes. Focus on the following areas to ensure high quality, stability, and maintainability.
1. Architecture & State Management (BLoC)
- •Event/State Immutability: Ensure all Bloc Events and States are immutable (
@immutableor usingFreezed). - •Logic Separation: UI widgets should only dispatch events and listen to states. Business logic must reside in Blocs or Repositories.
- •Bloc Usage:
- •Use
BlocBuilderfor rebuilding UI part. - •Use
BlocListenerfor side effects (navigation, toasts, dialogs). - •Avoid overly complex logic inside
build()methods.
- •Use
- •HydratedBloc: Verify that state persistence logic (
fromJson/toJson) handles nulls and data migration gracefully.
2. Resource Management & Performance
- •Disposal: Check that all
Controllers(VideoPlayer, Chewie, TextEditing, Animation),Timers, andStreamsare properly disposed indispose(). - •Media Players: Ensure
video_playerandjust_audioinstances are stopped/paused before disposal to prevent background audio leaks. - •Build Method: Avoid expensive computations or object instantiations inside
build(). Uselate finalorinitStatewhere appropriate. - •const Constructors: Use
constfor widgets and values wherever possible to optimize rebuilds.
3. Error Handling & Stability
- •Network Requests: All
Diorequests must be wrapped in try/catch blocks handlingDioException. - •FFmpeg: Check for FFmpeg session return codes. Handle cases where merging or conversion fails.
- •Permissions: Verify that permission requests (
manageExternalStorage,photos, etc.) check the Android SDK version correctly (SDK 30+ vs older). - •Null Safety: strictly avoid force unwrapping (
!) unless absolutely certain. Use?.and??defaults.
4. User Interface & UX
- •Material 3: Ensure components follow Material 3 design guidelines (use
ColorScheme, proper typography). - •Responsiveness: UI should handle different screen sizes and orientations gracefully.
- •Dark Mode: Verify correct color usage for both Light and Dark themes (use
Theme.of(context).colorScheme). - •Localization: All user-facing text must use
easy_localizationkeys (e.g.,"key".tr()). No hardcoded strings.
5. Specific Project patterns
- •Background Service: Ensure tasks intended for background execution properly communicate with
FlutterForegroundTask. - •Navigation: Use
GoRouterfor all navigation. AvoidNavigator.pushunless working with dialogs/overlays that require it.
6. Security
- •Input Validation: Validate all user inputs (especially YouTube URLs).
- •File System: Be careful with file path manipulations. Use
path_providerand validate paths before writing.