2017-08-16 124 views
0

我正在使用一个Flutter滑块小部件,在滑块上点击/拖动可以移动滑块的progress/activeColor。但是,似乎只有直接触摸滑块会导致事件发生,并且很难始终将手指直接触摸滑块。有没有办法扩展滑块的“触摸区域”? 这是我有:如何增加我的Flutter滑块小部件的“触摸区域”?

return new Center(
    child: new Container(
     height: 2.0, 
     child: new Slider(
     min: 0.0, 
     max: 1.0, 
     activeColor: Colors.grey[50], 
     value: _getUnitProgress(model), 
     onChanged: (double value) => _unitSeek(value, model), 
    ), 
    ), 
); 

回答

0

你不想来包装你滑块与高度的容器。滑块有一个_kReactionRadius,它扩展了用户的触摸区域。这意味着,用户不必直接接触到滑块的水平线来触发的onTap():

return Center(
    child: new Slider(
    min: 0.0, 
    max: 1.0, 
    activeColor: Colors.grey[50], 
    value: _getUnitProgress(model), 
    onChanged: (double value) => _unitSeek(value, model), 
), 
);