Add 'package' argument to IconData (#12560)

This commit is contained in:
Sarah Zakarias 2017-10-19 09:38:54 +02:00 committed by GitHub
parent ce6f8d3a83
commit e4f53c3abd
3 changed files with 24 additions and 15 deletions

View file

@ -27,35 +27,36 @@ import 'package:flutter/widgets.dart';
class CupertinoIcons {
CupertinoIcons._();
static const String iconFont = 'packages/cupertino_icons/CupertinoIcons';
static const String iconFont = 'CupertinoIcons';
static const String iconFontPackage = 'cupertino_icons';
// Manually maintained list
static const IconData left_chevron = const IconData(0xf3f0, fontFamily: iconFont);
static const IconData left_chevron = const IconData(0xf3f0, fontFamily: iconFont, fontPackage: iconFontPackage);
static const IconData right_chevron = const IconData(0xf3f2, fontFamily: iconFont);
static const IconData right_chevron = const IconData(0xf3f2, fontFamily: iconFont, fontPackage: iconFontPackage);
static const IconData share = const IconData(0xf4ca, fontFamily: iconFont);
static const IconData share = const IconData(0xf4ca, fontFamily: iconFont, fontPackage: iconFontPackage);
static const IconData book = const IconData(0xf3e7, fontFamily: iconFont);
static const IconData book = const IconData(0xf3e7, fontFamily: iconFont, fontPackage: iconFontPackage);
static const IconData info = const IconData(0xf44c, fontFamily: iconFont);
static const IconData info = const IconData(0xf44c, fontFamily: iconFont, fontPackage: iconFontPackage);
static const IconData reply = const IconData(0xf4c6, fontFamily: iconFont);
static const IconData reply = const IconData(0xf4c6, fontFamily: iconFont, fontPackage: iconFontPackage);
static const IconData conversation_bubble = const IconData(0xf3fb, fontFamily: iconFont);
static const IconData conversation_bubble = const IconData(0xf3fb, fontFamily: iconFont, fontPackage: iconFontPackage);
static const IconData profile_circled = const IconData(0xf419, fontFamily: iconFont);
static const IconData profile_circled = const IconData(0xf419, fontFamily: iconFont, fontPackage: iconFontPackage);
static const IconData plus_circled = const IconData(0xf48a, fontFamily: iconFont);
static const IconData plus_circled = const IconData(0xf48a, fontFamily: iconFont, fontPackage: iconFontPackage);
static const IconData minus_circled = const IconData(0xf463, fontFamily: iconFont);
static const IconData minus_circled = const IconData(0xf463, fontFamily: iconFont, fontPackage: iconFontPackage);
static const IconData flag = const IconData(0xf42c, fontFamily: iconFont);
static const IconData flag = const IconData(0xf42c, fontFamily: iconFont, fontPackage: iconFontPackage);
static const IconData search = const IconData(0xf4c6, fontFamily: iconFont);
static const IconData search = const IconData(0xf4c6, fontFamily: iconFont, fontPackage: iconFontPackage);
static const IconData check_mark = const IconData(0xf41e, fontFamily: iconFont);
static const IconData check_mark = const IconData(0xf41e, fontFamily: iconFont, fontPackage: iconFontPackage);
static const IconData check_mark_circled = const IconData(0xf41f, fontFamily: iconFont);
static const IconData check_mark_circled = const IconData(0xf41f, fontFamily: iconFont, fontPackage: iconFontPackage);
}

View file

@ -132,6 +132,7 @@ class Icon extends StatelessWidget {
color: iconColor,
fontSize: iconSize,
fontFamily: icon.fontFamily,
package: icon.fontPackage,
),
),
),

View file

@ -14,9 +14,13 @@ class IconData {
///
/// Rarely used directly. Instead, consider using one of the predefined icons
/// like the [Icons] collection.
///
/// The [fontPackage] argument must be non-null when using a font family that
/// is included in a package. This is used when selecting the font.
const IconData(
this.codePoint, {
this.fontFamily,
this.fontPackage,
});
/// The Unicode code point at which this icon is stored in the icon font.
@ -25,6 +29,9 @@ class IconData {
/// The font family from which the glyph for the [codePoint] will be selected.
final String fontFamily;
// The name of the package from which the font family is included.
final String fontPackage;
@override
bool operator ==(dynamic other) {
if (runtimeType != other.runtimeType)