mirror of https://github.com/flutter/samples.git
Move library to a top-level variable, since it never changes (#887)
parent
ecf716dcab
commit
c9688ca34b
@ -1,24 +0,0 @@
|
||||
// Copyright 2021, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. 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 '../data.dart';
|
||||
|
||||
class LibraryScope extends InheritedWidget {
|
||||
final Library library;
|
||||
|
||||
const LibraryScope({
|
||||
Key? key,
|
||||
required this.library,
|
||||
required Widget child,
|
||||
}) : super(key: key, child: child);
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(LibraryScope oldWidget) =>
|
||||
library != oldWidget.library;
|
||||
|
||||
static Library of(BuildContext context) =>
|
||||
context.dependOnInheritedWidgetOfExactType<LibraryScope>()!.library;
|
||||
}
|
Loading…
Reference in new issue