-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathrow.dart
115 lines (105 loc) · 3.51 KB
/
row.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright 2013 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 'dart:async';
import 'package:flutter/material.dart';
import 'diagram_step.dart';
const String _row = 'row';
const String _rowError = 'row_error';
const String _rowFixed = 'row_fixed';
const String _rowTextDirection = 'row_textDirection';
class RowDiagram extends StatelessWidget with DiagramMetadata {
const RowDiagram(this.name, {super.key});
@override
final String name;
@override
Widget build(BuildContext context) {
Widget returnWidget;
switch (name) {
case _row:
returnWidget = const Row(
children: <Widget>[
Expanded(
child: Text(
'Deliver features faster',
textAlign: TextAlign.center,
),
),
Expanded(
child: Text('Craft beautiful UIs', textAlign: TextAlign.center),
),
Expanded(child: FittedBox(child: FlutterLogo())),
],
);
break;
case _rowError:
returnWidget = const Row(
children: <Widget>[
FlutterLogo(),
Text(
"Flutter's hot reload helps you quickly and easily experiment, build UIs, add features, and fix bug faster. Experience sub-second reload times, without losing state, on emulators, simulators, and hardware for iOS and Android.",
),
Icon(Icons.sentiment_very_satisfied),
],
);
break;
case _rowFixed:
returnWidget = const Row(
children: <Widget>[
FlutterLogo(),
Expanded(
child: Text(
"Flutter's hot reload helps you quickly and easily experiment, build UIs, add features, and fix bug faster. Experience sub-second reload times, without losing state, on emulators, simulators, and hardware for iOS and Android.",
),
),
Icon(Icons.sentiment_very_satisfied),
],
);
break;
case _rowTextDirection:
returnWidget = const Row(
textDirection: TextDirection.rtl,
children: <Widget>[
FlutterLogo(),
Expanded(
child: Text(
"Flutter's hot reload helps you quickly and easily experiment, build UIs, add features, and fix bug faster. Experience sub-second reload times, without losing state, on emulators, simulators, and hardware for iOS and Android.",
),
),
Icon(Icons.sentiment_very_satisfied),
],
);
break;
default:
throw Exception('unknown $runtimeType diagram type: $name');
}
return ConstrainedBox(
key: UniqueKey(),
constraints: BoxConstraints.tight(const Size(400.0, 250.0)),
child: Container(
alignment: FractionalOffset.center,
padding: const EdgeInsets.all(5.0),
color: Colors.white,
child: returnWidget,
),
);
}
@override
Set<Pattern> get expectedErrors {
return <Pattern>{
if (name == _rowError)
RegExp(r'A RenderFlex overflowed by \d+ pixels on the right.'),
};
}
}
class RowDiagramStep extends DiagramStep {
@override
final String category = 'widgets';
@override
Future<List<RowDiagram>> get diagrams async => <RowDiagram>[
const RowDiagram(_row),
const RowDiagram(_rowError),
const RowDiagram(_rowFixed),
const RowDiagram(_rowTextDirection),
];
}