An open API service indexing awesome lists of open source software.

https://github.com/spring-petclinic/spring-petclinic-flutter

Flutter frontend for Spring Petclinic, supporting Android and web with the Spring Petclinic REST backend.
https://github.com/spring-petclinic/spring-petclinic-flutter

android cross-platform dart flutter flutter-demo mobile-app rest-api sample spring spring-petclinic web

Last synced: about 10 hours ago
JSON representation

Flutter frontend for Spring Petclinic, supporting Android and web with the Spring Petclinic REST backend.

Awesome Lists containing this project

README

          

# Spring Petclinic Flutter

[![Flutter CI](https://github.com/spring-petclinic/spring-petclinic-flutter/actions/workflows/dart.yml/badge.svg?branch=master)](https://github.com/spring-petclinic/spring-petclinic-flutter/actions/workflows/dart.yml)
[![OSV Scanner](https://github.com/spring-petclinic/spring-petclinic-flutter/actions/workflows/osv-scanner.yml/badge.svg?branch=master)](https://github.com/spring-petclinic/spring-petclinic-flutter/actions/workflows/osv-scanner.yml)
[![Semgrep](https://github.com/spring-petclinic/spring-petclinic-flutter/actions/workflows/semgrep.yml/badge.svg?branch=master)](https://github.com/spring-petclinic/spring-petclinic-flutter/actions/workflows/semgrep.yml)
[![CodeQL](https://github.com/spring-petclinic/spring-petclinic-flutter/actions/workflows/codeql.yml/badge.svg?branch=master)](https://github.com/spring-petclinic/spring-petclinic-flutter/actions/workflows/codeql.yml)

Flutter frontend for [Spring Petclinic](https://github.com/spring-petclinic). This app targets Android and web, mirrors
the functional flows of the [Angular frontend](https://github.com/spring-petclinic/spring-petclinic-angular), and uses the same REST backend exposed by
[spring-petclinic-rest](https://github.com/spring-petclinic/spring-petclinic-rest).

The CI status includes static analysis, tests, the web build, and the Android debug APK build.

## Table of Contents

- [Screenshots](#screenshots)
- [Project Structure](#project-structure)
- [Backend](#backend)
- [API Configuration](#api-configuration)
- [Run on Android](#run-on-android)
- [Run on Web](#run-on-web)
- [Build](#build)
- [Validation](#validation)
- [Contributing](#contributing)

## Screenshots

### Web


Spring Petclinic owners screen on web
Spring Petclinic owners details screen on web

### Android


Spring Petclinic home screen on Android
Spring Petclinic owner details screen on Android

## Project Structure

The codebase follows a feature-first package structure under the `lib` directory:

```text
lib/
├── features/ # Feature-specific modules (screens, services, models)
│ ├── home/ # Home screen
│ ├── owners/ # Owner management (list, details, form)
│ ├── pets/ # Pet management (form)
│ ├── pettypes/ # Pet type administration
│ ├── specialties/ # Vet specialties administration
│ ├── vets/ # Veterinarians list and forms
│ └── visits/ # Pet visit registration and history
├── shared/ # Common and shared components across features
│ ├── config/ # Global configuration (e.g., API config)
│ ├── forms/ # Generic form validators and text helpers
│ ├── navigation/ # App routes and navigation extensions
│ ├── network/ # HTTP/REST API client and exception handling
│ ├── theme/ # App color schemes and typography
│ ├── utils/ # Helper functions and formatting utilities
│ └── widgets/ # Reusable layout and UI widgets
└── main.dart # App entry point
```

## Backend

Start the backend first:

```bash
cd ~/spring-petclinic-rest
./mvnw spring-boot:run
```

The expected API is:

```text
http://localhost:9966/petclinic/api
```

## API configuration

The app resolves the API base URL in this order:

1. `PETCLINIC_API_BASE_URL` passed with `--dart-define`
2. Platform default

Platform defaults:

- Android emulator: `http://10.0.2.2:9966/petclinic/api`
- Web: `http://localhost:9966/petclinic/api`
- Other non-Android platforms: `http://localhost:9966/petclinic/api`

That logic lives in:

```text
lib/shared/config/api_config.dart
```

Override it at runtime when needed:

```bash
flutter run --dart-define=PETCLINIC_API_BASE_URL=http://:9966/petclinic/api
```

Use an explicit override when:

- running on a physical Android device;
- serving the web app against a backend that is not on `localhost`;
- pointing the app to a shared/staging backend.

## Run on Android

For an Android emulator:

```bash
cd ~/spring-petclinic-flutter
flutter pub get
flutter run
```

For a physical Android device, pass the host machine IP explicitly:

```bash
flutter run --dart-define=PETCLINIC_API_BASE_URL=http://:9966/petclinic/api
```

## Run on Web

For local browser development against the backend running on the same machine:

```bash
cd ~/spring-petclinic-flutter
flutter pub get
flutter run -d chrome
```

If the backend is not reachable at `http://localhost:9966/petclinic/api`, pass an override:

```bash
flutter run -d chrome --dart-define=PETCLINIC_API_BASE_URL=http://:9966/petclinic/api
```

## Build

Build an Android debug APK:

```bash
flutter build apk --debug
```

Build the web app:

```bash
flutter build web
```

## Validation

Typical checks:

```bash
dart format --set-exit-if-changed .
flutter analyze
flutter test
flutter build apk --debug
flutter build web
```

GitHub Actions also runs dependency vulnerability scanning with OSV Scanner,
an advisory Semgrep scan, and CodeQL analysis for workflow security.

## Contributing

The [issue tracker](https://github.com/San-43/spring-petclinic-flutter/issues) is the preferred channel for reporting bugs and proposing new features.

Please refer to [CONTRIBUTING.md](CONTRIBUTING.md) for detailed contribution guidelines, including the pull request process and contribution workflow.