This repo is a minimal Flutter scaffold for the SDG MoneyMate frontend. It uses:
- Riverpod for state management
- Dio for network
A lightweight Flutter frontend scaffold for the SDG MoneyMate backend. It demonstrates a Clean Architecture layout with Riverpod state management and a small network layer (Dio) wired to the backend's JWT-based auth and AI endpoints.
- Riverpod for state management
- Dio for HTTP client and an interceptor to refresh tokens
- flutter_secure_storage for storing tokens securely
-
Install the Flutter SDK: Flutter install docs
-
Fetch dependencies:
flutter pub get- Run static analysis:
flutter analyze- Launch the app (connect a device or emulator):
flutter runflutter testThe ApiClient default base URL is http://localhost:8000. To change it, edit
lib/core/network/api_client.dart or provide a different baseUrl where the
ApiClient provider is created.
This scaffold expects the backend to expose JWT endpoints:
POST /api/token/(returnsaccessand optionallyrefresh)POST /api/token/refresh/(body{ "refresh": "..." })
The app stores tokens with flutter_secure_storage and uses an interceptor to
refresh the access token on 401 responses.
lib/main.dart— app entry, routes, ProviderScopelib/core/network/api_client.dart— Dio wrapper and interceptorlib/core/token_storage.dart— secure token storagelib/core/auth_gate.dart— route guard based on auth statelib/features/auth/— auth notifier, data source, repository and login UIlib/features/budget/— budget data source, repository and UIlib/features/chat/— chat data source, repository and UI
-
Auth flow:
AuthNotifieris a Riverpod StateNotifier that handles login, logout, and token refresh. After login, the access token is attached to the ApiClient Authorization header. -
Repositories: budget and chat features are wired through repository interfaces and Riverpod providers for easier testing and separation of concerns.
-
Tests: the
test/folder contains basic tests for the auth notifier and the budgets provider. Tests override providers to avoid touching real storage or network.
Fork and submit PRs to expand features (onboarding, expenses, advisor). When adding API usage, add a data source + repository + provider and corresponding unit tests.
- If you see network errors, ensure the backend is running and reachable from
your device (Android emulators may need
10.0.2.2to reach hostlocalhost). - If secure storage calls cause issues during testing, use provider overrides as shown in the tests.
This is a scaffold to support frontend development against the SDG-MoneyMate backend; adapt and extend as needed.
- If secure storage calls cause issues in tests, use provider overrides as the
- List devices recognized by Flutter:
flutter devices- Example output on this machine (your output may differ):
Found 3 connected devices:
CPH2473 (mobile) • 79124759 • android-arm64 • Android 14 (API 34)
Linux (desktop) • linux • linux-x64 • Pop!_OS 22.04 LTS
6.12.10-76061203-generic
Chrome (web) • chrome • web-javascript • Google Chrome 140.0.7339.127
Run "flutter emulators" to list and start any available device emulators.
- Run the app on a specific device (replace
<deviceId>with id fromflutter devices):
flutter run -d <deviceId>- Build and install an APK instead:
flutter build apk --debug
adb install -r build/app/outputs/flutter-apk/app-debug.apkNotes:
- For Android emulators use
10.0.2.2to reach a backend running on your hostlocalhost. - On Linux, if a physical device is not detected, you may need udev rules for your vendor id.
If your Android device is not detected on Linux, add a udev rule for the vendor id and restart udev:
- Find your device vendor id from
lsusb(example output shows vendor:product):
lsusb
# Bus 001 Device 005: ID 18d1:4ee7 Google Inc.- Create a udev rule file
/etc/udev/rules.d/51-android.ruleswith contents (replace0x18d1with your vendor id):
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
- Reload rules and replug the device:
sudo udevadm control --reload-rules
sudo udevadm trigger- Restart adb server and check devices:
adb kill-server
adb start-server
adb devicesIf adb devices shows unauthorized, accept the prompt on your phone.