Add UniqueComponent helper for creating components with unique states
This commit is contained in:
parent
ff5676952e
commit
e1b8f0b659
@ -47,5 +47,6 @@ export 'fn3/theme.dart';
|
|||||||
export 'fn3/title.dart';
|
export 'fn3/title.dart';
|
||||||
export 'fn3/tool_bar.dart';
|
export 'fn3/tool_bar.dart';
|
||||||
export 'fn3/transitions.dart';
|
export 'fn3/transitions.dart';
|
||||||
|
export 'fn3/unique_component.dart';
|
||||||
|
|
||||||
export 'package:vector_math/vector_math.dart' show Matrix4;
|
export 'package:vector_math/vector_math.dart' show Matrix4;
|
||||||
|
16
packages/flutter/lib/src/fn3/unique_component.dart
Normal file
16
packages/flutter/lib/src/fn3/unique_component.dart
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// 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/src/fn3.dart';
|
||||||
|
|
||||||
|
abstract class UniqueComponent<T extends State> extends StatefulComponent {
|
||||||
|
UniqueComponent({ GlobalKey key }) : super(key: key ?? new GlobalKey());
|
||||||
|
|
||||||
|
T createState();
|
||||||
|
|
||||||
|
T get currentState {
|
||||||
|
GlobalKey globalKey = key;
|
||||||
|
return globalKey.currentState;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user