This repository has been archived on 2026-06-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
FabledApp/lib/providers/notes_provider.dart
T
bvandeusen 4da36aa31d Initial commit: Fabled Android app
Flutter Android client for FabledAssistant with:
- Session-cookie auth via persistent cookie jar (Dio + cookie_jar)
- OAuth/SSO login via in-app WebView (flutter_inappwebview)
- Notes: list, detail (markdown render), create/edit
- Tasks: list with status tabs, create/edit with priority
- Chat: SSE streaming bubbles, conversation management
- Quick Capture FAB for rapid note/task creation
- Settings screen (change server URL, logout)
- Android home screen widget → opens chat
- Riverpod state management, go_router navigation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28 21:28:53 -05:00

45 lines
1.2 KiB
Dart

import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../data/models/note.dart';
import 'api_client_provider.dart';
final notesProvider =
AsyncNotifierProvider<NotesNotifier, List<Note>>(NotesNotifier.new);
class NotesNotifier extends AsyncNotifier<List<Note>> {
@override
Future<List<Note>> build() async {
return ref.watch(notesRepositoryProvider).getAll();
}
Future<Note> create(String title, String body) async {
final note =
await ref.read(notesRepositoryProvider).create(title, body);
state = AsyncData([...state.valueOrNull ?? [], note]);
return note;
}
Future<Note> updateNote(int id, String title, String body) async {
final updated =
await ref.read(notesRepositoryProvider).update(id, title, body);
state = AsyncData([
for (final n in state.valueOrNull ?? [])
if (n.id == id) updated else n,
]);
return updated;
}
Future<void> delete(int id) async {
await ref.read(notesRepositoryProvider).delete(id);
state = AsyncData([
for (final n in state.valueOrNull ?? [])
if (n.id != id) n,
]);
}
}
final noteDetailProvider =
FutureProvider.family<Note, int>((ref, id) async {
return ref.watch(notesRepositoryProvider).getOne(id);
});