Amigo
Amigo

Reputation: 163

Flutter ambiguous import of Images

enter image description here

I have some trouble writing this function in Flutter, where the definition of the type Image seems to come from different packages. If I try changing "Future" to "Future", there still is an error that "ui.Image isn't a type so can't be used as a type argument." How would I fix this?

Upvotes: 1

Views: 4962

Answers (1)

Ademir Villena Zevallos
Ademir Villena Zevallos

Reputation: 1561

When you import the dart:ui package (the first place where the Image class is defined), do it like this:

import 'dart:ui' as ui;

So, when you use an Image from that package, you only need to write ui.Image. This is because exists two definitions for Image in flutter. As member of ui package and as widget.

Upvotes: 8

Related Questions