how to focus on listview items in android tv app on flutter
after trying many ways I found an easy and effective way to doing this using InkWell.
widget tree will look like => scaffold -> somewidgets -> ListView -> Inkwell -> Carosouls
we have to wrap widget in InkWell and use onTap , focusColor , onFocusChange in InkWell because InkWell it self having focus.
onFocusChange: (value) {
print(i);
setState(() {
hoverIndex = i;
widget.selectedIndex = i;
});
},
focusColor: Colors.transparent,
this on focus change function will be inside InkWell so it will call everytime user ilterate in ListView so according to that i (index) we can assign hoverIndex and according to hoverIndex we can change styling of ilterating element.
Aviraj Patel
Updated on December 31, 2022Comments
-
Aviraj Patel over 1 year
I want to build an android tv app in flutter almost everything is done but one problem is I'm not able to focus(like some pop-up effect or border change anything that tells the user that you're on this item right now) item we are iterating in Listview.image of what I want in app
but I'm not able to give this focus. I tried with FocusScope -> Listview - > focus node but it is not giving exact behaviour in first and last index, and also it's not working in the homepage where multiple listviews are there.
-
Aviraj Patel over 2 yearsThank you for your answer,I tried this way but there is some problem with first index and last index in this way.
-
Aviraj Patel over 2 yearsi found alternate way of doing the same with InkWell.