[英]How do i rotate my fractionally sized box in flutter?
I am new to flutter and I am trying to rotate my box offscreen.我是 flutter 的新手,我正在尝试将我的盒子旋转到屏幕外。 I am trying to rotate my box from this:
我试图从这个旋转我的盒子:
My code is :我的代码是:
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: FractionallySizedBox(
widthFactor: 0.5,
heightFactor: 0.5,
child: Container(
color: Colors.grey,
new RotationTransition(
turns: AlwaysStoppedAnimation:(15 / 360),
child: new FractionallySizedBox(
widthFactor: 0.5,
heightFactor: 0.5,
),)
),
),
),
);
}
}
I also want it like cut off and angled like how I have it in the second photo.我也希望它像第二张照片中那样被切断和倾斜。
You can use 2 Transform
s.您可以使用 2 个
Transform
。 One for the x-axis(the box is moved to the left) and one for the rotation:一个用于 x 轴(框向左移动),一个用于旋转:
import 'package:flutter/material.dart';
import 'dart:math' as math;
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Transform.translate(
offset: Offset(-120.0, 0.0),
child: Transform.rotate(
angle: math.pi / 5.0,
child: Container(
child: FractionallySizedBox(
widthFactor: 0.5,
heightFactor: 0.5,
child: Container(
color: Colors.grey,
),
),
),
),
)),
);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.