TechNews is a modern Flutter application built with Clean Architecture and BLoC pattern that delivers the latest technology news. The app features a robust architecture with proper separation of concerns, comprehensive error handling, and enterprise-grade code organization.
This project follows Clean Architecture principles with the BLoC (Business Logic Component) pattern for state management, ensuring:
- Separation of Concerns: Clear boundaries between data, business logic, and presentation layers
- Testability: Interface-based design enables comprehensive unit and integration testing
- Maintainability: Modular structure makes the codebase easy to understand and modify
- Scalability: Architecture supports feature growth and team expansion
- Error Handling: Robust exception handling with custom error types
lib/
โโโ main.dart # Application entry point with DI setup
โโโ core/ # ๐ง Core functionality layer
โ โโโ constants/ # Application constants
โ โ โโโ api_constants.dart # API endpoints and configuration
โ โ โโโ app_constants.dart # App-wide settings and constants
โ โโโ errors/ # Custom error handling
โ โ โโโ exceptions.dart # Custom exception hierarchy
โ โโโ utils/ # Utility functions
โ โโโ date_utils.dart # Date formatting and manipulation
โ โโโ network_utils.dart # Network connectivity utilities
โโโ data/ # ๐ Data layer
โ โโโ datasources/ # Data source abstractions
โ โ โโโ news_data_source.dart # Data source interfaces
โ โ โโโ news_remote_data_source.dart # API implementation
โ โ โโโ news_local_data_source.dart # Local storage implementation
โ โโโ repositories/ # Repository implementations
โ โโโ news_repository_impl.dart # News repository with DI
โโโ models/ # ๐ Data models
โ โโโ news_article.dart # News article model
โโโ bloc/ # ๐ง Business logic layer (BLoC)
โ โโโ navigation/ # Navigation state management
โ โ โโโ navigation_bloc.dart
โ โ โโโ navigation_event.dart
โ โ โโโ navigation_state.dart
โ โโโ news/ # General tech news BLoC
โ โ โโโ news_bloc.dart
โ โ โโโ news_event.dart
โ โ โโโ news_state.dart
โ โโโ ai_news/ # AI-specific news BLoC
โ โ โโโ ai_news_bloc.dart
โ โ โโโ ai_news_event.dart
โ โ โโโ ai_news_state.dart
โ โโโ saved_news/ # Bookmarked news BLoC
โ โ โโโ saved_news_bloc.dart
โ โ โโโ saved_news_event.dart
โ โ โโโ saved_news_state.dart
โ โโโ news_detail/ # Article detail BLoC
โ โโโ news_detail_bloc.dart
โ โโโ news_detail_event.dart
โ โโโ news_detail_state.dart
โโโ screens/ # ๐จ Presentation layer
โโโ news_screen.dart # Main news feed screen
โโโ ai_news_screen.dart # AI news screen
โโโ saved_news_screen.dart # Bookmarked articles screen
โโโ news_detail_screen.dart # Article detail screen
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Flutter: Cross-platform mobile development framework
- Dart: Programming language
- BLoC Pattern: State management and business logic
- Clean Architecture: Architectural design pattern
- HTTP: API communication
- SharedPreferences: Local data persistence
- Equatable: Value equality and immutability
Ensure you have the following installed on your machine:
- Flutter (version 3.0.0 or later)
- Dart (version 3.0.0 or later)
- Android Studio (for Android development)
- Xcode (for iOS development, macOS only)
- Visual Studio Code (optional, but recommended)
-
Clone the repository:
git clone https://github.com/codewithkd77/technews-flutter.git cd technews-flutter
-
Install dependencies:
flutter pub get
-
Configure API:
- Open the
lib/core/constants/api_constants.dart
file. - Replace the placeholder API URL and API key with your own:
class ApiConstants { static const String baseUrl = 'YOUR_API_BASE_URL'; static const String aiNewsApiUrl = 'YOUR_AI_NEWS_API_URL'; static const String aiApiKey = 'YOUR_AI_API_KEY'; }
- Open the
-
Run the project:
- Android:
- Ensure you have an Android emulator running or a physical device connected.
flutter run
- iOS:
- Ensure you have an iOS simulator running or a physical device connected.
flutter run
- Android:
To build the APK file for Android:
flutter build apk --release
The APK file will be generated in the build/app/outputs/flutter-apk/
directory.
To build the iOS app:
flutter build ios --release
Note: You need a macOS machine with Xcode installed to build the iOS app.
-
Core Layer (
lib/core/
)- Constants: API endpoints, app configuration
- Errors: Custom exception hierarchy for robust error handling
- Utils: Shared utility functions and helpers
-
Data Layer (
lib/data/
)- Data Sources: Abstract interfaces and concrete implementations
NewsRemoteDataSource
: API communicationNewsLocalDataSource
: Local storage operations
- Repositories: Implementation of repository interfaces with dependency injection
- Data Sources: Abstract interfaces and concrete implementations
-
Domain Layer (Implicit)
- Models: Data entities and business objects
- Repository Interfaces: Abstract contracts for data operations
-
Presentation Layer (
lib/bloc/
+lib/screens/
)- BLoC: Business logic and state management
- Screens: UI components and user interactions
- ๐ Dependency Inversion: High-level modules don't depend on low-level modules
- ๐งช Testability: Each layer can be tested independently
- ๐ง Maintainability: Clear separation of concerns
- ๐ Scalability: Easy to add new features and modify existing ones
- ๐ Error Handling: Comprehensive exception handling at each layer
- Main tech news feed
- Pull-to-refresh functionality
- Navigation to article details
- Search functionality
- Dedicated AI and machine learning news
- Similar functionality to main news feed
- AI-specific content filtering
- Bookmarked articles management
- Local storage integration
- Remove from bookmarks functionality
- Full article content display
- Bookmark/unbookmark functionality
- Share article feature
- Related articles suggestions
Update lib/core/constants/api_constants.dart
:
class ApiConstants {
static const String baseUrl = 'https://your-api-url.com';
static const String newsEndpoint = '/api/news';
static const String aiNewsApiUrl = 'https://your-ai-api-url.com';
}
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Follow the architecture: Maintain Clean Architecture principles
- Write tests: Include unit tests for new features
- Follow code style: Use consistent formatting and naming
- Commit changes:
git commit -m 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Open a Pull Request
- Follow Dart Style Guide
- Use meaningful variable and function names
- Add comprehensive documentation
- Maintain consistent file structure
- Include proper error handling
- Dark mode support
- Push notifications for breaking news
- Offline reading mode
- Social sharing integration
- News categories and filtering
- User preferences and customization
- Analytics integration
This project is licensed under the MIT License - see the LICENSE file for details.
KULDEEPSINH - codewithkd77
- Flutter team for the amazing framework
- BLoC pattern developers for state management solution
- Clean Architecture principles by Robert C. Martin
- Open source community for continuous inspiration
Built with โค๏ธ using Flutter and Clean Architecture