相关疑难解决方法(0)

Flutter:如何移动,旋转和缩放容器?

我想制作一个可以拖动,缩放和旋转的容器。我能够实现变焦。下面是我的代码:

//variable declaration
  double _scale = 1.0;
  double _previousScale;
  var yOffset = 400.0;
  var xOffset = 50.0;
  var rotation = 0.0;
  var lastRotation = 0.0;
Run Code Online (Sandbox Code Playgroud)

//构建方法

@override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Center(
          child: GestureDetector(
            onScaleStart: (scaleDetails) {
              _previousScale = _scale;
              print(' scaleStarts = ${scaleDetails.focalPoint}');
            },
            onScaleUpdate: (scaleUpdates){
              //ScaleUpdateDetails
              rotation += lastRotation - scaleUpdates.rotation;
              lastRotation = scaleUpdates.rotation;
              print("lastRotation = $lastRotation");
              print(' scaleUpdates = ${scaleUpdates.scale} rotation = ${scaleUpdates.rotation}');
              setState(() => _scale = _previousScale * scaleUpdates.scale);
            },
            onScaleEnd: …
Run Code Online (Sandbox Code Playgroud)

zoom rotation pan gesture flutter

1
推荐指数
1
解决办法
2072
查看次数

标签 统计

flutter ×1

gesture ×1

pan ×1

rotation ×1

zoom ×1