Git Product home page Git Product logo

flutter_svg_provider's People

Contributors

abdifatahmuse avatar alyyasser avatar andreasgangso avatar anwar907 avatar blazer82 avatar devhammed avatar josephnglynn avatar knupper avatar meatysoda avatar nyan274 avatar pin73 avatar ruerob avatar suutaku avatar xuelongqy avatar yang-f avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flutter_svg_provider's Issues

could you add a beta channel version please?

Hello!

i need to develop an app also as webapp, thus i need to be in beta channel, and there i have to use
flutter_svg: ^0.20.0-nullsafety.3....
i f you could kindly do a version that works with that library?
thanks in advance

Please support [http] v1

Hi, the current google_fonts package requires http v1.0.0 which causes this error.

Resolving dependencies...
Because flutter_svg_provider 1.0.3 depends on http ^0.13.4 and no versions of flutter_svg_provider match >1.0.3 <2.0.0, flutter_svg_provider ^1.0.3 requires http ^0.13.4.

If possible, please upgrade.

Bump "flutter_svg" dependency

The flutter_svg library has had a major new 2.0 version since Feb. 2.

It'd be great if flutter_svg_provider was updated to use this new version.

Unexpected extension byte (at offset 0) when reopen the apps after closing on emulator

Hello, my app is crashed when i reopen the app after i manually close it on the emulator when the debugger still connected. the error are

The following FormatException was thrown resolving a single-frame image stream:
Unexpected extension byte (at offset 0)
When the exception was thrown, this was the stack
#0      _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1789:7)
#1      Utf8Decoder.convert (dart:convert/utf.dart:351:42)
#2      Utf8Codec.decode (dart:convert/utf.dart:63:20)
#3      AssetBundle.loadString
package:flutter/…/services/asset_bundle.dart:78
<asynchronous suspension>
#4      Svg._getSvgString
package:flutter_svg_provider/flutter_svg_provider.dart:88
<asynchronous suspension>
#5      Svg._loadAsync
package:flutter_svg_provider/flutter_svg_provider.dart:95
<asynchronous suspension>
════════════════════════════════════════════════════════════════════════════════

Here is my Code

BlocBuilder<HomeCubit, HomeState>(
  builder: (context, state) {
    return BottomNavigationBar(
      type: BottomNavigationBarType.fixed,
      selectedIconTheme: theme.iconTheme,
      selectedItemColor: theme.primaryColor,
      currentIndex: state.index,
      showUnselectedLabels: false,
      items: const [
        BottomNavigationBarItem(
          icon: ImageIcon(Svg('lib/assets/icons/home.svg')),
          label: 'Home',
        ),
        BottomNavigationBarItem(
          icon: ImageIcon(Svg('lib/assets/icons/kenalsaham.svg')),
          label: 'Kenal Saham',
        ),
        BottomNavigationBarItem(
          icon: ImageIcon(Svg('lib/assets/icons/ceksaham.svg')),
          label: 'Cek Saham',
        ),
        // BottomNavigationBarItem(
        //   icon: ImageIcon(
        //       AssetImage('lib/assets/icons/forumdiskusi.png')),
        //   label: 'Forum Diskusi',
        // ),
      ],
      onTap: (index) {
        if (index == 0) {
          BlocProvider.of<HomeCubit>(context)
              .getNavBarItem(HomeItem.home);
        } else if (index == 1) {
          BlocProvider.of<HomeCubit>(context)
              .getNavBarItem(HomeItem.kenal);
        } else if (index == 2) {
          BlocProvider.of<HomeCubit>(context)
              .getNavBarItem(HomeItem.cek);
        }
      },
    );
  },
),
body: BlocBuilder<HomeCubit, HomeState>(builder: (context, state) {
  if (state.navbarItem == HomeItem.home) {
    return const _HomeScreen();
  } else if (state.navbarItem == HomeItem.kenal) {
    return const SahamKenal();
  } else if (state.navbarItem == HomeItem.cek) {
    // return const SahamCek();
  }
  return Container();
})

Build error with 0.1.11

% fvm flutter doctor   
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on macOS 12.0.1 21A559 darwin-x64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0-rc1)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.62.3)
[✓] Connected device (2 available)

This is the error:

: Error: Type 'AssetBundle' not found.
../…/lib/svg.dart:325
    AssetBundle? bundle,
    ^^^^^^^^^^^
: Error: 'AssetBundle' isn't a type.
../…/lib/svg.dart:325
    AssetBundle? bundle,
    ^^^^^^^^^^^

Specifically with these versions:

flutter_svg:
    dependency: transitive
    description:
      name: flutter_svg
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.23.0+1"
  flutter_svg_provider:
    dependency: "direct main"
    description:
      name: flutter_svg_provider
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.1.11"

run error

