-
-
Notifications
You must be signed in to change notification settings - Fork 24
Add Empty-State UI and Retry Actions for Summary and Prescription Screens #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,14 @@ import 'screens/summary_screen.dart'; | |||||||||||||||||||||||||||||
| import 'screens/prescription_screen.dart'; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Future<void> main() async { | ||||||||||||||||||||||||||||||
| await dotenv.load(); | ||||||||||||||||||||||||||||||
| // Try loading .env if present; if not, continue and rely on --dart-define. | ||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||
| await dotenv.load(fileName: '.env'); | ||||||||||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||||||||||
| // No .env found in production builds; use --dart-define fallback | ||||||||||||||||||||||||||||||
| developer.log('No .env loaded: $e'); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| runApp(const MyApp()); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -186,7 +193,7 @@ class _TranscriptionScreenState extends State<TranscriptionScreen> with SingleTi | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Future<void> _transcribeAudio() async { | ||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||
| final apiKey = dotenv.env['DEEPGRAM_API_KEY'] ?? ''; | ||||||||||||||||||||||||||||||
| final apiKey = getDeepgramApiKey(); | ||||||||||||||||||||||||||||||
| final uri = Uri.parse('https://api.deepgram.com/v1/listen?model=nova-2'); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| final file = File(_recordingPath); | ||||||||||||||||||||||||||||||
|
|
@@ -474,7 +481,13 @@ class _TranscriptionScreenState extends State<TranscriptionScreen> with SingleTi | |||||||||||||||||||||||||||||
| () => Navigator.push( | ||||||||||||||||||||||||||||||
| context, | ||||||||||||||||||||||||||||||
| MaterialPageRoute( | ||||||||||||||||||||||||||||||
| builder: (context) => SummaryScreen(summary: _summaryContent), | ||||||||||||||||||||||||||||||
| builder: (context) => SummaryScreen( | ||||||||||||||||||||||||||||||
| summary: _summaryContent, | ||||||||||||||||||||||||||||||
| onRetry: () { | ||||||||||||||||||||||||||||||
| Navigator.pop(context); | ||||||||||||||||||||||||||||||
| _processWithGemini(_transcription); | ||||||||||||||||||||||||||||||
|
Comment on lines
+486
to
+488
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add validation and concurrency guard before retrying Gemini processing. The retry callback directly passes
🔎 Proposed fix with validation and concurrency guard onRetry: () {
+ if (_isProcessing) return;
+ if (_transcription.isEmpty || _transcription == 'No speech detected') {
+ ScaffoldMessenger.of(context).showSnackBar(
+ const SnackBar(content: Text('No valid transcription to retry')),
+ );
+ return;
+ }
Navigator.pop(context);
_processWithGemini(_transcription);
},📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||
|
|
@@ -487,7 +500,13 @@ class _TranscriptionScreenState extends State<TranscriptionScreen> with SingleTi | |||||||||||||||||||||||||||||
| () => Navigator.push( | ||||||||||||||||||||||||||||||
| context, | ||||||||||||||||||||||||||||||
| MaterialPageRoute( | ||||||||||||||||||||||||||||||
| builder: (context) => PrescriptionScreen(prescription: _prescriptionContent), | ||||||||||||||||||||||||||||||
| builder: (context) => PrescriptionScreen( | ||||||||||||||||||||||||||||||
| prescription: _prescriptionContent, | ||||||||||||||||||||||||||||||
| onRetry: () { | ||||||||||||||||||||||||||||||
| Navigator.pop(context); | ||||||||||||||||||||||||||||||
| _processWithGemini(_transcription); | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,7 +5,8 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| class ChatbotService { | ||||||||||||||||||||||||||
| // Get API key from .env file | ||||||||||||||||||||||||||
| final String apiKey = dotenv.env['GEMINI_API_KEY'] ?? ''; | ||||||||||||||||||||||||||
| // Get API key using config fallback (dart-define > .env) | ||||||||||||||||||||||||||
| String get apiKey => getGeminiApiKey(); | ||||||||||||||||||||||||||
|
Comment on lines
7
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing import for The getter references Also, the 🔎 Proposed fix import 'dart:convert';
import 'dart:developer' as developer;
import 'package:http/http.dart' as http;
-import 'package:flutter_dotenv/flutter_dotenv.dart';
+import 'config.dart';
class ChatbotService {
- // Get API key from .env file
// Get API key using config fallback (dart-define > .env)
String get apiKey => getGeminiApiKey();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Get a response from Gemini based on a prompt | ||||||||||||||||||||||||||
| Future<String> getGeminiResponse(String prompt) async { | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
|
|
||
| /// Return GEMINI API key from --dart-define or .env as fallback. | ||
| String getGeminiApiKey() { | ||
| const envValue = String.fromEnvironment('GEMINI_API_KEY'); | ||
| if (envValue.isNotEmpty) return envValue; | ||
| return dotenv.env['GEMINI_API_KEY'] ?? ''; | ||
| } | ||
|
|
||
| /// Return DEEPGRAM API key from --dart-define or .env as fallback. | ||
| String getDeepgramApiKey() { | ||
| const envValue = String.fromEnvironment('DEEPGRAM_API_KEY'); | ||
| if (envValue.isNotEmpty) return envValue; | ||
| return dotenv.env['DEEPGRAM_API_KEY'] ?? ''; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing import for
getDeepgramApiKeywill cause a compile error.The function
getDeepgramApiKey()is called but not imported fromconfig.dart. This will fail at compile time.🔎 Proposed fix
Add the import at the top of the file with the other service imports:
import 'services/chatbot_service.dart'; import 'screens/transcription_detail_screen.dart'; import 'screens/summary_screen.dart'; import 'screens/prescription_screen.dart'; +import 'services/config.dart';🤖 Prompt for AI Agents