简体   繁体   English

如何在 flutter 应用程序中使用自定义图像

[英]How to use custom images in a flutter app

I am just graduating and am working on my first app via an internship.我刚刚毕业,正在通过实习开发我的第一个应用程序。 The school taught me ionic/angular but this customer wants to use flutter which I have no experience.学校教我离子/角度,但这个客户想使用我没有经验的 flutter。 I have succeeded with demo apps running in chrome.我已经成功地在 chrome 中运行了演示应用程序。

I am following this example here .我在这里遵循这个例子。

But I get an error here trying to extend the Decoration class:但是我在这里尝试扩展装饰 class 时遇到错误:

class CircleTabIndicator extends **Decoration** {
    final BoxPainter _painter;

It says:它说:

Classes can only extend other classes.类只能扩展其他类。 Try specifying a different superclass, or removing the extends clause.尝试指定不同的超类,或删除 extends 子句。

I am new to flutter so I do not understand why one class exists in a project and not the other.我是 flutter 的新手,所以我不明白为什么项目中存在一个 class 而不是另一个。 I see no mention of an import or anything.我没有看到任何提及进口或任何东西。 Also there only seems to be one type of project the flutter create produces so this is quite confusing.此外, flutter 创建的项目似乎只有一种类型,所以这很令人困惑。

What I really need to do is use custom icons in a tab app.我真正需要做的是在标签应用程序中使用自定义图标。 i have the tabs working with icons that I assume are default icons that come with flutter.我有使用图标的选项卡,我认为这些图标是 flutter 附带的默认图标。 I used this example and it worked flawlessly.我使用了这个例子,它完美地工作。

Just add只需添加

import 'package:flutter/material.dart';

at the top of the file you're declaring CircleTabIndicator .在您声明CircleTabIndicator的文件顶部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM