feat(proj): init

This commit is contained in:
vl.arkhangelskii
2026-09-21 04:06:43 +03:00
commit c956b94983
1076 changed files with 50876 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
/// Minimal `.env` parser (KEY=VALUE, `#` comments, optional quotes).
///
/// Kept tiny and dependency-free so config loading is easy to test and does
/// not pull `flutter_dotenv` into the production graph.
Map<String, String> parseEnvFile(String source) {
final values = <String, String>{};
for (final raw in source.split(RegExp(r'\r?\n'))) {
final line = raw.trim();
if (line.isEmpty || line.startsWith('#')) continue;
final separator = line.indexOf('=');
if (separator <= 0) continue;
final key = line.substring(0, separator).trim();
if (key.isEmpty) continue;
var value = line.substring(separator + 1).trim();
if (value.length >= 2) {
final quote = value[0];
if ((quote == '"' || quote == "'") && value.endsWith(quote)) {
value = value.substring(1, value.length - 1);
}
}
values[key] = value;
}
return values;
}
String normalizeUrl(String url) => url.trim().replaceAll(RegExp(r'/$'), '');
bool parseEnvFlag(String? raw, {bool fallback = false}) {
if (raw == null || raw.trim().isEmpty) return fallback;
return switch (raw.trim().toLowerCase()) {
'1' || 'true' || 'yes' || 'on' => true,
'0' || 'false' || 'no' || 'off' => false,
_ => fallback,
};
}