icon_theme.dart 905 Bytes
Newer Older
Adam Barth's avatar
Adam Barth committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// 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:flutter/widgets.dart';

import 'icon_theme_data.dart';

class IconTheme extends InheritedWidget {
  IconTheme({
    Key key,
    this.data,
    Widget child
  }) : super(key: key, child: child) {
    assert(data != null);
    assert(child != null);
  }

  final IconThemeData data;

21
  /// The data from the closest instance of this class that encloses the given context.
Adam Barth's avatar
Adam Barth committed
22
  static IconThemeData of(BuildContext context) {
Ian Hickson's avatar
Ian Hickson committed
23
    IconTheme result = context.inheritFromWidgetOfExactType(IconTheme);
Adam Barth's avatar
Adam Barth committed
24 25 26 27 28 29
    return result?.data;
  }

  bool updateShouldNotify(IconTheme old) => data != old.data;

  void debugFillDescription(List<String> description) {
Ian Hickson's avatar
Ian Hickson committed
30
    super.debugFillDescription(description);
Adam Barth's avatar
Adam Barth committed
31 32 33
    description.add('$data');
  }
}