- 背景:**
我在探索flutter和dart,而且我做app只是为了自己的乐趣。
- 我的目标**
我想做一个愚蠢的应用程序,每天显示一个随机的图标(就像一天中的一句话)。
但是我不知道现在该怎么做,在所有的例子中,代码都直接引用了IconData字段,这些字段是在各自的类中声明的,比如FontAwesomeIcons
或Icons
。
这些字段被声明为static const
,访问这些字段的最正确方法是什么,以便说 * 把它们放在一个列表中,我可以随机选择一个索引 *?
library font_awesome_flutter;
import 'package:flutter/widgets.dart';
import 'package:font_awesome_flutter/icon_data.dart';
// THIS FILE IS AUTOMATICALLY GENERATED!
class FontAwesomeIcons {
static const IconData fiveHundredPx = const IconDataBrands(0xf26e);
static const IconData accessibleIcon = const IconDataBrands(0xf368);
static const IconData accusoft = const IconDataBrands(0xf369);
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/widgets.dart';
/// Identifiers for the supported material design icons.
///
/// Use with the [Icon] class to show specific icons.
///
/// Icons are identified by their name as listed below.
///
/// To use this class, make sure you set `uses-material-design: true` in your
/// project's `pubspec.yaml` file in the `flutter` section. This ensures that
/// the MaterialIcons font is included in your application. This font is used to
/// display the icons. For example:
///
/// ```yaml
/// name: my_awesome_application
/// flutter:
/// uses-material-design: true
/// ```
///
/// See also:
///
/// * [Icon]
/// * [IconButton]
/// * [design.google.com/icons](https://design.google.com/icons/)
class Icons {
Icons._();
// Generated code: do not hand-edit.
// See https://github.com/flutter/flutter/wiki/Updating-Material-Design-Fonts
// BEGIN GENERATED
/// <i class="material-icons md-36">360</i> — material icon named "360".
static const IconData threesixty = IconData(0xe577, fontFamily: 'MaterialIcons');
/// <i class="material-icons md-36">3d_rotation</i> — material icon named "3d rotation".
static const IconData threed_rotation = IconData(0xe84d, fontFamily: 'MaterialIcons');
2条答案
按热度按时间pdkcd3nj1#
只需使用
Icon(IconData())
构造函数。填充你的表格点与一些值的字符在这选定的字体风格.
如果您愿意,只需按名称创建一个图标列表,如下所示:
6kkfgxo02#