-
Notifications
You must be signed in to change notification settings - Fork 106
/
box_fit.dart
90 lines (80 loc) · 2.21 KB
/
box_fit.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
// 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';
class BoxFitDiagram extends StatelessWidget with DiagramMetadata {
const BoxFitDiagram(this.fit, {super.key});
final BoxFit fit;
@override
String get name => 'box_fit_${fit.name}';
@override
Widget build(BuildContext context) {
final Widget inner = Container(
decoration: BoxDecoration(
border: Border.all(width: 2.0, color: Colors.blue[300]!),
color: Colors.blue[100],
),
child: FittedBox(
fit: fit,
child: Container(
width: 5.0 * 13.0,
height: 5.0 * 13.0,
decoration: BoxDecoration(
border: Border.all(width: 2.0, color: Colors.teal[700]!),
color: Colors.teal[600],
),
child: GridPaper(
color: Colors.teal[400]!,
divisions: 1,
interval: 18.5,
subdivisions: 1,
child: Center(
child: Text(fit.toString().split('.').join('\n')),
),
),
),
),
);
return SizedBox(
key: UniqueKey(),
width: 300.0,
height: 90.0,
child: Row(
key: GlobalObjectKey(fit),
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
flex: 180,
child: Center(
child: AspectRatio(
aspectRatio: 2.5,
child: inner,
),
),
),
const SizedBox(width: 30.0),
Expanded(
flex: 80,
child: inner,
),
const SizedBox(width: 30.0),
Expanded(
flex: 200,
child: inner,
),
],
),
);
}
}
class BoxFitDiagramStep extends DiagramStep {
@override
final String category = 'painting';
final List<BoxFitDiagram> _diagrams = <BoxFitDiagram>[
for (final BoxFit fit in BoxFit.values) BoxFitDiagram(fit),
];
@override
Future<List<BoxFitDiagram>> get diagrams async => _diagrams;
}