我在自定义无状态视图中有一个var viewer = new Cesium.Viewer ('cesiumContainer', {
scene3DOnly: false,
selectionIndication: false,
baseLayerPicker: true
});
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI4ODY0ZjkwMy03YmZlLTRlNGEtYmNhOS0xMDBlZGVmNDRkZGMiLCJpZCI6OTE4MSwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU1MzYxMjM5Mn0.aYYX1f1MQfg9zLFu0vnP3A56Neo4Y_N3G2O5tuTS0XM';
// Enable lighting based on sun/moon positions
viewer.scene.globe.enableLighting = true;
//Stazione di terra
var entity = viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(12.04, 44.23),
ellipse : {
semiMinorAxis : 150000.0,
semiMajorAxis : 150000.0,
material : Cesium.Color.YELLOW.withAlpha(0.5)
}
});
var ellipse = entity.ellipse;
ellipse.material = new Cesium.GridMaterialProperty({
color : Cesium.Color.YELLOW,
cellAlpha : 0.2,
lineCount : new Cesium.Cartesian2(8, 8),
lineThickness : new Cesium.Cartesian2(2.0, 2.0)
});
var GroundStation = viewer.entities.add({
name : 'Ground Station',
position : Cesium.Cartesian3.fromDegrees(12.07, 44.23),
point : {
pixelSize : 5,
color : Cesium.Color.RED,
outlineColor : Cesium.Color.WHITE,
outlineWidth : 2
},
label : {
text : 'Ground Station',
font : '14pt monospace',
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
outlineWidth : 2,
verticalOrigin : Cesium.VerticalOrigin.BOTTOM,
pixelOffset : new Cesium.Cartesian2(0, -9)
}
});
。
当GestureDetector
触发时,我显示一个显示一些信息的小吃店。
当用户快速单击多次时,它将永远显示小吃店。
onTap
我想禁用GestureDetector(
onTap: () {
Clipboard.setData(new ClipboardData(text: idText));
Scaffold.of(context).showSnackBar(SnackBar
(content: Text('ID copied')));
},
child: Icon(Icons.content_copy,),
}
几秒钟,然后才能再次单击它。
答案 0 :(得分:2)
将其包装在AbsorbPointer
var shouldAbsorb = true;
AbsorbPointer(
absorbing: shouldAbsorb,
child: GestureDetector(
onTap: () {
Navigator.of(context).pop();
},
child: Container(
color: Colors.red,
),
),
)
答案 1 :(得分:1)
您可以使用
bool _condition = true;
//...
GestureDetector(
onTap: _condition
? () {
// making it false when onTap() is pressed and after 1 second we'll make it true
setState(() => _condition = false);
Timer(Duration(seconds: 1), () => setState(() => _condition = true));
// your implementation
Clipboard.setData(new ClipboardData(text: idText));
Scaffold.of(context).showSnackBar(SnackBar
(content: Text('ID copied')));
}
: null, // disable onTap if condition is false
child: Icon(Icons.content_copy,),
),
答案 2 :(得分:1)
我个人使用GestureDetector
中的其他两种方法:
onTapDown
:当用户按下您的窗口小部件时。
onTapUp
:当用户离开窗口小部件时。
onTap
:是在点击并随后点击时显示的。如果用户将手指滑动太多,则Flutter会像取消水龙头一样。
onTapCancel
:用户取消时。
bool pressing = false;
GestureDetector(
// when user is pressing
onTapDown: (details) {
setState(() {
pressing = true;
});
},
// when user leaved
onTapUp: (details) {
setState(() {
pressing = false;
});
},
// when user leaved
onTapCancel: () {
setState(() {
pressing = false;
});
}
// the action to do when user tap
onTap: () {
// code...
}
);