title.dart 1.17 KB
Newer Older
Adam Barth's avatar
Adam Barth committed
1 2 3 4
// 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.

5 6
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
7

8
/// A widget that describes this app in the operating system.
9
class Title extends StatelessWidget {
10
  /// Creates a widget that describes this app to the operating system.
11 12 13
  Title({
    Key key,
    this.title,
14 15
    this.color,
    this.child
16
  }) : super(key: key) {
Ian Hickson's avatar
Ian Hickson committed
17 18
    assert(color == null || color.alpha == 0xFF);
  }
Adam Barth's avatar
Adam Barth committed
19

20
  /// A one-line description of this app for use in the window manager.
Adam Barth's avatar
Adam Barth committed
21
  final String title;
22 23

  /// A color that the window manager should use to identify this app.
24
  final Color color;
Adam Barth's avatar
Adam Barth committed
25

26
  /// The widget below this widget in the tree.
27 28
  final Widget child;

29
  @override
30
  Widget build(BuildContext context) {
Ian Hickson's avatar
Ian Hickson committed
31
    updateTaskDescription(label: title, color: color);
Adam Barth's avatar
Adam Barth committed
32 33
    return child;
  }
Hixie's avatar
Hixie committed
34

35
  @override
Hixie's avatar
Hixie committed
36 37
  void debugFillDescription(List<String> description) {
    super.debugFillDescription(description);
Ian Hickson's avatar
Ian Hickson committed
38 39 40 41
    if (title != null)
      description.add('"$title"');
    if (color != null)
      description.add('color: $color');
Hixie's avatar
Hixie committed
42
  }
Adam Barth's avatar
Adam Barth committed
43
}