将小部件添加到小部件树时如何为更改设置动画

时间:2019-04-08 10:00:52

标签: animation flutter

我有一个带状态的窗口小部件,该窗口小部件显示包含复选框的表单。表单的一部分(“ taxId”的文本字段)仅在复选框处于活动状态时显示。

Here's a mock of the screen

我可以更改状态并重新触发构建以完成该操作。我想做的就是动画化变化。我想让新的文本字段动起来(淡入并向下推其余的小部件),而不仅仅是出现。有没有办法通过隐式动画(类似于iOS上的UIStackView)来完成此任务?

1 个答案:

答案 0 :(得分:0)

将剩余的小部件向下推,我们可以使用

__global__ void insertKernel(struct SlabList* head_ref, int* new_key, 
                             int* new_val, int size, struct SlabList* SL, struct SlabList* temp)
{
    int id = blockIdx.x*blockDim.x + threadIdx.x;
    if(id<size/SLAB_SIZE){
        struct SlabList* new_node = (struct SlabList*)malloc(sizeof(struct SlabList));
        SlabList* SLnew = (SlabList *)atomicAdd((unsigned long long *)&SL,
                                                sizeof(struct SlabList));
        SlabList* oldhead = (SlabList *)atomicExch((unsigned long long *)&head_ref, 
                                        (unsigned long long)new_node);
        for(int j=0;j<SLAB_SIZE;j++){
            new_node->key[j] = new_key[id*SLAB_SIZE+j];
            new_node->val[j] = new_val[id*SLAB_SIZE+j];
        }
        new_node->next = oldhead;
        memcpy(SLnew, new_node, sizeof(struct SlabList));
    }
}

将TextField作为您的孩子并选中复选框来更改侦听器

AnimatedContainer(
  duration: Duration(seconds: 5),
  height: height,
  color: Color(0xff14ff65),
  child: Container(
      height: 50.0,
      child: yourchild,),
    ),
)