Unverified Commit 27ac523e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Provide an initial rotation of the ExpansionIcon if isExpanded = true on initState (#15657)

* rotate expansion icon fully if initial state expanded = true

* add test case for initially expanded

* remove unused import

* Update expand_icon_test.dart

add linebreak

* import dart:math as math
parent 33fea5c1
// Copyright 2015 The Chromium Authors. All rights reserved. // Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:math' as math;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -72,6 +73,10 @@ class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateM ...@@ -72,6 +73,10 @@ class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateM
curve: Curves.fastOutSlowIn curve: Curves.fastOutSlowIn
) )
); );
// If the widget is initially expanded, rotate the icon without animating it.
if (widget.isExpanded) {
_controller.value = math.pi;
}
} }
@override @override
......
...@@ -67,6 +67,23 @@ void main() { ...@@ -67,6 +67,23 @@ void main() {
expect(expanded, isFalse); expect(expanded, isFalse);
}); });
testWidgets('ExpandIcon is rotated initially if isExpanded is true on first build', (WidgetTester tester) async {
bool expanded = true;
await tester.pumpWidget(
wrap(
child: new ExpandIcon(
isExpanded: expanded,
onPressed: (bool isExpanded) {
expanded = !isExpanded;
},
)
)
);
final RotationTransition rotation = tester.firstWidget(find.byType(RotationTransition));
expect(rotation.turns.value, 0.5);
});
} }
Widget wrap({ Widget child }) { Widget wrap({ Widget child }) {
......
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