default_text_style.dart 781 Bytes
Newer Older
1 2 3 4 5 6
// 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.

import 'package:sky/painting/text_style.dart';
import 'package:sky/widgets/basic.dart';
7
import 'package:sky/widgets/framework.dart';
8 9 10 11

class DefaultTextStyle extends Inherited {

  DefaultTextStyle({
12
    Key key,
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
    this.style,
    Widget child
  }) : super(key: key, child: child) {
    assert(style != null);
    assert(child != null);
  }

  final TextStyle style;

  static TextStyle of(Component component) {
    DefaultTextStyle result = component.inheritedOfType(DefaultTextStyle);
    return result == null ? null : result.style;
  }

  bool syncShouldNotify(DefaultTextStyle old) => style != old.style;

}