A Flutter application showcasing top anime using Clean Architecture principles, built as a migration from the original Android application.
- π― Clean Architecture - Separated into Data, Domain, and Presentation layers
- π State Management - Using Cubit from flutter_bloc
- πΎ Offline Support - Local caching with SharedPreferences
- π Dark Theme - Automatic light/dark theme switching
- π Pull to Refresh - Refresh anime list with pull-to-refresh gesture
- π External Links - Tap anime cards to open in browser
- β‘ Modern UI - Material 3 design with smooth animations
lib/
βββ core/ # Core functionality
β βββ constants/ # App constants (API URLs, storage keys)
β βββ error/ # Error handling (failures, exceptions)
β βββ network/ # Network client configuration
β βββ usecases/ # Base use case classes
βββ data/ # Data layer
β βββ datasources/ # Remote and local data sources
β βββ models/ # Data Transfer Objects (DTOs)
β βββ repositories/ # Repository implementations
βββ domain/ # Domain layer (pure Dart)
β βββ entities/ # Business entities
β βββ repositories/ # Repository contracts
β βββ usecases/ # Business logic use cases
βββ presentation/ # Presentation layer
β βββ cubit/ # State management (Cubit & States)
β βββ pages/ # Screen widgets
β βββ widgets/ # Reusable UI components
βββ injection_container.dart # Dependency injection setup
This application follows Clean Architecture principles:
- AnimeRemoteDataSource: Fetches data from Jikan API
- AnimeLocalDataSource: Handles local caching with SharedPreferences
- AnimeRepositoryImpl: Implements repository contract, handles data flow
- Anime: Core business entity (pure Dart)
- AnimeRepository: Abstract repository contract
- GetTopAnime: Use case for fetching anime data
- AnimeCubit: Manages UI state using Cubit pattern
- AnimeListPage: Main screen displaying anime grid
- AnimeCard: Reusable widget for anime items
The app integrates with the Jikan API to fetch top upcoming anime data.
- flutter_bloc: State management with Cubit
- get_it: Dependency injection
- dio: HTTP client for API calls
- dartz: Functional programming (Either type)
- equatable: Value equality comparison
- cached_network_image: Image caching and loading
- shimmer: Loading placeholder animations
- url_launcher: External link handling
- bloc_test: Testing Cubit state changes
- mocktail: Mocking for unit tests
- build_runner: Code generation
- json_serializable: JSON serialization
- Flutter SDK (3.8.1 or higher)
- Dart SDK (3.8.1 or higher)
-
Clone the repository
-
Navigate to the flutter directory:
cd flutter -
Install dependencies:
flutter pub get
-
Generate code (if needed):
flutter packages pub run build_runner build
-
Run the app:
flutter run
flutter testflutter test test/widget_test.dartflutter test --coverageThe app uses Cubit for state management with the following states:
- AnimeInitial: Initial state when app starts
- AnimeLoading: Data is being fetched
- AnimeLoaded: Data successfully loaded
- AnimeError: Error occurred during data fetching
The app provides offline functionality through:
- Cache Strategy: Data is cached locally using SharedPreferences
- Cache Validity: Cache expires after 24 hours
- Fallback: If network fails, app shows cached data
- Refresh: Pull-to-refresh forces fresh data fetch
| Android (Kotlin) | Flutter (Dart) |
|---|---|
| MVVM + Repository | Clean Architecture |
| ViewModel | Cubit |
| LiveData | Cubit States |
| Retrofit | Dio |
| Room Database | SharedPreferences |
| RecyclerView | GridView.builder |
| Glide | CachedNetworkImage |
| Dagger | get_it |
flutter build apk --releaseflutter build ios --releaseflutter build web --release- Follow the existing code structure and naming conventions
- Write tests for new features
- Ensure code passes linting checks
- Update documentation for significant changes
This project is licensed under the MIT License - see the original project's LICENSE file for details.