matrix4_transform 3.0.0 copy "matrix4_transform: ^3.0.0" to clipboard
matrix4_transform: ^3.0.0 copied to clipboard

Helper math class for easily creating Matrix4 transformations, that you can use in Container's transform parameter and elsewhere.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:matrix4_transform/matrix4_transform.dart';

// Developed by Marcelo Glasberg (Aug 2019).
// For more info, see: https://pub.dartlang.org/packages/matrix4_transform

void main() async => runApp(MaterialApp(home: Demo()));

class Demo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Scale and Translate Example')),
      body: Stack(
        children: [
          box1(),
          box2(),
          box3(),
          box4(),
        ],
      ),
    );
  }

  Center box1() => Center(child: box('140×180'));

  Center box2() {
    return Center(
      child: Container(
        transform:
            Matrix4Transform().scaleBy(x: 1.5, y: 1.5, origin: Offset(140 / 2, 180 / 2)).matrix4,
        child: box('140×180\nScale 1.5×1.5 (origin 70×90)'),
      ),
    );
  }

  Center box3() {
    return Center(
      child: Container(
        transform: Matrix4Transform().translate(x: 140, y: 180).scaleBy(x: 1.5, y: 1.5).matrix4,
        child: box('140×180\nScale 1.5×1.5\n(origin 140×180)'),
      ),
    );
  }

  Center box4() {
    return Center(
      child: Container(
        transform: Matrix4Transform().scaleBy(x: 1.5, y: 1.5).translate(x: 140, y: 180).matrix4,
        child: box('140×180\nScale 1.5×1.5\n(origin 140×180)'),
      ),
    );
  }

  Container box(String text) {
    return Container(
      color: Colors.red.withOpacity(0.5),
      width: 140,
      height: 180,
      child: Text(text, style: TextStyle(fontSize: 10.5)),
    );
  }
}
167
likes
0
pub points
94%
popularity

Publisher

verified publisherglasberg.dev

Helper math class for easily creating Matrix4 transformations, that you can use in Container's transform parameter and elsewhere.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on matrix4_transform