gpt4 book ai didi

dart - 错误 : The name 'Image' is defined in the libraries 'package:flutter/src/widgets/image.dart' and 'package:image/src/image.dart' . -- ambiguous_import

转载 作者:IT老高 更新时间:2023-10-28 12:34:58 32 4
gpt4 key购买 nike

如何解决 Dart 中的这种歧义错误。

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:camera/camera.dart';
import 'package:image/image.dart';

return MaterialApp(
title: 'Camera',
home: Scaffold(
body: new Container(
child: _image == null ? Text('No Image to display') : Image.file(_image),
),
floatingActionButton: new FloatingActionButton(onPressed:() {
picker();
},
tooltip: 'Pick image',
child: new Icon(Icons.camera)),
),
);

错误:

The name 'Image' is defined in the libraries 'package:flutter/src/widgets/image.dart' and 'package:image/src/image.dart'. (ambiguous_import at [camera] lib\packs\reg.certificate.dart:45)

ImageFlutter Widget 库 中定义,也在 'package:image/image.dart' 中定义。但是我想从 Flutter Widget library 中引用它怎么做?

这是 package:image/image.dart--> 用于解码图像的库的图像

**package:image/image.dart**

最佳答案

如果您有一个名为 import 的文件,例如:

Import ‘package:image/image.dart’ as Image;

那么该包中的类将是Image.image

关于dart - 错误 : The name 'Image' is defined in the libraries 'package:flutter/src/widgets/image.dart' and 'package:image/src/image.dart' . -- ambiguous_import,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53514344/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com