Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Web] can't compile because of fake File #1059

Open
richert-addisca opened this issue Apr 19, 2024 · 2 comments
Open

[Web] can't compile because of fake File #1059

richert-addisca opened this issue Apr 19, 2024 · 2 comments

Comments

@richert-addisca
Copy link

When I use a dart:io File type in the same dart file as SvgPicture.file on the web, it won't compile saying the types are not compatible.

When I remove the if condition in \flutter_svg-2.0.10+1\lib\src\utilities\file.dart locally, everything compiles and works as expected.

This even happens when doing an early return for web.

if (kIsWeb) {
  return SvgPicture.network(
    imageUrl!,
  );
}

ref.watch(imageToFileProvider);
File? file = ref.watch(imageToFileProvider.notifier).getFile(imageUrl!);

if (file == null) {
  return svgPlaceholder(context);
}

return 
  (imageUrl!.contains(".svg") || file.path.endsWith('.svg'))
    ? SvgPicture.file(
      file,
    )
    : RoundedContainer(
      borderRadius: borderRadius,
        child: Image.file(
          file,
        ),
      );
@GVAMDaniel
Copy link

Same error here

My appFile.file seems to be the same class File but when I try to compile this error appear

Captura de pantalla 2024-05-09 a las 14 27 53

The temporary solution is to load as SvgBytesLoader

SvgBytesLoader(appFile.file!.readAsBytesSync())

@sinhpn92
Copy link

sinhpn92 commented Oct 18, 2024

I have the same issue. Did you solve this issue @richert-addisca ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants