forked from firka/flutter
Move icons stuff from material to widget (#10192)
Moved everything icons related except the material icon button and the materialicon font list to widget
This commit is contained in:
@@ -97,6 +97,6 @@ String getIconDeclaration(String line) {
|
|||||||
return '''
|
return '''
|
||||||
|
|
||||||
/// <p><i class="material-icons md-36">$name</i> — material icon named "$description".</p>
|
/// <p><i class="material-icons md-36">$name</i> — material icon named "$description".</p>
|
||||||
static const IconData $identifier = const IconData(0x$codepoint);
|
static const IconData $identifier = const IconData(0x$codepoint, fontFamily: 'MaterialIcons');
|
||||||
''';
|
''';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,12 +48,8 @@ export 'src/material/floating_action_button.dart';
|
|||||||
export 'src/material/flutter_logo.dart';
|
export 'src/material/flutter_logo.dart';
|
||||||
export 'src/material/grid_tile.dart';
|
export 'src/material/grid_tile.dart';
|
||||||
export 'src/material/grid_tile_bar.dart';
|
export 'src/material/grid_tile_bar.dart';
|
||||||
export 'src/material/icon.dart';
|
|
||||||
export 'src/material/icon_button.dart';
|
export 'src/material/icon_button.dart';
|
||||||
export 'src/material/icon_theme.dart';
|
|
||||||
export 'src/material/icon_theme_data.dart';
|
|
||||||
export 'src/material/icons.dart';
|
export 'src/material/icons.dart';
|
||||||
export 'src/material/image_icon.dart';
|
|
||||||
export 'src/material/ink_highlight.dart';
|
export 'src/material/ink_highlight.dart';
|
||||||
export 'src/material/ink_splash.dart';
|
export 'src/material/ink_splash.dart';
|
||||||
export 'src/material/ink_well.dart';
|
export 'src/material/ink_well.dart';
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ import 'app_bar.dart';
|
|||||||
import 'debug.dart';
|
import 'debug.dart';
|
||||||
import 'dialog.dart';
|
import 'dialog.dart';
|
||||||
import 'flat_button.dart';
|
import 'flat_button.dart';
|
||||||
import 'icon.dart';
|
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'list_tile.dart';
|
import 'list_tile.dart';
|
||||||
import 'page.dart';
|
import 'page.dart';
|
||||||
import 'progress_indicator.dart';
|
import 'progress_indicator.dart';
|
||||||
|
|||||||
@@ -12,10 +12,7 @@ import 'package:flutter/widgets.dart';
|
|||||||
import 'back_button.dart';
|
import 'back_button.dart';
|
||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
import 'flexible_space_bar.dart';
|
import 'flexible_space_bar.dart';
|
||||||
import 'icon.dart';
|
|
||||||
import 'icon_button.dart';
|
import 'icon_button.dart';
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
import 'page.dart';
|
import 'page.dart';
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'icon.dart';
|
|
||||||
import 'icon_button.dart';
|
import 'icon_button.dart';
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'theme.dart';
|
import 'theme.dart';
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import 'package:vector_math/vector_math_64.dart' show Vector3;
|
|||||||
|
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'ink_well.dart';
|
import 'ink_well.dart';
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
import 'theme.dart';
|
import 'theme.dart';
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import 'colors.dart';
|
|||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
import 'debug.dart';
|
import 'debug.dart';
|
||||||
import 'flat_button.dart';
|
import 'flat_button.dart';
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'ink_well.dart';
|
import 'ink_well.dart';
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
import 'raised_button.dart';
|
import 'raised_button.dart';
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import 'package:flutter/widgets.dart';
|
|||||||
|
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'debug.dart';
|
import 'debug.dart';
|
||||||
import 'icon.dart';
|
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'tooltip.dart';
|
import 'tooltip.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ import 'checkbox.dart';
|
|||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'debug.dart';
|
import 'debug.dart';
|
||||||
import 'dropdown.dart';
|
import 'dropdown.dart';
|
||||||
import 'icon.dart';
|
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'ink_well.dart';
|
import 'ink_well.dart';
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import 'colors.dart';
|
|||||||
import 'debug.dart';
|
import 'debug.dart';
|
||||||
import 'dialog.dart';
|
import 'dialog.dart';
|
||||||
import 'flat_button.dart';
|
import 'flat_button.dart';
|
||||||
import 'icon.dart';
|
|
||||||
import 'icon_button.dart';
|
import 'icon_button.dart';
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'ink_well.dart';
|
import 'ink_well.dart';
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import 'package:flutter/widgets.dart';
|
|||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
import 'debug.dart';
|
import 'debug.dart';
|
||||||
import 'icon.dart';
|
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'ink_well.dart';
|
import 'ink_well.dart';
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import 'package:flutter/widgets.dart';
|
|||||||
|
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'debug.dart';
|
import 'debug.dart';
|
||||||
import 'icon.dart';
|
|
||||||
import 'icon_button.dart';
|
import 'icon_button.dart';
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'theme.dart';
|
import 'theme.dart';
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'icon.dart';
|
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'list_tile.dart';
|
import 'list_tile.dart';
|
||||||
import 'theme.dart';
|
import 'theme.dart';
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'ink_well.dart';
|
import 'ink_well.dart';
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
import 'theme.dart';
|
import 'theme.dart';
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
|
|
||||||
/// The Flutter logo, in widget form. This widget respects the [IconTheme].
|
/// The Flutter logo, in widget form. This widget respects the [IconTheme].
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'theme.dart';
|
import 'theme.dart';
|
||||||
|
|
||||||
/// A header used in a material design [GridTile].
|
/// A header used in a material design [GridTile].
|
||||||
|
|||||||
@@ -8,9 +8,6 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'debug.dart';
|
import 'debug.dart';
|
||||||
import 'icon.dart';
|
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'ink_well.dart';
|
import 'ink_well.dart';
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -7,9 +7,6 @@ import 'package:flutter/widgets.dart';
|
|||||||
|
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'debug.dart';
|
import 'debug.dart';
|
||||||
import 'icon.dart';
|
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'theme.dart';
|
import 'theme.dart';
|
||||||
|
|
||||||
const Duration _kTransitionDuration = const Duration(milliseconds: 200);
|
const Duration _kTransitionDuration = const Duration(milliseconds: 200);
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import 'package:flutter/widgets.dart';
|
|||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
import 'debug.dart';
|
import 'debug.dart';
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'ink_well.dart';
|
import 'ink_well.dart';
|
||||||
import 'theme.dart';
|
import 'theme.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ import 'card.dart';
|
|||||||
import 'data_table.dart';
|
import 'data_table.dart';
|
||||||
import 'data_table_source.dart';
|
import 'data_table_source.dart';
|
||||||
import 'dropdown.dart';
|
import 'dropdown.dart';
|
||||||
import 'icon.dart';
|
|
||||||
import 'icon_button.dart';
|
import 'icon_button.dart';
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'progress_indicator.dart';
|
import 'progress_indicator.dart';
|
||||||
import 'theme.dart';
|
import 'theme.dart';
|
||||||
|
|||||||
@@ -9,10 +9,7 @@ import 'package:flutter/widgets.dart';
|
|||||||
|
|
||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
import 'divider.dart';
|
import 'divider.dart';
|
||||||
import 'icon.dart';
|
|
||||||
import 'icon_button.dart';
|
import 'icon_button.dart';
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'ink_well.dart';
|
import 'ink_well.dart';
|
||||||
import 'list_tile.dart';
|
import 'list_tile.dart';
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import 'button.dart';
|
|||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'debug.dart';
|
import 'debug.dart';
|
||||||
import 'flat_button.dart';
|
import 'flat_button.dart';
|
||||||
import 'icon.dart';
|
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'ink_well.dart';
|
import 'ink_well.dart';
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import 'app_bar.dart';
|
|||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
import 'debug.dart';
|
import 'debug.dart';
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'ink_well.dart';
|
import 'ink_well.dart';
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
import 'tab_controller.dart';
|
import 'tab_controller.dart';
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'theme_data.dart';
|
import 'theme_data.dart';
|
||||||
|
|
||||||
export 'theme_data.dart' show Brightness, ThemeData;
|
export 'theme_data.dart' show Brightness, ThemeData;
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import 'dart:math' as math;
|
|||||||
import 'dart:ui' show Color, hashValues;
|
import 'dart:ui' show Color, hashValues;
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'typography.dart';
|
import 'typography.dart';
|
||||||
|
|
||||||
/// Describes the contrast needs of a color.
|
/// Describes the contrast needs of a color.
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'icon.dart';
|
|
||||||
import 'icon_theme.dart';
|
|
||||||
import 'icon_theme_data.dart';
|
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'list_tile.dart';
|
import 'list_tile.dart';
|
||||||
import 'theme.dart';
|
import 'theme.dart';
|
||||||
|
|||||||
@@ -2,34 +2,20 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
|
|
||||||
import 'icon_button.dart';
|
import 'basic.dart';
|
||||||
|
import 'framework.dart';
|
||||||
|
import 'icon_data.dart';
|
||||||
import 'icon_theme.dart';
|
import 'icon_theme.dart';
|
||||||
import 'icon_theme_data.dart';
|
import 'icon_theme_data.dart';
|
||||||
import 'icons.dart';
|
|
||||||
import 'theme.dart';
|
|
||||||
|
|
||||||
/// A material design icon.
|
|
||||||
|
/// A graphical icon widget drawn with a glyph from a font described in
|
||||||
|
/// an [IconData] such as material's predefined [IconData]s in [Icons].
|
||||||
///
|
///
|
||||||
/// Icons are not interactive. For an interactive icon, consider [IconButton].
|
/// Icons are not interactive. For an interactive icon, consider material's
|
||||||
///
|
/// [IconButton].
|
||||||
/// Icons are identified by their name (as given on that page), with spaces
|
|
||||||
/// converted to underscores, from the [Icons] class. For example, the "alarm
|
|
||||||
/// add" icon is [Icons.alarm_add].
|
|
||||||
///
|
|
||||||
/// Available icons are shown on this page: <https://design.google.com/icons/>
|
|
||||||
///
|
|
||||||
/// 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:
|
/// See also:
|
||||||
///
|
///
|
||||||
@@ -69,15 +55,19 @@ class Icon extends StatelessWidget {
|
|||||||
|
|
||||||
/// The color to use when drawing the icon.
|
/// The color to use when drawing the icon.
|
||||||
///
|
///
|
||||||
/// Defaults to the current [IconTheme] color, if any. If there is
|
/// Defaults to the current [IconTheme] color, if any.
|
||||||
/// no [IconTheme], then it defaults to white if the theme is dark
|
|
||||||
/// and black if the theme is light. See [Theme] to set the current
|
|
||||||
/// theme and [ThemeData.brightness] for setting the current theme's
|
|
||||||
/// brightness.
|
|
||||||
///
|
///
|
||||||
/// The given color will be adjusted by the opacity of the current
|
/// The given color will be adjusted by the opacity of the current
|
||||||
/// [IconTheme], if any.
|
/// [IconTheme], if any.
|
||||||
///
|
///
|
||||||
|
/// If no [IconTheme]s are specified, icons will default to black.
|
||||||
|
///
|
||||||
|
/// In material apps, if there is a [Theme] without any [IconTheme]s
|
||||||
|
/// specified, icon colors default to white if the theme is dark
|
||||||
|
/// and black if the theme is light.
|
||||||
|
/// See [Theme] to set the current theme and [ThemeData.brightness]
|
||||||
|
/// for setting the current theme's brightness.
|
||||||
|
///
|
||||||
/// Typically, a material design color will be used, as follows:
|
/// Typically, a material design color will be used, as follows:
|
||||||
///
|
///
|
||||||
/// ```dart
|
/// ```dart
|
||||||
41
packages/flutter/lib/src/widgets/icon_data.dart
Normal file
41
packages/flutter/lib/src/widgets/icon_data.dart
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// Copyright 2017 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/foundation.dart';
|
||||||
|
|
||||||
|
/// A description of an icon fulfilled by a font glyph.
|
||||||
|
///
|
||||||
|
/// See [Icons] for a number of predefined icons available for material
|
||||||
|
/// design applications.
|
||||||
|
@immutable
|
||||||
|
class IconData {
|
||||||
|
/// Creates icon data.
|
||||||
|
///
|
||||||
|
/// Rarely used directly. Instead, consider using one of the predefined icons
|
||||||
|
/// like the [Icons] collection.
|
||||||
|
const IconData(
|
||||||
|
this.codePoint, {
|
||||||
|
this.fontFamily,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// The Unicode code point at which this icon is stored in the icon font.
|
||||||
|
final int codePoint;
|
||||||
|
|
||||||
|
/// The font family from which the glyph for the [codePoint] will be selected.
|
||||||
|
final String fontFamily;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(dynamic other) {
|
||||||
|
if (runtimeType != other.runtimeType)
|
||||||
|
return false;
|
||||||
|
final IconData typedOther = other;
|
||||||
|
return codePoint == typedOther.codePoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => codePoint.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => 'IconData(U+${codePoint.toRadixString(16).toUpperCase().padLeft(5, '0')})';
|
||||||
|
}
|
||||||
@@ -3,8 +3,9 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
|
|
||||||
|
import 'basic.dart';
|
||||||
|
import 'framework.dart';
|
||||||
import 'icon_theme_data.dart';
|
import 'icon_theme_data.dart';
|
||||||
|
|
||||||
/// Controls the default color, opacity, and size of icons in a widget subtree.
|
/// Controls the default color, opacity, and size of icons in a widget subtree.
|
||||||
@@ -2,13 +2,15 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
|
|
||||||
import 'icon_button.dart';
|
import 'basic.dart';
|
||||||
|
import 'framework.dart';
|
||||||
|
import 'icon.dart';
|
||||||
import 'icon_theme.dart';
|
import 'icon_theme.dart';
|
||||||
import 'icon_theme_data.dart';
|
import 'icon_theme_data.dart';
|
||||||
import 'icons.dart';
|
import 'image.dart';
|
||||||
|
|
||||||
/// An icon that comes from an [ImageProvider], e.g. an [AssetImage].
|
/// An icon that comes from an [ImageProvider], e.g. an [AssetImage].
|
||||||
///
|
///
|
||||||
@@ -16,7 +18,8 @@ import 'icons.dart';
|
|||||||
///
|
///
|
||||||
/// * [IconButton], for interactive icons.
|
/// * [IconButton], for interactive icons.
|
||||||
/// * [IconTheme], which provides ambient configuration for icons.
|
/// * [IconTheme], which provides ambient configuration for icons.
|
||||||
/// * [Icon] and [Icons], for icons from the material design library.
|
/// * [Icon], for icons based on glyphs from fonts instead of images
|
||||||
|
/// * [Icons], a predefined font based set of icons from the material design library.
|
||||||
class ImageIcon extends StatelessWidget {
|
class ImageIcon extends StatelessWidget {
|
||||||
/// Creates an image icon.
|
/// Creates an image icon.
|
||||||
///
|
///
|
||||||
@@ -34,7 +34,12 @@ export 'src/widgets/framework.dart';
|
|||||||
export 'src/widgets/gesture_detector.dart';
|
export 'src/widgets/gesture_detector.dart';
|
||||||
export 'src/widgets/grid_paper.dart';
|
export 'src/widgets/grid_paper.dart';
|
||||||
export 'src/widgets/heroes.dart';
|
export 'src/widgets/heroes.dart';
|
||||||
|
export 'src/widgets/icon.dart';
|
||||||
|
export 'src/widgets/icon_data.dart';
|
||||||
|
export 'src/widgets/icon_theme.dart';
|
||||||
|
export 'src/widgets/icon_theme_data.dart';
|
||||||
export 'src/widgets/image.dart';
|
export 'src/widgets/image.dart';
|
||||||
|
export 'src/widgets/image_icon.dart';
|
||||||
export 'src/widgets/implicit_animations.dart';
|
export 'src/widgets/implicit_animations.dart';
|
||||||
export 'src/widgets/layout_builder.dart';
|
export 'src/widgets/layout_builder.dart';
|
||||||
export 'src/widgets/locale_query.dart';
|
export 'src/widgets/locale_query.dart';
|
||||||
|
|||||||
@@ -1,92 +0,0 @@
|
|||||||
// 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/material.dart';
|
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
testWidgets('Icon sizing - no theme, default size', (WidgetTester tester) async {
|
|
||||||
await tester.pumpWidget(
|
|
||||||
const Center(
|
|
||||||
child: const Icon(null),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
|
|
||||||
expect(renderObject.size, equals(const Size.square(24.0)));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('Icon sizing - no theme, explicit size', (WidgetTester tester) async {
|
|
||||||
await tester.pumpWidget(
|
|
||||||
const Center(
|
|
||||||
child: const Icon(
|
|
||||||
null,
|
|
||||||
size: 96.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
|
|
||||||
expect(renderObject.size, equals(const Size.square(96.0)));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('Icon sizing - sized theme', (WidgetTester tester) async {
|
|
||||||
await tester.pumpWidget(
|
|
||||||
const Center(
|
|
||||||
child: const IconTheme(
|
|
||||||
data: const IconThemeData(size: 36.0),
|
|
||||||
child: const Icon(null),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
|
|
||||||
expect(renderObject.size, equals(const Size.square(36.0)));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('Icon sizing - sized theme, explicit size', (WidgetTester tester) async {
|
|
||||||
await tester.pumpWidget(
|
|
||||||
const Center(
|
|
||||||
child: const IconTheme(
|
|
||||||
data: const IconThemeData(size: 36.0),
|
|
||||||
child: const Icon(
|
|
||||||
null,
|
|
||||||
size: 48.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
|
|
||||||
expect(renderObject.size, equals(const Size.square(48.0)));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('Icon sizing - sizeless theme, default size', (WidgetTester tester) async {
|
|
||||||
await tester.pumpWidget(
|
|
||||||
const Center(
|
|
||||||
child: const IconTheme(
|
|
||||||
data: const IconThemeData(),
|
|
||||||
child: const Icon(null),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
|
|
||||||
expect(renderObject.size, equals(const Size.square(24.0)));
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
testWidgets('Icon with custom font', (WidgetTester tester) async {
|
|
||||||
await tester.pumpWidget(
|
|
||||||
const Center(
|
|
||||||
child: const Icon(const IconData(0x41, fontFamily: 'Roboto')),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final RichText richText = tester.firstWidget(find.byType(RichText));
|
|
||||||
expect(richText.text.style.fontFamily, equals('Roboto'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -11,4 +11,9 @@ void main() {
|
|||||||
expect(Icons.account_balance.hashCode, isNot(equals(Icons.account_box.hashCode)));
|
expect(Icons.account_balance.hashCode, isNot(equals(Icons.account_box.hashCode)));
|
||||||
expect(Icons.account_balance, hasOneLineDescription);
|
expect(Icons.account_balance, hasOneLineDescription);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('Icons specify the material font', (WidgetTester tester) async {
|
||||||
|
expect(Icons.clear.fontFamily, 'MaterialIcons');
|
||||||
|
expect(Icons.search.fontFamily, 'MaterialIcons');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
@@ -3,20 +3,102 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('Can set opacity for an Icon', (WidgetTester tester) async {
|
testWidgets('Can set opacity for an Icon', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
new IconTheme(
|
const IconTheme(
|
||||||
data: new IconThemeData(
|
data: const IconThemeData(
|
||||||
color: Colors.green[500],
|
color: const Color(0xFF666666),
|
||||||
opacity: 0.5
|
opacity: 0.5
|
||||||
),
|
),
|
||||||
child: const Icon(Icons.add)
|
child: const Icon(const IconData(0xd0a0, fontFamily: 'Arial'))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
final RichText text = tester.widget(find.byType(RichText));
|
final RichText text = tester.widget(find.byType(RichText));
|
||||||
expect(text.text.style.color, equals(Colors.green[500].withOpacity(0.5)));
|
expect(text.text.style.color, const Color(0xFF666666).withOpacity(0.5));
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Icon sizing - no theme, default size', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
const Center(
|
||||||
|
child: const Icon(null),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
|
||||||
|
expect(renderObject.size, equals(const Size.square(24.0)));
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Icon sizing - no theme, explicit size', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
const Center(
|
||||||
|
child: const Icon(
|
||||||
|
null,
|
||||||
|
size: 96.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
|
||||||
|
expect(renderObject.size, equals(const Size.square(96.0)));
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Icon sizing - sized theme', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
const Center(
|
||||||
|
child: const IconTheme(
|
||||||
|
data: const IconThemeData(size: 36.0),
|
||||||
|
child: const Icon(null),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
|
||||||
|
expect(renderObject.size, equals(const Size.square(36.0)));
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Icon sizing - sized theme, explicit size', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
const Center(
|
||||||
|
child: const IconTheme(
|
||||||
|
data: const IconThemeData(size: 36.0),
|
||||||
|
child: const Icon(
|
||||||
|
null,
|
||||||
|
size: 48.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
|
||||||
|
expect(renderObject.size, equals(const Size.square(48.0)));
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Icon sizing - sizeless theme, default size', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
const Center(
|
||||||
|
child: const IconTheme(
|
||||||
|
data: const IconThemeData(),
|
||||||
|
child: const Icon(null),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final RenderBox renderObject = tester.renderObject(find.byType(Icon));
|
||||||
|
expect(renderObject.size, equals(const Size.square(24.0)));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
testWidgets('Icon with custom font', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
const Center(
|
||||||
|
child: const Icon(const IconData(0x41, fontFamily: 'Roboto')),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final RichText richText = tester.firstWidget(find.byType(RichText));
|
||||||
|
expect(richText.text.style.fontFamily, equals('Roboto'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,19 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('IconThemeData control test', () {
|
test('IconThemeData control test', () {
|
||||||
final IconThemeData data = new IconThemeData(color: Colors.green[500], opacity: 0.5, size: 16.0);
|
final IconThemeData data = const IconThemeData(color: const Color(0xAAAAAAAA), opacity: 0.5, size: 16.0);
|
||||||
|
|
||||||
expect(data, hasOneLineDescription);
|
expect(data, hasOneLineDescription);
|
||||||
expect(data, equals(data.copyWith()));
|
expect(data, equals(data.copyWith()));
|
||||||
expect(data.hashCode, equals(data.copyWith().hashCode));
|
expect(data.hashCode, equals(data.copyWith().hashCode));
|
||||||
|
|
||||||
final IconThemeData lerped = IconThemeData.lerp(data, const IconThemeData.fallback(), 0.25);
|
final IconThemeData lerped = IconThemeData.lerp(data, const IconThemeData.fallback(), 0.25);
|
||||||
expect(lerped.color, equals(Color.lerp(Colors.green[500], Colors.black, 0.25)));
|
expect(lerped.color, equals(Color.lerp(const Color(0xAAAAAAAA), const Color(0xFF000000), 0.25)));
|
||||||
expect(lerped.opacity, equals(0.625));
|
expect(lerped.opacity, equals(0.625));
|
||||||
expect(lerped.size, equals(18.0));
|
expect(lerped.size, equals(18.0));
|
||||||
});
|
});
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
Reference in New Issue
Block a user