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
5import 'package:flutter/foundation.dart';
6import 'package:flutter/services.dart';
7
8import 'basic.dart';
9import 'framework.dart';
10
11/// A widget that describes this app in the operating system.
12class Title extends StatelessWidget {
13 /// Creates a widget that describes this app to the Android operating system.
14 ///
15 /// [title] will default to the empty string if not supplied.
16 /// [color] must be an opaque color (i.e. color.alpha must be 255 (0xFF)).
17 /// [color] and [child] are required arguments.
18 Title({
19 super.key,
20 this.title = '',
21 required this.color,
22 required this.child,
23 }) : assert(color.alpha == 0xFF);
24
25 /// A one-line description of this app for use in the window manager.
26 final String title;
27
28 /// A color that the window manager should use to identify this app. Must be
29 /// an opaque color (i.e. color.alpha must be 255 (0xFF)), and must not be
30 /// null.
31 final Color color;
32
33 /// The widget below this widget in the tree.
34 ///
35 /// {@macro flutter.widgets.ProxyWidget.child}
36 final Widget child;
37
38 @override
39 Widget build(BuildContext context) {
40 SystemChrome.setApplicationSwitcherDescription(
41 ApplicationSwitcherDescription(
42 label: title,
43 primaryColor: color.value,
44 ),
45 );
46 return child;
47 }
48
49 @override
50 void debugFillProperties(DiagnosticPropertiesBuilder properties) {
51 super.debugFillProperties(properties);
52 properties.add(StringProperty('title', title, defaultValue: ''));
53 properties.add(ColorProperty('color', color, defaultValue: null));
54 }
55}
56