-
-
Save tech-andgar/12188f6cd146ed48e3012e353cf25373 to your computer and use it in GitHub Desktop.
MatrixTransition demo with rotateX, rotateY, & rotateZ matrices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math'; | |
import 'package:flutter/material.dart'; | |
import 'package:window_manager/window_manager.dart'; | |
void main() async { | |
WidgetsFlutterBinding.ensureInitialized(); | |
await windowManager.ensureInitialized(); | |
const WindowOptions windowOptions = WindowOptions( | |
size: Size(800, 600), | |
center: true, | |
backgroundColor: Colors.transparent, | |
skipTaskbar: false, | |
titleBarStyle: TitleBarStyle.hidden, | |
windowButtonVisibility: true, | |
); | |
windowManager.waitUntilReadyToShow(windowOptions, () async { | |
await windowManager.show(); | |
await windowManager.focus(); | |
}); | |
runApp(const MatrixTransitionExampleApp()); | |
} | |
class MatrixTransitionExampleApp extends StatelessWidget { | |
const MatrixTransitionExampleApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return const MaterialApp( | |
home: MatrixTransitionExample(), | |
); | |
} | |
} | |
class MatrixTransitionExample extends StatefulWidget { | |
const MatrixTransitionExample({super.key}); | |
@override | |
State<MatrixTransitionExample> createState() => | |
_MatrixTransitionExampleState(); | |
} | |
/// [AnimationController]s can be created with `vsync: this` because of | |
/// [TickerProviderStateMixin]. | |
class _MatrixTransitionExampleState extends State<MatrixTransitionExample> | |
with TickerProviderStateMixin { | |
late AnimationController _controller; | |
late Animation<double> _animation; | |
@override | |
void initState() { | |
super.initState(); | |
_controller = AnimationController( | |
duration: const Duration(seconds: 2), | |
vsync: this, | |
)..repeat(); | |
_animation = CurvedAnimation( | |
parent: _controller, | |
curve: Curves.linear, | |
); | |
} | |
@override | |
void dispose() { | |
_controller.dispose(); | |
super.dispose(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Center( | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
children: [ | |
MatrixTransition( | |
animation: _animation, | |
child: const Padding( | |
padding: EdgeInsets.all(8.0), | |
child: FlutterLogo(size: 150.0), | |
), | |
onTransform: (double value) { | |
return Matrix4.identity()..rotateX(pi * 2.0 * value); | |
}, | |
), | |
MatrixTransition( | |
animation: _animation, | |
child: const Padding( | |
padding: EdgeInsets.all(8.0), | |
child: FlutterLogo(size: 150.0), | |
), | |
onTransform: (double value) { | |
return Matrix4.identity()..rotateY(pi * 2.0 * value); | |
}, | |
), | |
MatrixTransition( | |
animation: _animation, | |
child: const Padding( | |
padding: EdgeInsets.all(8.0), | |
child: FlutterLogo(size: 150.0), | |
), | |
onTransform: (double value) { | |
return Matrix4.identity()..rotateZ(pi * 2.0 * value); | |
}, | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment