title.dart 1.1 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
/// Controls the description of this app in the operating system.
9
class Title extends StatelessWidget {
10 11 12 13 14 15
  Title({
    Key key,
    this.title,
    this.child,
    this.color
  }) : super(key: key) {
Ian Hickson's avatar
Ian Hickson committed
16 17
    assert(color == null || color.alpha == 0xFF);
  }
Adam Barth's avatar
Adam Barth committed
18

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

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

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

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

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