Flutter: EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE (AbortError: Aborted by failure.)

Viewed 64

I am trying to add an image with a text on it through Positioned widget. But got this error while showing the image. Image Path is correct also I added the path in pubspec.yaml file.

Flutter version: 3.0.3

Complete Error

══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
The following DomException object was thrown resolving an image frame:
  AbortError: Aborted by failure.
When the exception was thrown, this was the stack
Image provider: AssetImage(bundle: null, name: "assets/images/contact_us_banner.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#b62cd(), name:
  "assets/images/contact_us_banner.png", scale: 1)

Code:

import 'package:flutter/material.dart';
import '../../../../constants/images.dart';

class ContactUsContainer extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    double width = MediaQuery.of(context).size.width;
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 60, horizontal: 20),
      child: Container(
        color: const Color(0xff9ABFC7),
        height: 200,
        width: width * 0.80,
        child: Stack(children: [
          Image.asset(contactUsBanner, fit: BoxFit.contain),
          const Positioned(
              top: 20,
              left: 20,
              child: Text("Let's Build Your Website!",
                  style: TextStyle(
                      color: Colors.white,
                      fontSize: 40,
                      wordSpacing: 2,
                      letterSpacing: 2,
                      fontWeight: FontWeight.w900)))
        ]),
      ),
    );
  }
}
1 Answers

Solution: The image size is too big (more than 50 mbs). Just compressed the file(image) size and restart your App.

Related