loadFrom static method

Future<TouchBarImage> loadFrom({
  1. required String path,
  2. String? key,
})

Create an instance of TouchBarImage from an asset path with a key.

path must have the same value defined in the pubspec. Example:

in pubspec.yaml:

assets:
  - assets/icons/myIcon.png

in the Flutter code:

TouchBarImage(icon: 'assets/icons/myIcon.png')

key must be unique, if none is provided the path will be used as the key value.

Implementation

static Future<TouchBarImage> loadFrom({
  required String path,
  String? key,
}) async {
  assert(path.isNotEmpty);
  if (key == null) key = path;

  ByteData data = await rootBundle.load(path);
  return TouchBarImage(key: key, data: data);
}