default_text_style.dart 746 Bytes
Newer Older
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
import 'package:sky/painting.dart';
6 7
import 'package:sky/src/widgets/basic.dart';
import 'package:sky/src/widgets/framework.dart';
8 9 10 11

class DefaultTextStyle extends Inherited {

  DefaultTextStyle({
12
    Key key,
13 14 15 16 17 18 19 20 21
    this.style,
    Widget child
  }) : super(key: key, child: child) {
    assert(style != null);
    assert(child != null);
  }

  final TextStyle style;

22 23
  static TextStyle of(Widget widget) {
    DefaultTextStyle result = widget.inheritedOfType(DefaultTextStyle);
24
    return result?.style;
25 26 27 28 29
  }

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

}