我有以下代码:
Grid get _gridA => $['myGridA'];
Grid get _gridB => $['myGridB'];
Grid get _gridC => $['myGridC'];
List<Grid> _grids = [];
Grid _selectedGrid = null;
attached(){
// Sets array and sets the defaul selected Grid.
_grids = [_gridA, _gridB, _gridC];
_selectedGrid = _grids[0];
}
onTabChange(index, _){
//crashes here, because at this point, _grids is still [] and not [a,b,c]
_selectedGrid = _grids[index];
}
有没有办法解决这个问题? set
也没有做任何事情。
当我尝试在我将其定义为[]
的顶部实例化时,我会得到错误,我的数组中不能包含非静态项。