Skip to content

Commit

Permalink
🚨 Fix FormData lints
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Apr 14, 2024
1 parent 8484e9a commit 6c5f647
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions dio/lib/src/form_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,9 @@ class FormData {

final controller = StreamController<Uint8List>(sync: false);

void writeUtf8(String s) {
final encoded = utf8.encode(s);
controller.add(
encoded is Uint8List ? encoded : Uint8List.fromList(encoded),
);
}

void writeLine() => controller.add(_rnU8); // \r\n
void writeUtf8(String s) =>
controller.add(_effectiveU8Encoding(utf8.encode(s)));

for (final entry in fields) {
writeUtf8('--$boundary$_rn');
Expand Down Expand Up @@ -222,3 +217,7 @@ class FormData {
return clone;
}
}

Uint8List _effectiveU8Encoding(List<int> encoded) {
return encoded is Uint8List ? encoded : Uint8List.fromList(encoded);
}

0 comments on commit 6c5f647

Please sign in to comment.