java-james / flutter_dotenv

Loads environment variables from `.env`.
https://pub.dartlang.org/packages/flutter_dotenv
MIT License
209 stars 46 forks source link

When Flutter app in background, env file data not importing #61

Open SamarpanCoder2002 opened 2 years ago

SamarpanCoder2002 commented 2 years ago
static Key _key =
      Key.fromBase64(DataManagement.getEnvData(EnvFileKey.encryptKey) ?? '');

That's how I am importing env file data(encryptKey in this case). It works fine normally but does not import data while the app is in the background.

If possible, please fix this.

FlawLessx commented 1 year ago

because background service is creating separate isolate from flutter app, you need to initialize first on your background service function, example: await dotenv.load(fileName: ".env");