String to Uint8List function

This commit is contained in:
Ankit Mahato
2023-04-25 07:42:48 +05:30
parent c504d667c1
commit 1675e3530e

View File

@ -1,3 +1,5 @@
import 'dart:typed_data';
import 'dart:convert';
import '../consts.dart';
import 'package:apidash/models/models.dart' show KVRow;
@ -77,3 +79,13 @@ List<KVRow>? mapToRows(Map<String, String>? kvMap) {
}
return finalRows;
}
Uint8List? stringToBytes(String? text) {
if (text == null) {
return null;
} else {
var l = utf8.encode(text);
var bytes = Uint8List.fromList(l);
return bytes;
}
}