一,概述  

  图标组件(Icon)为展示图标的组件,该组件不可交互,要实现可交互的图标,可以考虑使用IconButton组件。
   图标组件相关的几个组件:

  • IconButton:可交互的Icon;
  • Icons:框架自带Icon集合;
  • IconTheme:Icon主题;
  • ImageIcon:通过AssetImages或者其他图片显示Icon。

二,继承关系

  •   

    Object > Diagnosticable > DiagnosticableTree > Widget > StatelessWidget > Icon

三,构造函数

  • Icon组件

    • 为展示图标的组件,不能交互
    • 构造函数
       const Icon(IconData icon, {//显示的图标
      Key key,
      double size,//图标尺寸
      Color color, //图标颜色
      String semanticLabel,//语义标签
      TextDirection textDirection,//用户呈现图标的文本方向
      })
  • 其它
    • IconButton:可交互的Icon;

      • IconButton是直接继承自StatelessWidget的,默认没有背景
      • 构造函数
      • const IconButton({
        Key key,
        this.iconSize = 24.0,
        this.padding = const EdgeInsets.all(8.0),
        this.alignment = Alignment.center,
        @required this.icon,
        this.color,
        this.highlightColor,
        this.splashColor,
        this.disabledColor,
        @required this.onPressed,
        this.tooltip
        })

          

    • Icons:框架自带Icon集合;
    • IconTheme:Icon主题;
    • ImageIcon:通过AssetImages或者其他图片显示Icon。   

四,参数详情

  • color  

    • 类型:Color  
    • 说明:图标颜色
  • icon  
    • 类型:IconData
    • 说明:显示的图标
  • semanticLabel  
    • 类型:String  
    • 说明:语义标签,此标签不会显示在UI中
  • size
    • 类型:double  
    • 说明:图标尺寸
  • textDirection  
    • 类型:TextDirection  
    • 说明:用户呈现图标的文本方向

五,示例demo

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {

  @override
Widget build(BuildContext context) {
const data = "Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep";
return MaterialApp(
title: 'Hello World!',
theme: ThemeData(
primaryColor: Colors.red,
),
home: Scaffold(
appBar: AppBar(
title: Text('Welcome to Fultter'),
),
body: Center(
child: Icon(
Icons.build,
color: Colors.red,
semanticLabel: "user",
size: 64.0,
textDirection: TextDirection.rtl,
),
),
),
);
}
}

六,官方文档

官方文档--Icon

最新文章

  1. django pdb
  2. 为 Xamarin.Forms 做个跑马灯控件
  3. CLR via C#深解笔记七 - 自动内存管理(垃圾回收)
  4. php基础32:正则匹配-修饰符
  5. ASP.NET MVC Controller Session问题
  6. 微信公开课(北京站)速记 微信、微信支付、O2O的定义与关联
  7. Vmware下Ubuntu无法上网的问题
  8. 关于LINQ一个简单例子
  9. Spring两种实现AOP的方式
  10. 洛谷P1220 关路灯
  11. Spring Ioc知识整理
  12. 主流JavaScript框架(Dojo、Google Closure、jQuery、Prototype、Mootools和YUI)的分析和对比
  13. 【SICP归纳】2 高阶函数和数据抽象
  14. 初入ubuntu
  15. 《Linux命令行与shell脚本编程大全》- 读书笔记2 - 更多的bash shell命令
  16. BZOJ4621 Tc605(动态规划)
  17. WebLogic使用总结(一)——WebLogic安装
  18. JavaSE基础知识(4)—数组的应用
  19. VMMAP的简单使用
  20. 使用自定义端口连接SQL Server 的方法

热门文章

  1. Vue学习笔记【28】——Vue路由(使用 children 属性实现路由嵌套)
  2. makefile 中的patsubst
  3. context和getApplicationContext()的区别
  4. sync.Once.Do(f func())
  5. java对象属性为date oracle数据库字段为Timestamp 处理方式
  6. iiview Select 选择框打勾选中的内容label和展示的不一致
  7. 转载! 一图读懂 SignalR
  8. Windows操作系统架构
  9. POJ 2254 Globetrotter (计算几何 - 球面最短距离)
  10. 一份详尽的 Java 问题排查工具清单,值得收藏!