Skip to content

Commit 12f3989

Browse files
committed
ci: add GitHub Actions workflow and CONTRIBUTING.md
1 parent 2e8f30d commit 12f3989

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

example/flutter_secure_dotenv_generator_example.dart

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,28 @@ import 'package:flutter_secure_dotenv/flutter_secure_dotenv.dart';
22

33
part 'env.g.dart';
44

5-
@DotEnvGen(
6-
filename: '.env',
7-
fieldRename: FieldRename.screamingSnake,
8-
)
5+
/// Example using the "Hardcoded Key + Gitignore" pattern.
6+
///
7+
/// This file (env.dart) is GITIGNORED. A template `env.example.dart` with
8+
/// placeholder values is committed instead. See SECURITY.md in
9+
/// flutter_secure_dotenv for details.
10+
11+
@DotEnvGen(filename: '.env', fieldRename: FieldRename.screamingSnake)
912
abstract class Env {
10-
static Env create() {
11-
String encryptionKey = const String.fromEnvironment(
12-
"APP_ENCRYPTION_KEY"); // On build, change with your generated encryption key (use dart-define for String.fromEnvironment)
13-
String iv = const String.fromEnvironment(
14-
"APP_IV_KEY"); // On build, change with your generated iv (use dart-define for String.fromEnvironment)
15-
return Env(encryptionKey, iv);
16-
}
13+
// These values come from the temporary encryption_key.json generated by
14+
// build_runner. Copy them here, then delete the JSON file.
15+
static const _encryptionKey = 'YOUR_BASE64_ENCRYPTION_KEY';
16+
static const _iv = 'YOUR_BASE64_IV';
17+
18+
static Env create() => Env(_encryptionKey, _iv);
1719

1820
const factory Env(String encryptionKey, String iv) = _$Env;
1921

2022
const Env._();
2123

22-
@FieldKey(defaultValue: "")
24+
@FieldKey(defaultValue: '')
2325
String get apiBaseUrl;
2426

25-
@FieldKey(defaultValue: "")
27+
@FieldKey(defaultValue: '')
2628
String get apiWebSocketUrl;
2729
}

0 commit comments

Comments
 (0)