Skip to content

"No constructor with matching arguments" exception thrown for Image.asset() method  #6186

@qchong

Description

@qchong

Steps to Reproduce

This snippet of code returns an exception, although it seems to conforms to the Image.asset() method signature.

builder: (BuildContext context, Widget child) {
          return new Image.asset(
            name: 'assets/flutter_logo.png',
            width: animation.value,
            height: animation.value,
            fit: ImageFit.contain,
          );

Flutter Doctor

[✓] Flutter (on Linux, channel master)
    • Flutter at /usr/local/google/home/quddusc/flutter/flutter
    • Framework revision b329894b4d (3 hours ago), 2016-10-03 12:52:06
    • Engine revision 71f2871f00
    • Tools Dart version 1.20.0-dev.5.0

[✓] Android toolchain - develop for Android devices (Android SDK 24.0.0)
    • Android SDK at /usr/local/google/home/quddusc/Android/Sdk
    • Platform android-24, build-tools 24.0.0
    • OpenJDK Runtime Environment (build 1.8.0-google-v7-132676107-132666263)

[✓] Atom - a lightweight development environment for Flutter
    • flutter plugin version 0.2.6
    • dartlang plugin version 0.6.40

[✓] Connected devices
    • Nexus 6P • 84B7N15818000592 • android-arm

Logs and Crash Reports

Please attach any relevent logs or crash reports.

Running lib/main.dart on Nexus 6P...
I/flutter : ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter : The following NoSuchMethodError was thrown building AnimatedBuilder(animation: AnimationController(▶
I/flutter : 0.000)➩Tween(0.0 → 200.0)➩0.0; dirty; state: _AnimatedState(666270605)):
I/flutter : No constructor 'Image.asset' with matching arguments declared in class 'Image'.
I/flutter : 
I/flutter : NoSuchMethodError: incorrect number of arguments passed to method named 'Image.asset'
I/flutter : Receiver: Type: class 'Image'
I/flutter : Tried calling: Image.asset(name: "assets/flutter_logo.png", width: 0.0, height: 0.0, fit: Instance
I/flutter : of 'ImageFit')
I/flutter : Found: Image.asset(String, {Key key, AssetBundle bundle, double scale, dynamic width, dynamic
I/flutter : height, dynamic color, dynamic fit, dynamic alignment, dynamic repeat, dynamic centerSlice, dynamic
I/flutter : gaplessPlayback})
I/flutter : 
I/flutter : When the exception was thrown, this was the stack:
I/flutter : #0      NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:184)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions