map_test.dart 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import 'dart:math';
  2. import 'package:flutter/material.dart';
  3. import '../../styles/color_schemes.g.dart';
  4. import '../../widget/matrix_gesture_detector.dart';
  5. class TransformDemo extends StatelessWidget {
  6. @override
  7. Widget build(BuildContext context) {
  8. final ValueNotifier<Matrix4> notifier = ValueNotifier(Matrix4.identity());
  9. return Scaffold(
  10. backgroundColor: Colors.grey,
  11. appBar: AppBar(
  12. title: Text('Transform Demo'),
  13. ),
  14. body: MatrixGestureDetector(
  15. onMatrixUpdate: (m, tm, sm, rm) {
  16. notifier.value = m;
  17. },
  18. child: AnimatedBuilder(
  19. animation: notifier,
  20. builder: (ctx, child) {
  21. return Transform(
  22. transform: notifier.value,
  23. child: Stack(
  24. children: <Widget>[
  25. Container(
  26. color: Colors.white30,
  27. ),
  28. Positioned.fill(
  29. child: Container(
  30. transform: notifier.value,
  31. child: FittedBox(
  32. fit: BoxFit.contain,
  33. child: Icon(
  34. Icons.favorite,
  35. color: Colors.deepPurple.withOpacity(0.5),
  36. ),
  37. ),
  38. ),
  39. ),
  40. Container(
  41. decoration: FlutterLogoDecoration(),
  42. padding: EdgeInsets.all(32),
  43. alignment: Alignment(0, -0.5),
  44. child: Text(
  45. 'use your two fingers to translate / rotate / scale ...',
  46. style: Theme.of(context).textTheme.bodyText1,
  47. textAlign: TextAlign.center,
  48. ),
  49. ),
  50. ],
  51. ),
  52. );
  53. },
  54. ),
  55. ),
  56. );
  57. }
  58. }
  59. void main() {
  60. runApp(MaterialApp(
  61. theme: ThemeData(useMaterial3: true, colorScheme: lightColorScheme),
  62. home: TransformDemo()));
  63. }