getTestUri method

Uri getTestUri(
  1. Uri key,
  2. int? version

Returns a new golden file Uri to incorporate any version number with the key.

The version is an optional int that can be used to differentiate historical golden files.

Version numbers are used in golden file tests for package:flutter. You can learn more about these tests here.


Uri getTestUri(Uri key, int? version) {
  if (version == null) {
    return key;
  final String keyString = key.toString();
  final String extension = path.extension(keyString);
  return Uri.parse('${keyString.split(extension).join()}.$version$extension');