flutter_logo.dart 3.01 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6
// 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';

7
import 'colors.dart';
8 9

/// The Flutter logo, in widget form. This widget respects the [IconTheme].
10
/// For guidelines on using the Flutter logo, visit https://flutter.dev/brand.
11 12 13 14 15 16 17 18 19
///
/// See also:
///
///  * [IconTheme], which provides ambient configuration for icons.
///  * [Icon], for showing icons the Material design icon library.
///  * [ImageIcon], for showing icons from [AssetImage]s or other [ImageProvider]s.
class FlutterLogo extends StatelessWidget {
  /// Creates a widget that paints the Flutter logo.
  ///
20
  /// The [size] defaults to the value given by the current [IconTheme].
21 22 23
  const FlutterLogo({
    Key key,
    this.size,
24
    this.colors,
25 26 27 28
    this.textColor = const Color(0xFF616161),
    this.style = FlutterLogoStyle.markOnly,
    this.duration = const Duration(milliseconds: 750),
    this.curve = Curves.fastOutSlowIn,
29 30 31 32 33 34 35 36 37 38 39
  }) : super(key: key);

  /// The size of the logo in logical pixels.
  ///
  /// The logo will be fit into a square this size.
  ///
  /// Defaults to the current [IconTheme] size, if any. If there is no
  /// [IconTheme], or it does not specify an explicit size, then it defaults to
  /// 24.0.
  final double size;

40
  /// The color swatch to use to paint the logo, [Colors.blue] by default.
41
  ///
42 43 44
  /// If for some reason the default colors are impractical, then one
  /// of [Colors.amber], [Colors.red], or [Colors.indigo] swatches can be used.
  /// These are Flutter's secondary colors.
45 46 47 48
  ///
  /// In extreme cases where none of those four color schemes will work,
  /// [Colors.pink], [Colors.purple], or [Colors.cyan] swatches can be used.
  /// These are Flutter's tertiary colors.
49
  final MaterialColor colors;
50

51 52 53 54 55 56
  /// The color used to paint the "Flutter" text on the logo, if [style] is
  /// [FlutterLogoStyle.horizontal] or [FlutterLogoStyle.stacked]. The
  /// appropriate color is `const Color(0xFF616161)` (a medium gray), against a
  /// white background.
  final Color textColor;

57 58 59 60
  /// Whether and where to draw the "Flutter" text. By default, only the logo
  /// itself is drawn.
  final FlutterLogoStyle style;

61
  /// The length of time for the animation if the [style], [colors], or
62
  /// [textColor] properties are changed.
63 64
  final Duration duration;

65
  /// The curve for the logo animation if the [style], [colors], or [textColor]
66 67 68
  /// change.
  final Curve curve;

69 70
  @override
  Widget build(BuildContext context) {
71
    final IconThemeData iconTheme = IconTheme.of(context);
72
    final double iconSize = size ?? iconTheme.size;
73
    final MaterialColor logoColors = colors ?? Colors.blue;
74
    return AnimatedContainer(
75 76 77
      width: iconSize,
      height: iconSize,
      duration: duration,
78
      curve: curve,
79
      decoration: FlutterLogoDecoration(
80 81
        lightColor: logoColors.shade400,
        darkColor: logoColors.shade900,
82
        style: style,
83
        textColor: textColor,
84 85 86 87
      ),
    );
  }
}