mirror of
https://github.com/flutter/samples.git
synced 2026-03-21 20:08:16 +00:00
Flutter 3.29 beta (#2571)
This commit is contained in:
@@ -62,8 +62,12 @@ 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
|
||||
@@ -108,20 +112,25 @@ class _CellState extends State<Cell> with WidgetsBindingObserver {
|
||||
child: StreamBuilder<AccelerometerEvent>(
|
||||
// Don't continuously rebuild for nothing when the
|
||||
// cell isn't visible.
|
||||
stream: appLifecycleState == AppLifecycleState.resumed
|
||||
? accelerometerEventStream()
|
||||
: Stream.value(defaultPosition),
|
||||
stream:
|
||||
appLifecycleState == AppLifecycleState.resumed
|
||||
? accelerometerEventStream()
|
||||
: Stream.value(defaultPosition),
|
||||
initialData: defaultPosition,
|
||||
builder: (context, snapshot) {
|
||||
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(
|
||||
snapshot.data!.y / gravity * pi / 2,
|
||||
)..multiply(
|
||||
Matrix4.rotationY(
|
||||
snapshot.data!.x / gravity * pi / 2,
|
||||
),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: const FlutterLogo(size: 72),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -17,12 +17,7 @@ void main() {
|
||||
|
||||
final model = CounterModel();
|
||||
|
||||
runApp(
|
||||
ChangeNotifierProvider.value(
|
||||
value: model,
|
||||
child: const MyApp(),
|
||||
),
|
||||
);
|
||||
runApp(ChangeNotifierProvider.value(value: model, child: const MyApp()));
|
||||
}
|
||||
|
||||
/// This is on alternate entrypoint for this module to display Flutter UI in
|
||||
@@ -76,9 +71,7 @@ class MyApp extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Module Title',
|
||||
theme: ThemeData(
|
||||
colorSchemeSeed: Colors.blue,
|
||||
),
|
||||
theme: ThemeData(colorSchemeSeed: Colors.blue),
|
||||
routes: {
|
||||
'/': (context) => const FullScreenView(),
|
||||
'/mini': (context) => const Contents(),
|
||||
@@ -95,9 +88,7 @@ class FullScreenView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Full-screen Flutter with plugin'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('Full-screen Flutter with plugin')),
|
||||
body: const Contents(showExit: true),
|
||||
);
|
||||
}
|
||||
@@ -131,10 +122,7 @@ class Contents extends StatelessWidget {
|
||||
const Positioned.fill(
|
||||
child: Opacity(
|
||||
opacity: .25,
|
||||
child: FittedBox(
|
||||
fit: BoxFit.cover,
|
||||
child: FlutterLogo(),
|
||||
),
|
||||
child: FittedBox(fit: BoxFit.cover, child: FlutterLogo()),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
|
||||
@@ -4,7 +4,7 @@ description: An example Flutter module that uses a plugin.
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: ^3.5.0
|
||||
sdk: ^3.7.0-0
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
|
||||
Reference in New Issue
Block a user