首先需要在pubspec.yaml的
assets 下要注册这些图片
https://www.jianshu.com/p/07d26525a0b5
https://blog.csdn.net/yuzhiqiang_1993/article/details/85258876
https://flutterchina.club/assets-and-images/

  1. import 'package:flutter/material.dart';
  2. // import 'package:english_words/english_words.dart';
  3. void main() => runApp(new MyApp());
  4. class MyApp extends StatelessWidget {
  5. @override
  6. Widget build(BuildContext context) {
  7. return new MaterialApp(
  8. title: 'Welcome to Flutter',
  9. home: new Scaffold(
  10. appBar: new AppBar(
  11. title: new Text('Welcome to Flutter12'),
  12. ),
  13. body: Column(
  14. children: <Widget>[
  15. Image.asset(
  16. 'static/pic/mg3414.jpg',
  17. width: 200,
  18. height: 300,
  19. ),
  20. Image.asset('static/pic/162.jpg',
  21. width: 200,),
  22. Image.network('http://8.129.221.250:3000/uploads/fc3eace4355f22498f5d1008a942da30-NrJn4jqrY5Dd492d82806fe4d6b2a5707d806722350c.png')
  23. ],
  24. ),
  25. ),
  26. );
  27. }
  28. }

图标

https://www.jianshu.com/p/af2df7325e4e
https://blog.csdn.net/ding139725/article/details/104843005
先在 pubspec.yaml 的 fonts 下注册 从 iconfont (阿里巴巴字体图标库)下载到的ttf格式的文件
然后 fonts 下的 family 字段代表的我们自定义的图标的名称

自定义图标的文件 family 字段 为 MyIcon
然后在页面中通过 import 引入这个文件
使用:

  1. Icon(MyIcon.huawei)
  2. Icon(MyIcon.xiaomi)
  3. Icon(MyIcon.oppo)

1629386997(1).jpg

  1. import 'package:flutter/material.dart';
  2. // import 'package:english_words/english_words.dart';
  3. void main() => runApp(new MyApp());
  4. class MyApp extends StatelessWidget {
  5. @override
  6. Widget build(BuildContext context) {
  7. return new MaterialApp(
  8. title: 'Welcome to Flutter',
  9. home: new Scaffold(
  10. appBar: new AppBar(
  11. title: new Text('Welcome to Flutter12'),
  12. ),
  13. body: Column(
  14. children: <Widget>[
  15. Image.asset(
  16. 'static/pic/mg3414.jpg',
  17. width: 200,
  18. height: 300,
  19. ),
  20. Image.asset('static/pic/162.jpg',
  21. width: 200,),
  22. Image.network('http://8.129.221.250:3000/uploads/fc3eace4355f22498f5d1008a942da30-NrJn4jqrY5Dd492d82806fe4d6b2a5707d806722350c.png'),
  23. Icon(Icons.zoom_out_sharp)
  24. ]
  25. ),
  26. ),
  27. );
  28. }
  29. }