Is it possible to use 1password CLI with Flutter to load env file?

akelton
akelton
Community Member

I'm trying to see if I can replace my env file values with op url calls, per https://developer.1password.com/docs/cli/secrets-environment-variables#use-environment-env-files

To get the standard flutter run to pick up the value stored in 1pass, I'm running op run --env-file="./.env" -- flutter run

But I think Dart only allows url schemes http and https because I'm getting the following error:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: OperationException(linkException: ServerException(originalException: Invalid argument(s): Unsupported scheme 'op' in URI op://vault/item/section/label, originalStackTrace: #0      _HttpClient._openUrl (dart:_http/http_impl.dart:2698:9)
#1      _HttpClient.openUrl (dart:_http/http_impl.dart:2591:7)
#2      DatadogTrackingHttpClient._openUrl (package:datadog_tracking_http_client/src/tracking_http_client.dart:127:35)
#3      DatadogTrackingHttpClient.openUrl (package:datadog_tracking_http_client/src/tracking_http_client.dart:261:7)
#4      IOClient.send (package:http/src/io_client.dart:57:38)
#5      HttpLink._executeRequest (package:gql_http_link/src/link.dart:131:43)
#6      HttpLink.request (package:gql_http_link/src/link.dart:76:32)

Here's the Dart source code that says they'll only honor http and https: https://github.com/dart-lang/sdk/blob/main/sdk/lib/_http/http_impl.dart#L2747

Is there another way run a Flutter app so that it can pick up the env vars via 1pass? If not, is the only way through to open a PR with Dart requesting that they support the "op" scheme?


1Password Version: 2.13.1
Extension Version: Not Provided
OS Version: macOS 12.6.1
Browser:_ Not Provided
Referrer: forum-search:flutter

This discussion has been closed.