Launching lib\main.dart on JNY AL10 in debug mode...
lib\main.dart:1
/D:/env/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_svg-0.23.0+1/lib/svg.dart:325:5: Error: Type 'AssetBundle' not found.
AssetBundle? bundle,
^^^^^^^^^^^
/D:/env/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_svg-0.23.0+1/lib/svg.dart:325:5: Error: 'AssetBundle' isn't a type.
AssetBundle? bundle,
^^^^^^^^^^^
2

FAILURE: Build failed with an exception.

  • Where:
    Script 'D:\env\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035

  • What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command 'D:\env\flutter\bin\flutter.bat'' finished with non-zero exit value 1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 25s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

svg file from cached image not working

i was trying to load svg from cached data, and I'm using flutter_cache_manager.

here is my demo code,

Image(
  width: 32,
  height: 32,
  image: Svg(svgCach.path),
)

but it show some error

======== Exception caught by image resource service ================================================
The following assertion was thrown resolving a single-frame image stream:
Unable to load asset: "/data/user/0/com.example.example/cache/libCachedImageData/5d7b41a0-2869-11ee-8a7c-19fa185feb9e.svg".

Update to work with the latest flutter_svg 0.19.1

Because flutter_svg_provider 0.1.6 depends on flutter_svg ^0.18.0 and no versions of flutter_svg_provider match >0.1.6 <0.2.0, flutter_svg_provider ^0.1.6 requires flutter_svg ^0.18.0.
So, because xxx depends on both flutter_svg ^0.19.1 and flutter_svg_provider ^0.1.6, version solving failed.
pub get failed (1; So, because xxx depends on both flutter_svg ^0.19.1 and flutter_svg_provider ^0.1.6, version solving failed.)

Transparency

Is there anyway to have Svg() respect the transparency values in the SVG file?

Example:

  <path
     d="M 368,-4.7517545e-13 L 0,-4.7517545e-13 L 0,368 L 368,368 L 368,-4.7517545e-13 z"
     id="path4"
     style="opacity:1;fill:transparent;stroke:transparent;stroke-width:0.09375" />

I tried the current 0.1.9 version and I got white instead of transparent.

SVG image clarity dual

import 'package:flutter_svg_provider/flutter_svg_provider.dart' as svg_provider;


Container(
          height: double.maxFinite,
           width: double.maxFinite,
          decoration: const BoxDecoration(
            image: DecorationImage(
              //  opacity: 0.7,
                image: svg_provider.Svg(
                  "assets/icons/background_pattern.svg",
                  size: Size.square(40),
                ),
                repeat: ImageRepeat.repeat,
                fit: BoxFit.none)
          ),
        ),

svg_error

Problem with scaling since flutter_svg 2.0

Hi,

With flutter_svg 2.0+ we've lost the .toPicture, and its size method. This poses a problem when upscaling images, as the scale is not good (upscaled images can be blurred/pixelated). The problem has been discussed here dnfield/flutter_svg#858

To get around this, I had to do the following:

  static Future<ImageInfo> _loadAsync(SvgImageKey key) async {
    final String rawSvg = await _getSvgString(key);
    final pictureInfo = await vg.loadPicture(
      SvgStringLoader(rawSvg),
      null,
      clipViewbox: false,
    );

    final ui.PictureRecorder recorder = ui.PictureRecorder();
    final ui.Canvas canvas = ui.Canvas(recorder);

    canvas.scale(key.pixelWidth / pictureInfo.size.width, key.pixelHeight / pictureInfo.size.height);
    canvas.drawPicture(pictureInfo.picture);
    final ui.Picture scaledPicture = recorder.endRecording();

    final image = await scaledPicture.toImage(key.pixelWidth, key.pixelHeight);

    return ImageInfo(
      image: image,
      scale: 1.0,
    );
  }

I tried to manipulate all the other methods scale, size, ... without success, only this fix solved my problem.

Is there a better solution?

flutter 3.16 not working

After upgrading to Flutter 3.16 I can't get any images created with the Svg constructor to display.

Add Null safety version

This package has a dependency on flutter_svg: ^0.19.0. Please provide a null safe version and have it depend on the null safe version of flutter_svg

Color should be part of SvgImageKey

The same image is provided by the library when you change only the color property. This is because color is incorrectly not part of the == (equals) method of SvgImageKey.

return other is SvgImageKey &&

    return other is SvgImageKey &&
        other.path == path &&
        other.pixelWidth == pixelWidth &&
        other.pixelHeight == pixelHeight &&
        other.scale == scale &&
        other.source == source &&
        other.svgGetter == svgGetter;

This leads to bugs such as the provider not providing an updated image when your theme updates (such as when enabling dark/light mode) and your image only changes the svg's applied color. For example:

        image: DecorationImage(
          image: SvgProvider(
            "assets/somewhere/in/my/app/some_grpahic.svg",
            color: inDarkTheme ? Colors.grey.shade800 : Colors.grey.shade200,
          ),
        ),

