thumbnailFile method
Where the picture at uri is cached.
Implementation
File thumbnailFile(Uri uri) {
final name = uri.pathSegments.isEmpty ? '' : uri.pathSegments.last;
final dot = name.lastIndexOf('.');
final ext = dot < 0 ? 'img' : name.substring(dot + 1).toLowerCase();
final safeExt = RegExp(r'^[a-z0-9]{1,5}$').hasMatch(ext) ? ext : 'img';
return File(
'$dir/thumbnails/${Sha256.hexOf('$uri'.codeUnits).substring(0, 32)}.$safeExt',
);
}