mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-27 00:15:26 -04:00
lint work
This commit is contained in:
parent
9e4008214d
commit
6e8725f569
43 changed files with 257 additions and 332 deletions
|
@ -1,34 +1,22 @@
|
|||
import 'dart:typed_data';
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
T jsonDecodeBytes<T>(
|
||||
T Function(Map<String, dynamic>) fromJson, Uint8List data) {
|
||||
return fromJson(jsonDecode(utf8.decode(data)));
|
||||
}
|
||||
T Function(Map<String, dynamic>) fromJson, Uint8List data) => fromJson(jsonDecode(utf8.decode(data)));
|
||||
|
||||
Uint8List jsonEncodeBytes(Object? object,
|
||||
{Object? Function(Object?)? toEncodable}) {
|
||||
return Uint8List.fromList(
|
||||
{Object? Function(Object?)? toEncodable}) => Uint8List.fromList(
|
||||
utf8.encode(jsonEncode(object, toEncodable: toEncodable)));
|
||||
}
|
||||
|
||||
Future<Uint8List> jsonUpdateBytes<T>(T Function(Map<String, dynamic>) fromJson,
|
||||
Uint8List oldBytes, Future<T> Function(T) update) async {
|
||||
T oldObj = fromJson(jsonDecode(utf8.decode(oldBytes)));
|
||||
T newObj = await update(oldObj);
|
||||
final oldObj = fromJson(jsonDecode(utf8.decode(oldBytes)));
|
||||
final newObj = await update(oldObj);
|
||||
return jsonEncodeBytes(newObj);
|
||||
}
|
||||
|
||||
Future<Uint8List> Function(Uint8List) jsonUpdate<T>(
|
||||
T Function(Map<String, dynamic>) fromJson, Future<T> Function(T) update) {
|
||||
return (Uint8List oldBytes) {
|
||||
return jsonUpdateBytes(fromJson, oldBytes, update);
|
||||
};
|
||||
}
|
||||
T Function(Map<String, dynamic>) fromJson, Future<T> Function(T) update) => (oldBytes) => jsonUpdateBytes(fromJson, oldBytes, update);
|
||||
|
||||
T Function(Object?) genericFromJson<T>(
|
||||
T Function(Map<String, dynamic>) fromJsonMap) {
|
||||
return (Object? json) {
|
||||
return fromJsonMap(json as Map<String, dynamic>);
|
||||
};
|
||||
}
|
||||
T Function(Map<String, dynamic>) fromJsonMap) => (json) => fromJsonMap(json as Map<String, dynamic>);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue