解決辦法:https://blog.csdn.net/u013297881/article/details/103633429
第一種方法:
在InkResponse外圍添加Container简识,然后在Container中添加color屬性
return Scaffold(
? ? appBar: AppBar(
? ? ? title: Text("title"),
? ? ),
? ? body: Container(
? ? ? child: InkResponse(
? ? ? ? child: Padding(
? ? ? ? ? padding: EdgeInsets.all(20),
? ? ? ? ? child: Text("click me",style: TextStyle(color: Colors.black),),
? ? ? ? ),
? ? ? ? onTap: () {
? ? ? ? ? print("object");
? ? ? ? },
? ? ? ),
? ? ? color: Colors.red,
? ? ),
? ? );
第二種方法:
設(shè)置InkResponse的highlightColor為透明案站,同時設(shè)置radius為0,代碼如下:
return Scaffold(
? appBar: AppBar(
? ? title: Text("title"),
? ),
? body: InkResponse(
? ? highlightColor: Colors.transparent,
? ? radius: 0.0,
? ? child: Padding(
? ? ? padding: EdgeInsets.all(20),
? ? ? child: Text(
? ? ? ? "click me",
? ? ? ? style: TextStyle(color: Colors.black),
? ? ? ),
? ? ),
? ? onTap: () {
? ? ? print("object");
? ? },
? ),
);
第三種方法:使用 GestureDetector 組件 里面也有ontag 點擊方法