| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- 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<Matrix4> 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: <Widget>[
- 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()));
- }
|