Inspiration Legal information is confusing, expensive, and slow—especially for everyday issues like unpaid overtime, landlord disputes, or contract terms. We wanted to make high-quality legal information accessible, fast, and friendly.


What it does • Answers plain-English legal questions with direct, actionable guidance • Analyzes uploaded documents (images/PDF screenshots) using OCR • Highlights relevant laws (e.g., FLSA overtime rules) and suggests clear next steps • Saves past cases locally for quick reference • Cross-platform: Windows, Web, Android/iOS-ready Disclaimer: This app provides general legal information—not legal advice.


How we built it • Flutter + Dart for a fast, cross-platform UI • Provider for clean, reactive state management • OCR pipeline to extract text and detect document types • AI via OpenRouter API (configurable model) with timeouts, retries, and fallback • Hive for local storage (settings, cases, saved analyses) • Dio for secure networking • Web-aware file handling (bytes vs paths) with defensive error handling • Web scraping utilities for official public legal resources


Challenges we ran into • Preventing “setState during build” → solved with post-frame callbacks • Handling long AI response times → progressive timeouts + retry logic • Cross-platform file handling for images (web vs desktop/mobile) • Prompt design to force direct answers (“Is X illegal?” → clear yes/no + statute)


Accomplishments we’re proud of • Stable startup with safe initialization and no UI jank • Consistent AI responses with structured sections and official links • Document-aware analysis with actionable “next steps” • Fallback mode when AI is unavailable (local knowledge + guidance)


What we learned • Good UX needs resilient backends (timeouts, retries, fallbacks) • Prompt engineering is as important as code structure • Cross-platform file I/O requires careful platform checks and clear error handling


What’s next • Multi-jurisdiction coverage and localization • PDF/native doc parsing with highlighted excerpts • In-app letter templates and one-click PDF exports • Privacy mode with on-device AI analysis where possible


Ethics & Safety • No legal advice—only educational information • Clear disclaimers and links to official resources (e.g., DOL, Legal Aid) • No hidden data collection; API keys stored securely by the user


Built with Flutter (Dart) · Provider · Hive · Dio · file_picker · speech_to_text · flutter_tts · share_plus · printing · geolocator / geocoding · OpenRouter API · OCR service · Web scraping utilities


Try it out • GitHub: https://github.com/assassinaj602/ai-pocket-lawyer.git


Code block example // Retry with exponential backoff in Provider class AskViewModel extends ChangeNotifier { final AiClient ai; AskViewModel(this.ai);

Future ask(String question, {int maxRetries = 3}) async { int attempt = 0; while (true) { try { final res = await ai.answer(question, timeout: Duration(seconds: 30 + 10 * attempt)); return res; // structured markdown with: Analysis / Rights / Next Steps } catch (e) { if (attempt++ >= maxRetries) rethrow; await Future.delayed(Duration(milliseconds: 300 * (1 << attempt))); // backoff } } } }


LaTeX example Inline retry delay: ( d_k = d_0 \cdot 2^k ) Expected total wait after (n) retries: Tn=∑k=0nd0⋅2k=d0⋅2 n+1−12−1.T_n = \sum_{k=0}^{n} d_0 \cdot 2^k = d_0 \cdot \frac{2^{\,n+1} - 1}{2 - 1}.Tn=k=0∑nd0⋅2k=d0⋅2−12n+1−1.

Built With

  • ai
  • apis
  • cloud-services
  • dart
  • databases
  • deepseek
  • flutter
  • frameworks
  • openrouter
  • or-other-technologies-did-you-use?-*-built-with-languages
  • platforms
Share this project:

Updates