小编Joh*_*Boy的帖子

您如何更改 didUpdateWidget 上颤动动画的持续时间?

我想按需更新计时器,但我不知道如何去做。我想检查在更改持续时间之前更新小部件时是否满足某些条件。到目前为止,我已经尝试使用“didUpdateWidget”函数,但我收到了一个代码错误。当我将 mixin 更改为 TickerProviderStateMixin 时,持续时间不会更新。

class _ProgressBarState extends State<ProgressBar>
    with SingleTickerProviderStateMixin {

  int _duration;
  int _position;
  bool _isPaused;

  Animation animation;
  AnimationController animationController;

  @override
  void initState() {
    super.initState();
    _duration = widget.duration;
    _position = widget.position;
    _isPaused = widget.isPaused;
    animationController = AnimationController(
    duration: Duration(milliseconds: _duration), vsync: this);
    animation = Tween(begin: 0.0, end: 1.0).animate(animationController);
  }

  @override
    void didUpdateWidget(ProgressBar oldWidget) {
      // TODO: implement didUpdateWidget
      setState(() {
        _duration = widget.duration;
        _position = widget.position;
        _isPaused = widget.isPaused;
      });

      updateController(oldWidget);
      super.didUpdateWidget(oldWidget);
    }


  void updateController(ProgressBar oldWidget){
    if(oldWidget.duration != …
Run Code Online (Sandbox Code Playgroud)

animation duration flutter

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

如何使Flutter上的按钮/图标按下可拖动的ReorderableListView ListTile?

所以我看了ReorderableListView演示,看到他们有

“第二:const Icon(Icons.drag_handle)”

但是在查看reorderable_list.dart文件时,我注意到整个列表仍然可以在LongPressDraggable上拖动[第424行]。所以,我怎么能明确作出任何的源代码或适当改变我自己,为了使图标的实际拖动手柄?

CheckboxListTile(
      key: Key(item.value),
      isThreeLine: true,
      value: item.checkState ?? false,
      onChanged: (bool newValue) {
        setState(() {
          item.checkState = newValue;
        });
      },
      title: Text('This item represents ${item.value}.'),
      subtitle: secondary,
      secondary: const Icon(Icons.drag_handle),  // Make this Icon drag source
    );
Run Code Online (Sandbox Code Playgroud)

谢谢

draggable flutter

6
推荐指数
2
解决办法
894
查看次数

Dart:如何将对象数组转换为哈希图数组?

我想将对象转换为哈希图,以便可以使用Flutter方法通道将数据发送到Android。

我已经考虑过逐一迭代并映射它们,但是必须有一种更优雅的方法来实现此目的...

例:

宾语

class Something {
  Something(this.what, this.the, this.fiddle);
  final String what;
  final int the;
  final bool fiddle;
}
Run Code Online (Sandbox Code Playgroud)

别的地方

List<Something> listOStuff = List<Something>.generate(10, (int index){
  return Something(index.toString(), index, false,);
});

List<Map<String, dynamic>> parseToMaps(List<Something> listOStuff){
  List<Map<String, dynamic>> results;
  // do something crazy to get listOStuff into Map of primitive values for each object
  // preferably a built in method of some sort... otherwise, i guess i'll just iterate...
  // maybe even an imported package if such thing exists
  return …
Run Code Online (Sandbox Code Playgroud)

object hashmap dart flutter

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

标签 统计

flutter ×3

animation ×1

dart ×1

draggable ×1

duration ×1

hashmap ×1

object ×1