From e4f53c3abdb0fd8c0d29f095d2ec40e124ef9746 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Thu, 19 Oct 2017 09:38:54 +0200 Subject: [PATCH] Add 'package' argument to IconData (#12560) --- packages/flutter/lib/src/cupertino/icons.dart | 31 ++++++++++--------- packages/flutter/lib/src/widgets/icon.dart | 1 + .../flutter/lib/src/widgets/icon_data.dart | 7 +++++ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/packages/flutter/lib/src/cupertino/icons.dart b/packages/flutter/lib/src/cupertino/icons.dart index 62f0bae4650..34af2577cab 100644 --- a/packages/flutter/lib/src/cupertino/icons.dart +++ b/packages/flutter/lib/src/cupertino/icons.dart @@ -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); } \ No newline at end of file diff --git a/packages/flutter/lib/src/widgets/icon.dart b/packages/flutter/lib/src/widgets/icon.dart index 9a4d167601d..b89390b1c43 100644 --- a/packages/flutter/lib/src/widgets/icon.dart +++ b/packages/flutter/lib/src/widgets/icon.dart @@ -132,6 +132,7 @@ class Icon extends StatelessWidget { color: iconColor, fontSize: iconSize, fontFamily: icon.fontFamily, + package: icon.fontPackage, ), ), ), diff --git a/packages/flutter/lib/src/widgets/icon_data.dart b/packages/flutter/lib/src/widgets/icon_data.dart index 2e381371397..98c4a4d8812 100644 --- a/packages/flutter/lib/src/widgets/icon_data.dart +++ b/packages/flutter/lib/src/widgets/icon_data.dart @@ -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)