Skip to content

hafidmust/flutter-restful-bloc

Repository files navigation

Insurance Claims App

A Flutter mobile application that displays insurance claims using mock data from the JSONPlaceholder API.

Features

  • Claims List Screen: Displays a scrollable list of insurance claims with search and filtering functionality
  • Claim Detail Screen: Shows comprehensive details of a selected claim
  • Search Functionality: Search claims by title, description, claim ID, or claimant ID
  • Loading States: Displays loading indicators during data fetching
  • Error Handling: Robust error handling with retry functionality
  • Pull to Refresh: Refresh claims data with pull-to-refresh gesture

Architecture

This application follows clean architecture principles with BLoC (Business Logic Component) pattern:

  • Models: Data models for claims (Claim)
  • Services: API service layer (ClaimService) for data fetching
  • BLoC: State management using BLoC pattern (ClaimsBloc, ClaimsEvent, ClaimsState)
  • Screens: UI components (ClaimsListScreen, ClaimDetailScreen)
  • Error Handling: Custom exception handling (ClaimServiceException)

API Integration

The app uses the JSONPlaceholder API as a mock backend:

  • Endpoint: https://jsonplaceholder.typicode.com/posts
  • Mapping: Posts are mapped to insurance claims where:
    • userId → Claimant ID
    • id → Claim ID
    • title → Claim Title
    • body → Claim Description

Setup Instructions

Prerequisites

  • Flutter SDK (>=3.4.0)
  • Dart SDK
  • Android Studio / VS Code with Flutter extensions
  • An emulator or physical device for testing

Installation

  1. Clone the repository

    git clone <repository-url>
    cd insurance_claims
  2. Install dependencies

    flutter pub get
  3. Run the application

    flutter run

Running Tests

Execute unit tests and widget tests:

flutter test

Building for Production

Android APK:

flutter build apk --release

iOS (requires macOS):

flutter build ios --release

Project Structure

lib/
├── main.dart                 # App entry point
├── bloc/
│   ├── claims_bloc.dart         # Claims BLoC implementation
│   ├── claims_event.dart        # Claims events
│   └── claims_state.dart        # Claims states
├── models/
│   └── claim.dart           # Claim data model
├── screens/
│   ├── claims_list_screen.dart    # Claims list UI
│   └── claim_detail_screen.dart   # Claim detail UI
└── services/
    └── claim_service.dart         # API service layer

test/
├── bloc/
│   └── claims_bloc_test.dart        # BLoC unit tests
├── models/
│   └── claim_test.dart           # Model unit tests
├── screens/
│   ├── claims_list_screen_test.dart    # List screen widget tests
│   └── claim_detail_screen_test.dart   # Detail screen widget tests
├── services/
│   └── claim_service_test.dart         # Service unit tests
└── widget_test.dart                    # Main app integration test

Dependencies

  • http: ^1.1.0 - HTTP client for API requests
  • flutter_bloc: ^8.1.3 - BLoC state management
  • equatable: ^2.0.5 - Value equality for BLoC states
  • flutter: SDK
  • cupertino_icons: ^1.0.6 - iOS style icons

Dev Dependencies

  • flutter_test: SDK - Testing framework
  • bloc_test: ^9.1.4 - BLoC testing utilities
  • flutter_lints: ^3.0.0 - Dart linting rules

Testing

The application includes comprehensive testing:

  • Unit Tests: Models and services
  • Widget Tests: UI components and user interactions
  • Integration Tests: App flow and navigation

Test coverage includes:

  • Claim model serialization/deserialization
  • API service error handling
  • UI component rendering
  • User interaction flows
  • Network error scenarios

Screenshots

Android Screenshots

Claims List Screen

Android Claims List

Claim Detail Screen

Android Claim Detail

Search - No Results Found

Android Search Not Found

iOS Screenshots

Claims List Screen

iOS Claims List

Claim Detail Screen

iOS Claim Detail

Search - No Results Found

iOS Search Not Found

Technical Decisions

  1. Architecture: Used BLoC pattern with clean architecture for separation of concerns
  2. State Management: BLoC pattern for predictable state management
  3. Error Handling: Implemented custom exceptions for better error management
  4. UI/UX: Material Design 3 for consistent user experience
  5. Testing: Comprehensive test suite with BLoC testing and mocking for reliable testing
  6. Dependencies: Minimal external dependencies focused on essential functionality

Future Enhancements

  • Add offline capability with local database
  • Implement claim creation and editing
  • Add user authentication
  • Include push notifications for claim updates
  • Add data visualization and analytics
  • Implement caching strategies for better performance
  • Add pagination for large datasets

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published