loadSegmentImages<T> function
Future<List<WheelSegment<T> > >
loadSegmentImages<T>(
- List<
WheelSegment< segments, {T> > - ImageConfiguration configuration = ImageConfiguration.empty,
Loads icons for every WheelSegment that still needs one (see WheelSegment.needsImageLoad). Images are loaded in parallel.
Returns a list of the same length and order as segments. Segments whose
image failed to load, or that need no loading, are returned unchanged.
Any image in the result that is not identical to the input segment's
image was created here, and the caller is responsible for disposing it.
Implementation
Future<List<WheelSegment<T>>> loadSegmentImages<T>(
List<WheelSegment<T>> segments, {
ImageConfiguration configuration = ImageConfiguration.empty,
}) {
return Future.wait(segments.map((segment) async {
if (!segment.needsImageLoad) return segment;
try {
final ui.Image image =
await loadSegmentImage(segment, configuration: configuration);
return segment.copyWith(image: image);
} catch (e) {
debugPrint('Error loading image for segment ${segment.label}: $e');
return segment;
}
}));
}