client static method
Prisma development environment client.
Implementation
static client({
required PrismaEnvironment environment,
required String encoded,
}) {
final Iterable<String> lines = encoded
.split(RegExp(r'\r?\n'))
.map((e) => e.trim())
.toList()
..removeWhere((element) => element.isEmpty);
final List<String> encodeds = <String>[];
final Iterator<String> iterator = lines.iterator;
String? current;
while (iterator.moveNext()) {
if (iterator.current == _start) {
current = '';
} else if (current != null && iterator.current == _end) {
encodeds.add(current.trim());
current = null;
} else if (current != null) {
current += iterator.current.trim();
}
}
for (final String encoded in encodeds) {
final Map<String, String?> decoded =
(json.decode(utf8.decode(base64.decode(encoded))) as Map)
.cast<String, String?>();
for (final MapEntry<String, String?> entry in decoded.entries) {
if (entry.value == null) {
environment.remove(entry.key);
continue;
}
environment[entry.key] = entry.value!;
}
}
}