1 | // Copyright 2014 The Flutter Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. |
4 | |
5 | import 'basic.dart'; |
6 | import 'framework.dart'; |
7 | import 'icon_theme.dart'; |
8 | import 'icon_theme_data.dart'; |
9 | import 'implicit_animations.dart'; |
10 | |
11 | /// The Flutter logo, in widget form. This widget respects the [IconTheme]. |
12 | /// For guidelines on using the Flutter logo, visit https://flutter.dev/brand. |
13 | /// |
14 | /// {@youtube 560 315 https://www.youtube.com/watch?v=aAmP-WcI6dg} |
15 | /// |
16 | /// See also: |
17 | /// |
18 | /// * [IconTheme], which provides ambient configuration for icons. |
19 | /// * [Icon], for showing icons the Material design icon library. |
20 | /// * [ImageIcon], for showing icons from [AssetImage]s or other [ImageProvider]s. |
21 | class FlutterLogo extends StatelessWidget { |
22 | /// Creates a widget that paints the Flutter logo. |
23 | /// |
24 | /// The [size] defaults to the value given by the current [IconTheme]. |
25 | /// |
26 | /// The [textColor], [style], [duration], and [curve] arguments must not be |
27 | /// null. |
28 | const FlutterLogo({ |
29 | super.key, |
30 | this.size, |
31 | this.textColor = const Color(0xFF757575), |
32 | this.style = FlutterLogoStyle.markOnly, |
33 | this.duration = const Duration(milliseconds: 750), |
34 | this.curve = Curves.fastOutSlowIn, |
35 | }); |
36 | |
37 | /// The size of the logo in logical pixels. |
38 | /// |
39 | /// The logo will be fit into a square this size. |
40 | /// |
41 | /// Defaults to the current [IconTheme] size, if any. If there is no |
42 | /// [IconTheme], or it does not specify an explicit size, then it defaults to |
43 | /// 24.0. |
44 | final double? size; |
45 | |
46 | /// The color used to paint the "Flutter" text on the logo, if [style] is |
47 | /// [FlutterLogoStyle.horizontal] or [FlutterLogoStyle.stacked]. |
48 | /// |
49 | /// If possible, the default (a medium grey) should be used against a white |
50 | /// background. |
51 | final Color textColor; |
52 | |
53 | /// Whether and where to draw the "Flutter" text. By default, only the logo |
54 | /// itself is drawn. |
55 | final FlutterLogoStyle style; |
56 | |
57 | /// The length of time for the animation if the [style] or [textColor] |
58 | /// properties are changed. |
59 | final Duration duration; |
60 | |
61 | /// The curve for the logo animation if the [style] or [textColor] change. |
62 | final Curve curve; |
63 | |
64 | @override |
65 | Widget build(BuildContext context) { |
66 | final IconThemeData iconTheme = IconTheme.of(context); |
67 | final double? iconSize = size ?? iconTheme.size; |
68 | return AnimatedContainer( |
69 | width: iconSize, |
70 | height: iconSize, |
71 | duration: duration, |
72 | curve: curve, |
73 | decoration: FlutterLogoDecoration( |
74 | style: style, |
75 | textColor: textColor, |
76 | ), |
77 | ); |
78 | } |
79 | } |
80 | |