1// Copyright 2014 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import 'package:flutter/material.dart';
6import 'package:flutter_test/flutter_test.dart';
7
8void main() {
9 testWidgets('Rotated box control test', (WidgetTester tester) async {
10 final List<String> log = <String>[];
11 final Key rotatedBoxKey = UniqueKey();
12
13 await tester.pumpWidget(
14 Center(
15 child: RotatedBox(
16 key: rotatedBoxKey,
17 quarterTurns: 1,
18 child: Row(
19 textDirection: TextDirection.ltr,
20 mainAxisSize: MainAxisSize.min,
21 children: <Widget>[
22 GestureDetector(
23 onTap: () {
24 log.add('left');
25 },
26 child: Container(width: 100.0, height: 40.0, color: Colors.blue[500]),
27 ),
28 GestureDetector(
29 onTap: () {
30 log.add('right');
31 },
32 child: Container(width: 75.0, height: 65.0, color: Colors.blue[500]),
33 ),
34 ],
35 ),
36 ),
37 ),
38 );
39
40 final RenderBox box = tester.renderObject(find.byKey(rotatedBoxKey));
41 expect(box.size.width, equals(65.0));
42 expect(box.size.height, equals(175.0));
43
44 await tester.tapAt(const Offset(420.0, 280.0));
45 expect(log, equals(<String>['left']));
46 log.clear();
47
48 await tester.tapAt(const Offset(380.0, 320.0));
49 expect(log, equals(<String>['right']));
50 log.clear();
51 });
52}
53

Provided by KDAB

Privacy Policy
Learn more about Flutter for embedded and desktop on industrialflutter.com