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
|
import 'package:flutter/material.dart';
enum ArrowDirection {
left(Icons.arrow_back),
down(Icons.arrow_downward),
up(Icons.arrow_upward),
right(Icons.arrow_forward);
const ArrowDirection(this.icon);
final IconData icon;
}
class Note {
final double time;
final ArrowDirection direction;
double position = 0;
bool? wasHit;
Note({required this.time, required this.direction});
}
class Arrows extends StatelessWidget {
final List<Note> notes;
final double position;
const Arrows({super.key, required this.notes, required this.position});
@override
Widget build(BuildContext context) {
return Stack(
children: notes.map((note) {
double position = note.position * 10000; // * 20 * MediaQuery.of(context).size.height;
return Arrow(
position: position,
direction: note.direction,
);
}).toList());
}
}
class Arrow extends StatelessWidget {
final double position;
final ArrowDirection direction;
const Arrow({super.key, required this.position, required this.direction});
@override
Widget build(BuildContext context) {
return Positioned(
left: MediaQuery.of(context).size.width / 2 - 50, // Center the arrow
bottom: position + 50,
child: Icon(size: 100, color: Colors.redAccent.shade400, direction.icon),
);
}
}
|