Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created February 16, 2020 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanlid/511f767d40447085b61ff11043b405d1 to your computer and use it in GitHub Desktop.
Save ryanlid/511f767d40447085b61ff11043b405d1 to your computer and use it in GitHub Desktop.
Transform 矩阵转换
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
title: "Transform矩阵转换示例",
home: LayoutDemo(),
));
}
class LayoutDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Transform矩阵转换示例"),
),
body: Center(
// 父容器作为背景
child: Container(
// 背景颜色
color: Colors.grey,
// 矩阵转换
child: Transform(
// 对齐方式
alignment: Alignment.topRight,
// 设置旋转值
transform: Matrix4.rotationZ(0.3),
// 设置旋转容器
child: Container(
padding: EdgeInsets.all(0.8),
color: Color(0xFFE8581C),
child: Text("Transform矩阵转换示例"),
),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment