|
|
@ -15,7 +15,7 @@ void main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class Cell extends StatefulWidget {
|
|
|
|
class Cell extends StatefulWidget {
|
|
|
|
const Cell({Key key}) : super(key: key);
|
|
|
|
const Cell({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() => _CellState();
|
|
|
|
State<StatefulWidget> createState() => _CellState();
|
|
|
@ -26,8 +26,8 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
|
|
|
|
static final AccelerometerEvent defaultPosition = AccelerometerEvent(0, 0, 0);
|
|
|
|
static final AccelerometerEvent defaultPosition = AccelerometerEvent(0, 0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
int cellNumber = 0;
|
|
|
|
int cellNumber = 0;
|
|
|
|
Random _random;
|
|
|
|
Random? _random;
|
|
|
|
AppLifecycleState appLifecycleState;
|
|
|
|
AppLifecycleState? appLifecycleState;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
@ -41,13 +41,13 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// Keep track of what the current platform lifecycle state is.
|
|
|
|
// Keep track of what the current platform lifecycle state is.
|
|
|
|
WidgetsBinding.instance.addObserver(this);
|
|
|
|
WidgetsBinding.instance!.addObserver(this);
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
void dispose() {
|
|
|
|
WidgetsBinding.instance.removeObserver(this);
|
|
|
|
WidgetsBinding.instance!.removeObserver(this);
|
|
|
|
super.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -62,8 +62,8 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
|
|
|
|
Color randomLightColor() {
|
|
|
|
Color randomLightColor() {
|
|
|
|
_random ??= Random(cellNumber);
|
|
|
|
_random ??= Random(cellNumber);
|
|
|
|
|
|
|
|
|
|
|
|
return Color.fromARGB(255, _random.nextInt(50) + 205,
|
|
|
|
return Color.fromARGB(255, _random!.nextInt(50) + 205,
|
|
|
|
_random.nextInt(50) + 205, _random.nextInt(50) + 205);
|
|
|
|
_random!.nextInt(50) + 205, _random!.nextInt(50) + 205);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
@ -117,9 +117,9 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
|
|
|
|
// Figure out the phone's orientation relative
|
|
|
|
// Figure out the phone's orientation relative
|
|
|
|
// to gravity's direction. Ignore the z vector.
|
|
|
|
// to gravity's direction. Ignore the z vector.
|
|
|
|
transform: Matrix4.rotationX(
|
|
|
|
transform: Matrix4.rotationX(
|
|
|
|
snapshot.data.y / gravity * pi / 2)
|
|
|
|
snapshot.data!.y / gravity * pi / 2)
|
|
|
|
..multiply(Matrix4.rotationY(
|
|
|
|
..multiply(Matrix4.rotationY(
|
|
|
|
snapshot.data.x / gravity * pi / 2)),
|
|
|
|
snapshot.data!.x / gravity * pi / 2)),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: const FlutterLogo(size: 72));
|
|
|
|
child: const FlutterLogo(size: 72));
|
|
|
|
},
|
|
|
|
},
|
|
|
|