Flutter Transform.rotate 对于 Compass 事件来说非常滞后并且不平滑,那么如何使其平滑

问题描述 投票:0回答:1

enter image description here

Flutter Transform.rotate 对于指南针事件来说非常滞后并且不平滑,因此如何使其平滑,因为它的跳跃移动不平滑,那么如何实现它 Flutter Qibla。

flutter smoothing compass
1个回答
1
投票

在颤振中实现平滑罗盘旋转的最佳方法是使用平滑罗盘颤振包这可能对某人有帮助 https://pub.dev/packages/smooth_compass_new

朝拜方向

SmoothCompass(
  height: 200,
  width: 200,
  isQiblahCompass: true,
  compassBuilder: (context,snapshot,child){
    return  AnimatedRotation(
      duration: const Duration(milliseconds:800),
      turns: snapshot?.data?.turns??0,
      child: Stack(
        children: [
          Positioned(
            top: 0,
            left: 0,
            right: 0,
            bottom: 0,
            child:Image.asset("assets/images/compass.png",fit: BoxFit.fill,),
          ),
          Positioned(
            top: 0,
            left: 0,
            right: 0,
            bottom: 0,
            child:AnimatedRotation(
              duration: const Duration(milliseconds: 500),
              turns: (snapshot?.data?.qiblahOffset??0)/360,
              //Place your qiblah needle here
              child: Container(
                decoration: const BoxDecoration(
                shape: BoxShape.circle,),
                child: const VerticalDivider(
                  color: Colors.grey,
                  thickness: 5,),
              )
            ),
          ),
        ],
      ),
    );
  },
)
© www.soinside.com 2019 - 2024. All rights reserved.