Flutter如何在此框架中构建自己的滚动物理?

问题描述

我想构建自己的自定义滚动体。我跟随着一个教程学习如何做到这一点。但是我不明白这种物理和模拟结构在Flutter中是如何工作的。不幸的是,关于该主题的教程或文档并不多。您能否解释一下Flutter中的物理和模拟工作原理。如何检测滑动? Flutter是否定义了“ MySimulation”类中的决赛?我可以使用哪个?我需要这样写还是可以使用其他方式?

我如何在自己的书面框架中制作自己的ScrollPhysics?

感谢您的帮助

import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:math' as math;




class MySimulation extends Simulation {
  final double initPosition;
  final double velocity;

  MySimulation({this.initPosition,this.velocity});

  @override
  double x(double time) {
    return initPosition;
  }

  @override
  double dx(double time) {
    return velocity;
  }

  @override
  bool isDone(double time) {
    return false;
  }
}

class MyScrollPhysics extends ScrollPhysics {
  @override
  ScrollPhysics applyTo(ScrollPhysics ancestor) {
    return MyScrollPhysics();
  }

  @override
  Simulation createClampingScrollSimulation(
      ScrollMetrics position,double velocity) {
    return MySimulation(
      initPosition: 0,velocity: 0,);
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...