[英]Detect focused widget in flutter listview
我有一個水平的 listview.builder 小部件,列表中的每個子項大約是總寬度的 90℅,我如何檢測哪個小部件處於焦點。
這是我的小部件。
new ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: categories.length,
itemBuilder: (context, index) {
return new InkWell(
onTap: () {
Navigator
.of(context)
.push(new MaterialPageRoute(
builder: (_) => new StakePage(),
));
},
child: new Card(
child: new Container(
decoration: new BoxDecoration(
image: new DecorationImage(
fit: BoxFit.cover,
image: categories[index].cover,
colorFilter: new ColorFilter.mode(
Colors.black12,
BlendMode.screen),
),
),
constraints: new BoxConstraints(
maxWidth: 400.0,
maxHeight: 600.0),
height: size.height / 2,
width: size.width * 0.85,
),
),
);
}),
你可以用與你的widget visibility_detector
小部件,它會觸發一個回調,只要你的控件在屏幕上。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.