blob: be060bc0ee1bb4d4e6afc63c5727885580dfd862 [file] [log] [blame]
// Copyright 2014 The Flutter 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:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
class TestUniqueWidget extends UniqueWidget<TestUniqueWidgetState> {
const TestUniqueWidget({ required super.key });
TestUniqueWidgetState createState() => TestUniqueWidgetState();
class TestUniqueWidgetState extends State<TestUniqueWidget> {
Widget build(BuildContext context) => Container();
void main() {
testWidgets('Unique widget control test', (WidgetTester tester) async {
final TestUniqueWidget widget = TestUniqueWidget(key: GlobalKey<TestUniqueWidgetState>());
await tester.pumpWidget(widget);
final TestUniqueWidgetState state = widget.currentState!;
expect(state, isNotNull);
await tester.pumpWidget(Container(child: widget));
expect(widget.currentState, equals(state));