theme.dart 822 Bytes
Newer Older
1 2 3 4 5
// 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/theme/theme_data.dart';
6
import 'package:sky/widgets/framework.dart';
7 8 9 10 11 12

export 'package:sky/theme/theme_data.dart' show ThemeData, ThemeBrightness;

class Theme extends Inherited {

  Theme({
13
    Key key,
14 15 16 17 18 19 20 21 22 23 24
    this.data,
    Widget child
  }) : super(key: key, child: child) {
    assert(child != null);
    assert(data != null);
  }

  final ThemeData data;

  static final ThemeData _kFallbackTheme = new ThemeData.fallback();

25 26
  static ThemeData of(Widget widget) {
    Theme theme = widget.inheritedOfType(Theme);
27 28 29 30 31 32
    return theme == null ? _kFallbackTheme : theme.data;
  }

  bool syncShouldNotify(Theme old) => data != old.data;

}