1
0
mirror of https://github.com/flutter/samples.git synced 2026-05-15 03:20:01 +00:00

Move library to a top-level variable, since it never changes (#887)

This commit is contained in:
Kevin Moore
2021-08-26 16:18:40 -07:00
committed by GitHub
parent ecf716dcab
commit c9688ca34b
8 changed files with 77 additions and 114 deletions

View File

@@ -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;
}