1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00
This commit is contained in:
Brett Morgan
2022-05-11 12:48:11 -07:00
committed by GitHub
parent fb00d0a102
commit ccd68f34e2
242 changed files with 1719 additions and 1430 deletions

View File

@@ -15,7 +15,7 @@ void main() {
}
class Cell extends StatefulWidget {
const Cell({Key key}) : super(key: key);
const Cell({Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() => _CellState();
@@ -26,8 +26,8 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
static final AccelerometerEvent defaultPosition = AccelerometerEvent(0, 0, 0);
int cellNumber = 0;
Random _random;
AppLifecycleState appLifecycleState;
Random? _random;
AppLifecycleState? appLifecycleState;
@override
void initState() {
@@ -62,8 +62,8 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
Color randomLightColor() {
_random ??= Random(cellNumber);
return Color.fromARGB(255, _random.nextInt(50) + 205,
_random.nextInt(50) + 205, _random.nextInt(50) + 205);
return Color.fromARGB(255, _random!.nextInt(50) + 205,
_random!.nextInt(50) + 205, _random!.nextInt(50) + 205);
}
@override
@@ -113,15 +113,20 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
: Stream.value(defaultPosition),
initialData: defaultPosition,
builder: (context, snapshot) {
final data = snapshot.data;
if (data == null) {
return const CircularProgressIndicator.adaptive();
}
return Transform(
// Figure out the phone's orientation relative
// to gravity's direction. Ignore the z vector.
transform: Matrix4.rotationX(
snapshot.data.y / gravity * pi / 2)
..multiply(Matrix4.rotationY(
snapshot.data.x / gravity * pi / 2)),
alignment: Alignment.center,
child: const FlutterLogo(size: 72));
// Figure out the phone's orientation relative
// to gravity's direction. Ignore the z vector.
transform: Matrix4.rotationX(
data.y / gravity * pi / 2,
)..multiply(
Matrix4.rotationY(data.x / gravity * pi / 2)),
alignment: Alignment.center,
child: const FlutterLogo(size: 72),
);
},
),
),

View File

@@ -69,7 +69,7 @@ class CounterModel extends ChangeNotifier {
/// It offers two routes, one suitable for displaying as a full screen and
/// another designed to be part of a larger UI.
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
@@ -86,7 +86,7 @@ class MyApp extends StatelessWidget {
/// Wraps [Contents] in a Material [Scaffold] so it looks correct when displayed
/// full-screen.
class FullScreenView extends StatelessWidget {
const FullScreenView({Key key}) : super(key: key);
const FullScreenView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
@@ -108,7 +108,7 @@ class FullScreenView extends StatelessWidget {
class Contents extends StatelessWidget {
final bool showExit;
const Contents({this.showExit = false, Key key}) : super(key: key);
const Contents({Key? key, this.showExit = false}) : super(key: key);
@override
Widget build(BuildContext context) {