flutter find a widget

55

flutter find a widget -

var keyA = UniqueKey();
var keyB = UniqueKey();
var keyC = UniqueKey();
var keyD = UniqueKey();
List<Widget> widgetList = List<Widget>();

widgetList.add(WidgetA(key: keyA));
widgetList.add(WidgetB(key: keyB));
widgetList.add(WidgetC(key: keyC));
widgetList.add(WidgetD(key: keyD));

Widget activeWidget = widgetList.firstWhere((x) => x.key == keyB);

Comments

Submit
0 Comments