Failed to find definition for url(#pattern0) : Flutter 2.8.1 - flutter

After upgrade flutter with null safe i'm facing this error
'assets/images/bg111.svg',
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
),```
Error:
════════ Exception caught by SVG ═══════════════════════════════════════════════
The following assertion was thrown while parsing AssetBundlePictureKey(bundle: PlatformAssetBundle#0293d(), name: "assets/images/bg111.svg", colorFilter: null) in _getDefinitionPaint:
Failed to find definition for url(#pattern0)

This occurs because you are using the element before defining it.
For me the solution was moving the entire defs tag and its content to immediately after the opening svg tag

Try below code hope its help to you. used flutter_svg: ^1.0.0 current version of svg dependency here.
Your widget:
SvgPicture.asset(
'assets/images/water.svg',
// height: MediaQuery.of(context).size.height,
// width: MediaQuery.of(context).size.width,
),
Your pubspec.yaml file
assets:
- assets/images/
Result screen->

As user #Mark Hardy said:
This arises in Android builds from a combination of:
Using compileSdkVersion 31,
With JDK8,
Having any Lambda style related code somewhere (else error may not happen).
The default android toolchains have moved to JDK11 now, you must use JDK11 when you change any of the Android API target versions from 30 to 31.
Semi duplicate of unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)

When using the Flutter SvgPicture package, I fall into the same problem.
I solve this issue by exporting the file from Figam as PDF and then converting the pdf file to SVG.
Here are the steps I follow:
Save as (.pdf) from Figma/Adobe XD.
Then go to Zamzar and convert the PDF file as SVG Image.
Use this image & Boom !!!
The problem is solved !!!

Bit late, but I had the same problem and fixed it by opening the svg and moving the ... to the top.

Related

Image.asset - flutter

When I try to use an image, the code gives me the following error:
But the code is working only with another image. When I try to use this one, it fails.
This is the code:
Center(
child: Image.asset(
'assets/perigo.png'),
)
Pubspeck.yaml file:
assets:
- assets/
check your image ("perigo.png") is correct, Type of image etc.
This work for me. try:
stop the running app and re-run it. (Not restart)
If it's not,
set your Pubspeck.yaml file like this,
assets:
- assets/perigo.png

Image from device path not shown

I have downloaded a file to getApplicationDocumentsDirectory().
Then I have inserted the file path to a SQLite database.
In this case the file is a png file, and I need to show it on a screen.
I am trying to do it as follows:
Container(color: Colors.grey[200],
child: Image.file(File(${snapshot.data![position].path})),
alignment: Alignment.center
)
I am geting an exception:
FileSystemException: Cannot open file, path=//var/mobile/Containers/Data/Application/B2663D60-9BEF-4FFF-9287-BFD3CE6EF8BE/Documents/AgdsBeviewlogomodesto.png
I have checked if the path from the downloaded file is equal to the path from the SQLite item value, and both are equal.
Downloaded file path print output:
flutter: path al archivo descargado /var/mobile/Containers/Data/Application/B2663D60-9BEF-4FFF-9287-BFD3CE6EF8BE/Documents/AgdsBeviewlogomodesto.png
SQLite path value :
path en docs: /var/mobile/Containers/Data/Application/B2663D60-9BEF-4FFF-9287-BFD3CE6EF8BE/Documents/AgdsBeviewlogomodesto.png
I have also tested putting that path as text directly into
Image.file(File("/var/mobile/Containers/Data/Application/B2663D60-9BEF-4FFF-9287-BFD3CE6EF8BE/Documents/AgdsBeviewlogomodesto.png"))
and it works.
I don´t find the reason for not showing the image when using the value snapshot.data![position].path, knowing that it is the same value.
In the exception, I can see that there is a leading / sign in the path which might be the problem.
FileSystemException: Cannot open file, path=//var/mobile/Containers/Data/Application/B2663D60-9BEF-4FFF-9287-BFD3CE6EF8BE/Documents/AgdsBeviewlogomodesto.png

java.net.URISyntaxException: Illegal character in opaque part at index 2: E:\\...\\intermediates\\flutter\\debug\\flutter_assets\\AssetManifest.json

I'm to get the solution.
I already tried flutter clean, flutter create, flutter get package.
AssetManifest.json
{"assets/audio/calling.mp3":["assets/audio/calling.mp3"],"assets/audio/chatsend.mp3":["assets/audio/chatsend.mp3"],"assets/cfg/configurations.json":["assets/cfg/configurations.json"],"assets/fonts/Blacksword.otf":["assets/fonts/Blacksword.otf"],"assets/fonts/proximanova-regular.otf":["assets/fonts/proximanova-regular.otf"],"assets/img/SuccessCheck.flr":["assets/img/SuccessCheck.flr"],"assets/img/apple_pay.png":["assets/img/apple_pay.png"],"assets/img/canada.png":["assets/img/canada.png"],"assets/img/cart_empty_ipmau1.png":["assets/img/cart_empty_ipmau1.png"],"assets/img/china.png":["assets/img/china.png"],"assets/img/clock.png":["assets/img/clock.png"],"assets/img/cod.png":["assets/img/cod.png"],"assets/img/completed.png":["assets/img/completed.png"],"assets/img/deliveryboy.png":["assets/img/deliveryboy.png"],"assets/img/flutterwave.png":["assets/img/flutterwave.png"],"assets/img/france.png":["assets/img/france.png"],"assets/img/germany.png":["assets/img/germany.png"],"assets/img/grocerydefaultbg.jpg":["assets/img/grocerydefaultbg.jpg"],"assets/img/intro1.png":["assets/img/intro1.png"],"assets/img/intro2.png":["assets/img/intro2.png"],"assets/img/intro3.png":["assets/img/intro3.png"],"assets/img/italy.png":["assets/img/italy.png"],"assets/img/loading.gif":["assets/img/loading.gif"],"assets/img/loading_card.gif":["assets/img/loading_card.gif"],"assets/img/loading_circle.png":["assets/img/loading_circle.png"],"assets/img/loading_trend.gif":["assets/img/loading_trend.gif"],"assets/img/location.png":["assets/img/location.png"],"assets/img/loginbg.jpg":["assets/img/loginbg.jpg"],"assets/img/loginbg1.jpg":["assets/img/loginbg1.jpg"],"assets/img/logo.png":["assets/img/logo.png"],"assets/img/malay.png":["assets/img/malay.png"],"assets/img/marker.png":["assets/img/marker.png"],"assets/img/mastercard.png":["assets/img/mastercard.png"],"assets/img/netherlands.png":["assets/img/netherlands.png"],"assets/img/no_data_found.png":["assets/img/no_data_found.png"],"assets/img/noshopfound.png":["assets/img/noshopfound.png"],"assets/img/onthway.gif":["assets/img/onthway.gif"],"assets/img/package.png":["assets/img/package.png"],"assets/img/paymentwaiting.gif":["assets/img/paymentwaiting.gif"],"assets/img/paypal.png":["assets/img/paypal.png"],"assets/img/paypal2.png":["assets/img/paypal2.png"],"assets/img/permission.png":["assets/img/permission.png"],"assets/img/pharmacydefaultbg.jpg":["assets/img/pharmacydefaultbg.jpg"],"assets/img/plate-food2.png":["assets/img/plate-food2.png"],"assets/img/portion.png":["assets/img/portion.png"],"assets/img/prescription.jpg":["assets/img/prescription.jpg"],"assets/img/rating.png":["assets/img/rating.png"],"assets/img/razorpay.png":["assets/img/razorpay.png"],"assets/img/rectangle_loader.gif":["assets/img/rectangle_loader.gif"],"assets/img/resturentdefaultbg.jpg":["assets/img/resturentdefaultbg.jpg"],"assets/img/shop.png":["assets/img/shop.png"],"assets/img/smiley.png":["assets/img/smiley.png"],"assets/img/spain.png":["assets/img/spain.png"],"assets/img/splash.flr":["assets/img/splash.flr"],"assets/img/stripe.png":["assets/img/stripe.png"],"assets/img/united-arab-emirates.png":["assets/img/united-arab-emirates.png"],"assets/img/united-states-of-america.png":["assets/img/united-states-of-america.png"],"assets/img/upi.png":["assets/img/upi.png"],"assets/img/userImage.png":["assets/img/userImage.png"],"assets/img/visa.png":["assets/img/visa.png"],"assets/img/visacard.png":["assets/img/visacard.png"],"assets/img/wallet.png":["assets/img/wallet.png"],"assets/img/winners.flr":["assets/img/winners.flr"],"packages/cupertino_icons/assets/CupertinoIcons.ttf":["packages/cupertino_icons/assets/CupertinoIcons.ttf"],"packages/rflutter_alert/assets/images/close.png":["packages/rflutter_alert/assets/images/close.png","packages/rflutter_alert/assets/images/2.0x/close.png","packages/rflutter_alert/assets/images/3.0x/close.png"],"packages/rflutter_alert/assets/images/icon_error.png":["packages/rflutter_alert/assets/images/icon_error.png","packages/rflutter_alert/assets/images/2.0x/icon_error.png","packages/rflutter_alert/assets/images/3.0x/icon_error.png"],"packages/rflutter_alert/assets/images/icon_info.png":["packages/rflutter_alert/assets/images/icon_info.png","packages/rflutter_alert/assets/images/2.0x/icon_info.png","packages/rflutter_alert/assets/images/3.0x/icon_info.png"],"packages/rflutter_alert/assets/images/icon_success.png":["packages/rflutter_alert/assets/images/icon_success.png","packages/rflutter_alert/assets/images/2.0x/icon_success.png","packages/rflutter_alert/assets/images/3.0x/icon_success.png"],"packages/rflutter_alert/assets/images/icon_warning.png":["packages/rflutter_alert/assets/images/icon_warning.png","packages/rflutter_alert/assets/images/2.0x/icon_warning.png","packages/rflutter_alert/assets/images/3.0x/icon_warning.png"]}

Another exception was thrown: NoSuchMethodError: The method '*' was called on null

I am having problems when I add an item to a CardList and try to display it using a Carousel. The item is added to the list but when I try to see it through the Carousel the error is shown :
I/flutter (12255): Another exception was thrown: NoSuchMethodError: The method '*' was called on null.
I have tried to not leave anything uninitialized as I have read in similar cases regarding this issue, but it doesn't help.
you can check my code here on my Github profile: https://github.com/varamsky/notes
And this is an image of the emulator screen.
enter image description here
kumar
I see your code and find the problem.
In file todoCard.dart in line 93 have this:
child: Text('${(percent*100).toInt()}%'),
This operation in the string (percent*100) not is valid because, for some reason, the percent is null.
You need to verify if percent is null.
PS: In next time, please place the code in answer, to facilitate a response.
PS2: I make a pull request to add a complete gitignore in your repository. This makes the repository easier to clone and work with him :D
A hug
I solved this problem while when I added:
textDirection: TextDirection.ltr, below the Row
check ----

Zend Framework Can't determine mime type of image upload

Hi all I'm trying to upload a image when creating a item in my app, however the action fails returning the following error: The mimetype of file 'mytestimage.jpg' could not be detected.
I've tried adding a Mime Type validator but the error persists, can anyone tell me where I'm going wrong in the code below.
// Image uploads
$images = new Zend_Form_Element_File('images');
$images->setMultiFile(2)
->addValidator('IsImage')
->addValidator('Size',false,'5242880')
->addValidator('Extension',false,'jpg,png,gif')
->addValidator('ImageSize',false,array(
'minwidth' => 250,
'minheight'=>250,
'maxwidth'=>500,
'maxheight'=>500
))
->setValueDisabled(true);
Many thanks in advance.
Graham
I had the same problem.
Zend_Frameworks tries to determine the mimetype in two ways:
First it tries to use the PECL FILEINFO-Extension (which is not installed on every server)
if the extension is not istalled it tries to use mime_content_type (a php function). This function however is deprecated as of php version 5.3
So in this case I guess your hoster is using php version 5.3 and has not installed the PECL FILEINFO-Extension. Same goes unfortunately for my hoster :(
Here are more details of the two ways in the php-manual:
http://de.php.net/manual/en/function.mime-content-type.php
http://de.php.net/manual/en/ref.fileinfo.php
By the way. You can see the code ZF uses in the file "Zend\File\Transfer\Adapter\Http.php" (lines 1281-1318: methodname is _detectMimeType