Skip to content

FileLottie never hit LottieCache. #412

@xiaochacha

Description

@xiaochacha

FileLottie never hit LottieCache, because FileLottie's hashCode() method return file.hashcode, not file.path.hashcode.

Image

class FileLottie extends LottieProvider {
FileLottie(
Object file, {
super.imageProviderFactory,
super.decoder,
super.backgroundLoading,
}) : file = file as io.File,
assert(
!kIsWeb,
'Lottie.file is not supported on Flutter Web. '
'Consider using either Lottie.asset or Lottie.network instead.',
);

final io.File file;

...

@OverRide
bool operator ==(Object other) {
if (other.runtimeType != runtimeType) return false;
return other is FileLottie && file.path == other.file.path;
}

@OverRide
int get hashCode => file.hashCode;

@OverRide
String toString() => '$runtimeType(file: ${file.path})';
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions