flutter_dotenv icon indicating copy to clipboard operation
flutter_dotenv copied to clipboard

Env file not readable in an isolate

Open ciprianteletin opened this issue 1 year ago • 0 comments

Hi, currently I am running flutter_dotenv 5.1.0, with dart --version 3.1.5 Inside my isolate code, I am calling dotenv.load(file) since I need in my process some of the environment variables defined in the file. The error does not appear if I remove the dotenv.load(file) call from the isolate.

The error is the following:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: UI actions are only available on root isolate. #0 FfiTrampoline____nativeSetNeedsReportTimings$Method$FfiNative$Ptr (dart:ffi) #1 PlatformDispatcher.__nativeSetNeedsReportTimings (dart:ui/platform_dispatcher.dart:588:24) #2 PlatformDispatcher._nativeSetNeedsReportTimings (dart:ui/platform_dispatcher.dart:585:52) #3 PlatformDispatcher.onReportTimings= (dart:ui/platform_dispatcher.dart:577:29) #4 SchedulerBinding.addTimingsCallback (package:flutter/src/scheduler/binding.dart:308:26) #5 SchedulerBinding.initInstances (package:flutter/src/scheduler/binding.dart:240:7) #6 ServicesBinding.initInstances (package:flutter/src/services/binding.dart:37:11) #7 PaintingBinding.initInstances (package:flutter/src/painting/binding.dart:20:11) #8 SemanticsBinding.initInstances (package:flutter/src/semantics/binding.dart:18:11) #9 RendererBinding.initInstances (package:flutter/src/rendering/binding.dart:29:11)<…>

I see that the load method is calling WidgetsFlutterBinding.ensureInitialized() in the background which is causing the error from above.

ciprianteletin avatar Jul 04 '24 20:07 ciprianteletin