日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

gesturedetector.java_我的flutter代码中的GestureDetector不起作用

發(fā)布時(shí)間:2023/12/10 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 gesturedetector.java_我的flutter代码中的GestureDetector不起作用 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

我正在玩flip_card package(這個(gè)軟件包會(huì)創(chuàng)建一張卡片,當(dāng)你點(diǎn)擊它時(shí),它會(huì)翻轉(zhuǎn)卡片并顯示卡片的正面或背面) . 我想要做的是,每次點(diǎn)擊卡片時(shí)顯示不同的圖像,并且卡片翻轉(zhuǎn)到正面 .

為此,我將flip_card example修改為有狀態(tài)小部件,并使用GestureDetector檢測(cè)水龍頭:

_renderContent(context) {

return Card(

elevation: 0.0,

margin: EdgeInsets.only(left: 32.0, right: 32.0, top: 10.0, bottom: 0.0),

color: Color(0x00000000),

child: FlipCard(

direction: FlipDirection.HORIZONTAL,

front: GestureDetector(

behavior: HitTestBehavior.opaque,

onTap: _tapHandler,

child: Container(

decoration: BoxDecoration(

color: Color(0xFF006666),

borderRadius: BorderRadius.all(Radius.circular(8.0)),

boxShadow: [BoxShadow(blurRadius: 15.0, spreadRadius: 0.8)],

image: DecorationImage(

image: AssetImage(_cards[_cardInd]),

fit: BoxFit.cover,

)),

child: Column(

mainAxisAlignment: MainAxisAlignment.center,

children: [

Text('Back', style: Theme.of(context).textTheme.headline),

Text('Click here to flip front',

style: Theme.of(context).textTheme.body1),

],

),

),

),

back: Container(

decoration: BoxDecoration(

color: Color(0xFF006666),

borderRadius: BorderRadius.all(Radius.circular(8.0)),

boxShadow: [BoxShadow(blurRadius: 15.0, spreadRadius: 0.8)],

image: DecorationImage(

image: AssetImage(_cards[0]),

fit: BoxFit.cover,

)),

child: Column(

mainAxisAlignment: MainAxisAlignment.center,

children: [

Text('Back', style: Theme.of(context).textTheme.headline),

Text('Click here to flip front',

style: Theme.of(context).textTheme.body1),

],

),

),

),

);

}

而tapHandler函數(shù)是:

void _tapHandler() {

setState(() {

_cardInd = x.nextInt(_cards.length);

});

print("_cardInd $_cardInd");

}

_cardInd 是圖像資源列表 _cards 的索引 . 但是,GestureDetector不起作用 . 圖像不會(huì)改變,也不會(huì)在屏幕上打印 print("_cardInd $_cardInd"); .

有人可以幫助我,以便當(dāng)我點(diǎn)擊卡片時(shí)圖像會(huì)發(fā)生變化嗎?

總結(jié)

以上是生活随笔為你收集整理的gesturedetector.java_我的flutter代码中的GestureDetector不起作用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。