yang-f / flutter_svg_provider Goto Github PK
View Code? Open in Web Editor NEWUse svg as image provider.
Home Page: https://pub.dev/packages/flutter_svg_provider
License: Apache License 2.0
Use svg as image provider.
Home Page: https://pub.dev/packages/flutter_svg_provider
License: Apache License 2.0
its hurting our updates
Please add a Nullsafety version
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
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.
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.
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();
})
% 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"
Hello. There is some plans for migrate plugin to null-safety?
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)
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".
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.)
Android Gradle is not updated
Hi ,
After upgrade flutter to 3.16.5 from 3.13.9 , the SVGs not displaying anymore .
was working perfectly in 3.13.9.
Thank you .
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(<flie path to svg>, size: Size(10,10))
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)
),
),
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?
After upgrading to Flutter 3.16 I can't get any images created with the Svg constructor to display.
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
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 &&
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,
),
),
flutter_svg supports loading from memory like
SvgPicture.memory(
Base64Decoder().convert(
"BASE64STRING")
);
Please support this behaviour.
That means this can only be imported using the GitHub link. Also releasing this would increase visibility :)
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 file to render:
thunderbird
So my proposal would be, to add the implementation for the <style> element.
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.
Should support the "package" parameter, so you can do e.g.
Svg(
'some-asset.svg',
package: 'some_third_party_package',
),
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图片的方式,但是找不到解决方案。所以想来向你求助,谢谢!
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
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.
Is there a process here to convert the SVG file to an image file. Because in some SVG files the image is blurred.
I think it would be a great idea to upstream this work directly into the flutter_svg
package.
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))),
)
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))),
)
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 :)
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!
its cauing speed issues, also please upgrade the package on pub.dev
Please upgrade all dependencies including http
thanks for the great work!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.