Skip to content

Commit d08adcb

Browse files
authored
Merge branch 'master' into master
2 parents dfbf270 + 700a201 commit d08adcb

8 files changed

Lines changed: 176 additions & 78 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Flutter Tests
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
flutter-tests:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Flutter
22+
uses: subosito/flutter-action@v2
23+
with:
24+
channel: stable
25+
cache: true
26+
cache-key: flutter-${{ hashFiles('**/pubspec.lock') }}
27+
cache-path: ${{ runner.tool_cache }}/flutter
28+
29+
- name: Show Flutter version
30+
run: flutter --version
31+
32+
- name: Get dependencies
33+
run: flutter pub get
34+
35+
- name: Run tests with coverage
36+
run: flutter test --coverage
37+
38+
- name: Upload coverage artifact
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: coverage-report
42+
path: coverage/lcov.info
43+
if-no-files-found: warn

example/pubspec.lock

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,26 @@ packages:
2121
dependency: transitive
2222
description:
2323
name: characters
24-
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
24+
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
2525
url: "https://pub.dev"
2626
source: hosted
27-
version: "1.3.0"
27+
version: "1.4.0"
2828
clock:
2929
dependency: transitive
3030
description:
3131
name: clock
32-
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
32+
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
3333
url: "https://pub.dev"
3434
source: hosted
35-
version: "1.1.1"
35+
version: "1.1.2"
3636
collection:
3737
dependency: transitive
3838
description:
3939
name: collection
40-
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
40+
sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
4141
url: "https://pub.dev"
4242
source: hosted
43-
version: "1.18.0"
43+
version: "1.19.1"
4444
cupertino_icons:
4545
dependency: "direct main"
4646
description:
@@ -53,10 +53,10 @@ packages:
5353
dependency: transitive
5454
description:
5555
name: fake_async
56-
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
56+
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
5757
url: "https://pub.dev"
5858
source: hosted
59-
version: "1.3.1"
59+
version: "1.3.3"
6060
flutter:
6161
dependency: "direct main"
6262
description: flutter
@@ -86,26 +86,26 @@ packages:
8686
dependency: transitive
8787
description:
8888
name: leak_tracker
89-
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
89+
sha256: "8dcda04c3fc16c14f48a7bb586d4be1f0d1572731b6d81d51772ef47c02081e0"
9090
url: "https://pub.dev"
9191
source: hosted
92-
version: "10.0.5"
92+
version: "11.0.1"
9393
leak_tracker_flutter_testing:
9494
dependency: transitive
9595
description:
9696
name: leak_tracker_flutter_testing
97-
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
97+
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
9898
url: "https://pub.dev"
9999
source: hosted
100-
version: "3.0.5"
100+
version: "3.0.10"
101101
leak_tracker_testing:
102102
dependency: transitive
103103
description:
104104
name: leak_tracker_testing
105-
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
105+
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
106106
url: "https://pub.dev"
107107
source: hosted
108-
version: "3.0.1"
108+
version: "3.0.2"
109109
lints:
110110
dependency: transitive
111111
description:
@@ -118,10 +118,10 @@ packages:
118118
dependency: transitive
119119
description:
120120
name: matcher
121-
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
121+
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
122122
url: "https://pub.dev"
123123
source: hosted
124-
version: "0.12.16+1"
124+
version: "0.12.17"
125125
material_color_utilities:
126126
dependency: transitive
127127
description:
@@ -134,23 +134,23 @@ packages:
134134
dependency: transitive
135135
description:
136136
name: meta
137-
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
137+
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
138138
url: "https://pub.dev"
139139
source: hosted
140-
version: "1.15.0"
140+
version: "1.16.0"
141141
path:
142142
dependency: transitive
143143
description:
144144
name: path
145-
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
145+
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
146146
url: "https://pub.dev"
147147
source: hosted
148-
version: "1.9.0"
148+
version: "1.9.1"
149149
sky_engine:
150150
dependency: transitive
151151
description: flutter
152152
source: sdk
153-
version: "0.0.99"
153+
version: "0.0.0"
154154
source_span:
155155
dependency: transitive
156156
description:
@@ -163,18 +163,18 @@ packages:
163163
dependency: transitive
164164
description:
165165
name: stack_trace
166-
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
166+
sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
167167
url: "https://pub.dev"
168168
source: hosted
169-
version: "1.11.1"
169+
version: "1.12.1"
170170
stream_channel:
171171
dependency: transitive
172172
description:
173173
name: stream_channel
174-
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
174+
sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
175175
url: "https://pub.dev"
176176
source: hosted
177-
version: "2.1.2"
177+
version: "2.1.4"
178178
string_scanner:
179179
dependency: transitive
180180
description:
@@ -195,18 +195,18 @@ packages:
195195
dependency: transitive
196196
description:
197197
name: test_api
198-
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
198+
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
199199
url: "https://pub.dev"
200200
source: hosted
201-
version: "0.7.2"
201+
version: "0.7.6"
202202
vector_math:
203203
dependency: transitive
204204
description:
205205
name: vector_math
206-
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
206+
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
207207
url: "https://pub.dev"
208208
source: hosted
209-
version: "2.1.4"
209+
version: "2.2.0"
210210
vm_service:
211211
dependency: transitive
212212
description:
@@ -216,5 +216,5 @@ packages:
216216
source: hosted
217217
version: "14.2.5"
218218
sdks:
219-
dart: ">=3.5.3 <4.0.0"
219+
dart: ">=3.8.0-0 <4.0.0"
220220
flutter: ">=3.18.0-18.0.pre.54"

lib/src/dotenv.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,13 @@ class DotEnv {
130130
linesFromFile = await _getEntriesFromFile(fileName);
131131
linesFromOverrides = await _getLinesFromOverride(overrideWith);
132132
} on FileNotFoundError {
133-
if (isOptional) {
134-
linesFromFile = [];
135-
linesFromOverrides = [];
136-
} else {
137-
rethrow;
138-
}
133+
if (!isOptional) rethrow;
134+
linesFromFile = [];
135+
linesFromOverrides = [];
136+
} on EmptyEnvFileError {
137+
if (!isOptional) rethrow;
138+
linesFromFile = [];
139+
linesFromOverrides = [];
139140
}
140141

141142
final linesFromMergeWith = mergeWith.entries
@@ -149,20 +150,22 @@ class DotEnv {
149150
_isInitialized = true;
150151
}
151152

152-
void testLoad({
153-
String fileInput = '',
153+
void loadFromString({
154+
String envString = '',
155+
List<String> overrideWith = const [],
154156
Parser parser = const Parser(),
155157
Map<String, String> mergeWith = const {},
156-
List<String> overrideWith = const [],
158+
bool isOptional = false,
157159
}) {
158160
clean();
159-
final linesFromFile = fileInput.split('\n');
160-
161+
if (envString.isEmpty && !isOptional) {
162+
throw EmptyEnvFileError();
163+
}
164+
final linesFromFile = envString.split('\n');
161165
final linesFromOverrides = overrideWith
162166
.map((String lines) => lines.split('\n'))
163167
.expand((x) => x)
164168
.toList();
165-
166169
final linesFromMergeWith = mergeWith.entries
167170
.map((entry) => "${entry.key}=${entry.value}")
168171
.toList();

0 commit comments

Comments
 (0)