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({super.key, this.title = '', required this.color, required this.child})
19 : assert(color.alpha == 0xFF);
20
21 /// A one-line description of this app for use in the window manager.
22 final String title;
23
24 /// A color that the window manager should use to identify this app. Must be
25 /// an opaque color (i.e. color.alpha must be 255 (0xFF)), and must not be
26 /// null.
27 final Color color;
28
29 /// The widget below this widget in the tree.
30 ///
31 /// {@macro flutter.widgets.ProxyWidget.child}
32 final Widget child;
33
34 @override
35 Widget build(BuildContext context) {
36 SystemChrome.setApplicationSwitcherDescription(
37 ApplicationSwitcherDescription(label: title, primaryColor: color.value),
38 );
39 return child;
40 }
41
42 @override
43 void debugFillProperties(DiagnosticPropertiesBuilder properties) {
44 super.debugFillProperties(properties);
45 properties.add(StringProperty('title', title, defaultValue: ''));
46 properties.add(ColorProperty('color', color, defaultValue: null));
47 }
48}
49