mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Add a way of having keys based on numeric types or DateTimes by having a ValueKey<T> class. Remove the redundant ways of declaring things, except for leaving one shorthand -- you can say `new Key(s)` instead of `new ValueKey<String>(s)`.
75 lines
1.5 KiB
Dart
75 lines
1.5 KiB
Dart
import 'package:sky/widgets.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import 'widget_tester.dart';
|
|
|
|
void main() {
|
|
test('Mimic can track tree movements', () {
|
|
GlobalKey globalKey = new GlobalKey();
|
|
WidgetTester tester = new WidgetTester();
|
|
|
|
tester.pumpFrame(() {
|
|
return new Flex([
|
|
new Mimicable(
|
|
key: globalKey,
|
|
child: new Container(
|
|
key: new Key('inner'),
|
|
height: 10.0,
|
|
width: 10.0
|
|
)
|
|
)
|
|
]);
|
|
});
|
|
|
|
bool mimicReady = false;
|
|
|
|
tester.pumpFrame(() {
|
|
return new Flex([
|
|
new Mimicable(
|
|
key: globalKey,
|
|
child: new Container(
|
|
height: 10.0,
|
|
width: 10.0
|
|
)
|
|
),
|
|
new SizedBox(
|
|
height: 10.0,
|
|
width: 10.0,
|
|
child: new Mimic(
|
|
original: globalKey,
|
|
onMimicReady: () {
|
|
mimicReady = true;
|
|
}
|
|
)
|
|
)
|
|
]);
|
|
});
|
|
|
|
expect(mimicReady, isTrue);
|
|
|
|
tester.pumpFrame(() {
|
|
return new Flex([
|
|
new Container(
|
|
key: new Key('outer'),
|
|
height: 10.0,
|
|
width: 10.0,
|
|
child: new Mimicable(
|
|
key: globalKey,
|
|
child: new Container(
|
|
key: new Key('inner'),
|
|
height: 10.0,
|
|
width: 10.0
|
|
)
|
|
)
|
|
),
|
|
new SizedBox(
|
|
height: 10.0,
|
|
width: 10.0,
|
|
child: new Mimic(original: globalKey)
|
|
)
|
|
]);
|
|
});
|
|
|
|
});
|
|
}
|