Skip to content

Commit

Permalink
check if env exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jwt2706 committed Mar 12, 2024
1 parent 7f5c766 commit ee8cd37
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/screens/send_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ class _SendDataState extends State<SendData> {
}

Future<void> loadEnv() async {
String envString;
try {
envString = await rootBundle.loadString('.env');
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('The .env file could not be found')),
);
return;
}

try {
await dotenv.load(fileName: ".env").timeout(Duration(seconds: 5));
_gsheets = GSheets(dotenv.env['GOOGLE_SHEETS_DATA']!);
Expand Down

0 comments on commit ee8cd37

Please sign in to comment.