import 'dart:math'; import 'package:flutter/material.dart'; import '../../styles/color_schemes.g.dart'; import '../../widget/matrix_gesture_detector.dart'; class TransformDemo extends StatelessWidget { @override Widget build(BuildContext context) { final ValueNotifier notifier = ValueNotifier(Matrix4.identity()); return Scaffold( backgroundColor: Colors.grey, appBar: AppBar( title: Text('Transform Demo'), ), body: MatrixGestureDetector( onMatrixUpdate: (m, tm, sm, rm) { notifier.value = m; }, child: AnimatedBuilder( animation: notifier, builder: (ctx, child) { return Transform( transform: notifier.value, child: Stack( children: [ Container( color: Colors.white30, ), Positioned.fill( child: Container( transform: notifier.value, child: FittedBox( fit: BoxFit.contain, child: Icon( Icons.favorite, color: Colors.deepPurple.withOpacity(0.5), ), ), ), ), Container( decoration: FlutterLogoDecoration(), padding: EdgeInsets.all(32), alignment: Alignment(0, -0.5), child: Text( 'use your two fingers to translate / rotate / scale ...', style: Theme.of(context).textTheme.bodyText1, textAlign: TextAlign.center, ), ), ], ), ); }, ), ), ); } } void main() { runApp(MaterialApp( theme: ThemeData(useMaterial3: true, colorScheme: lightColorScheme), home: TransformDemo())); }