我试图在 Flutter 中使用计算功能。
void _blockPressHandler(int row, int col) async {
// Called when user clicks any block on the sudoku board . row and col are the corresponding row and col values ;
setState(() {
widget.selCol = col;
}
});
bool boardSolvable;
boardSolvable = await compute(SudokuAlgorithm.isBoardInSudoku , widget.board , widget.size) ;
}
isBoardInSudoku
是数独算法类的静态方法。存在于另一个文件中。写上面的代码,告诉我
error: The argument type '(List<List<int>>, int) → bool' can't be assigned to the parameter type '(List<List<int>>) → bool'. (argument_type_not_assignable at [just_sudoku] lib/sudoku/SudokuPage.dart:161)
我该如何解决?可以在不将数独算法类的方法从其文件中取出的情况下完成吗?如何向计算函数发送多个参数?
static bool isBoardInSudoku(List<List<int>>board , int size ){ }
是我的 isBoardInSudoku 函数。
只需将参数放入 Map 中并传递即可。
没有办法将多个参数传递给compute
因为它是启动隔离的便利函数,除了单个参数之外也不允许任何其他内容。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)