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

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)


Solution 1:[1]

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

Solution 2:[2]

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->image

Solution 3:[3]

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)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 IzyPro
Solution 2 Ravindra S. Patil
Solution 3 Bruno J.