etag function
Create a simple ETag.
entity must be of either of type String, Uint8List, or FileStat type, if not a TypeError is thrown.
Implementation
String etag(dynamic entity, {bool? weak}) {
late final String tag;
late final bool isWeak;
if (entity is String || entity is Uint8List) {
isWeak = weak ?? false;
tag = _entitytag(entity);
} else if (entity is FileStat) {
isWeak = weak ?? true;
tag = _stattag(entity);
} else {
throw ArgumentError.value(entity,
'entity must be either of type String, Uint8List, or FileStat.');
}
return isWeak ? 'W/"$tag"' : '"$tag"';
}