Add support for loading from memory

flutter_svg supports loading from memory like

SvgPicture.memory(
                     Base64Decoder().convert(
                     "BASE64STRING")
);

Please support this behaviour.

Add <style> element

Hey :) First of all, good work!

I have the issue that a specific .svg can't be rendered correctly:

══╡ EXCEPTION CAUGHT BY SVG ╞═══════════════════════════════════════════════════════════════════════
The following UnimplementedError was thrown in parseSvgElement:
The <style> element is not implemented in this library.

Style elements are not supported by this library and the requested SVG may not render as intended.
If possible, ensure the SVG uses inline styles and/or attributes (which are supported), or use a
preprocessing utility such as svgcleaner to inline the styles for you.

Picture key: /usr/share/icons/hicolor/scalable/apps/thunderbird.svg
════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: unhandled element filter; Picture key: /usr/share/icons/hicolor/scalable/apps/thunderbird.svg

The rendered output:
image

The file to render:
thunderbird

So my proposal would be, to add the implementation for the <style> element.

How to preload

How to preload a SVG showed as following?

Container(
  child: DecoratedBox(
    decoration: BoxDecoration(
      image: DecorationImage(
        repeat: ImageRepeat.repeat,
        image: svg_provider.Svg(
          "assets/test.png",
          size: Size(200, 200),
        ),
        colorFilter: ColorFilter.mode(
          Colors.black12,
          BlendMode.srcIn,
        ),
      ),
    ),
    child: Container(),
  ),
),

I tried with this one but it does not preload the SVG.

precachePicture(
  ExactAssetPicture(SvgPicture.svgStringDecoderBuilder, "assets/test.png"),
  null,
);

After the SVG is showed once, then it's always fast to show up.

Could you add web support to this project? Thank you! 您可以在这个项目中添加对于web的支持吗?谢谢!

As we know, the web of flutter has been updated to the beta version. At the same time, many developers like me are trying to add web support to the original project recently. However, the SVG image does not work on the web side. I have been looking for a way to load the SVG image on the web, but I cannot find a solution. So I want to ask you for help, thank you!

鉴于我们知道,flutter的web已经更新到beta版本了,同时很多像我一样的开发者最近也在尝试将原有的项目添加web支持,但是svg格式的图片却在web端是不生效的,我一直在寻找web加载svg图片的方式,但是找不到解决方案。所以想来向你求助,谢谢!

SvgSource.file not working for me

im trying to create a imageProvider for container. and i need to pass svg code directly. so i tried like this

Svg(
            '<svg .....> </svg>',
            source: SvgSource.file,
          )

but for some reason its not working

SVG image gets pixelated when using with PhotoView

While using this package with PhotoView package as follows and then we zoom in a little, the SVG image gets pixelated.

PhotoView( imageProvider: Svg("assets/1223-1920x1080.svg"), ),

The image is proper and confirmed that it can zoom without pixelated using external tool. To further identify problematic part, used the following code. flutter_svg was used in place of flutter_svg_provider.

Transform.scale( scale: 30, child: SvgPicture.asset('assets/1223-1920x1080.svg'), )

This time the image did not pixelate this time.

Blurred SVG problem

Is there a process here to convert the SVG file to an image file. Because in some SVG files the image is blurred.

suspect wrong color filter mode

I had a problem when using the color property to re-color the image and found changing the blend mode from srcATop to srcIn fix the problem for me. Is this a bug?

if use color

Container(
  decoration: const BoxDecoration(
    image: DecorationImage(
      image: Svg(
        'assets/grid.svg', 
        size: Size.square(40), 
        color: Colors.black12,
      ),
      repeat: ImageRepeat.repeat,
    ),
  ),
  child: Center(child: Text("Hello", style: TextStyle(fontSize: 80))),
)

image

if change it to srcIn

Container(
  decoration: const BoxDecoration(
    image: DecorationImage(
      image: Svg('assets/grid.svg', size: Size.square(40)),
      repeat: ImageRepeat.repeat,
      colorFilter: ColorFilter.mode(Colors.black12, BlendMode.srcIn),
    ),
  ),
  child: Center(child: Text("Hello", style: TextStyle(fontSize: 80))),
)

image

Respect parent size bugued ?

Hi,

I have seen this :

final double logicWidth = size?.width ?? configuration.size?.width ?? 100;
final double logicHeight = size?.height ?? configuration.size?.width ?? 100;

The logic height is binded on parent with, not height :)

flutter_svg on version 1.0.1 on current release

Hello!

On the current release on pub.dev, the dependency flutter_svg is currently at version 1.0.1. It looks like the dependency on master for flutter_svg is 2.0.2.

Would you make a new release with the updated dependency please? It's necessary in order to upgrade to Dart 3.

Thanks for all your hard work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.