Commit e1b8f0b6 authored by Adam Barth's avatar Adam Barth

Add UniqueComponent helper for creating components with unique states

parent ff567695
...@@ -47,5 +47,6 @@ export 'fn3/theme.dart'; ...@@ -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;
// 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;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment