为什么我不能使用 int 值来控制 flutter 中的图标颜色?

Why i cannot use int value to control my icon color in flutter?

我想更改我的网站图标是否推入它,但它没有发生,因为我无法使用 int 值来控制它。这是我的代码示例=>

class _WebViewExampleState extends State<WebViewExample> {
  final Completer<WebViewController> _controller = Completer<WebViewController>();
  int ctr=0;
...
 floatingActionButton: favoriteButton(),
...
Widget favoriteButton() {
    return FutureBuilder<WebViewController>(
        future: _controller.future,
        builder: (BuildContext context,
            AsyncSnapshot<WebViewController> controller) {
          if (controller.hasData) {
            return FloatingActionButton(
              backgroundColor: Colors.indigo,
              onPressed: () async {
                final String url = (await controller.data!.currentUrl())!;
                // ignore: deprecated_member_use
                Scaffold.of(context).showSnackBar(
                  SnackBar(content: Text('Favorited $url')),
                );
                setState(() {
                  ctr++;
                });
              },
              child: const Icon(Icons.favorite,
              <this place where i got the mistake> 
              color: this.ctr%2==1 ? Colors.red : Colors.white),
              </this place where i got the mistake>

            );
          }
          return Container();
        });
  }
}//end of the top row.

我把上面提到的 HTML 标记为“我弄错的地方”。错误是 Invalid constant value 我也试过声明里面的变量 favoriteButton.Why 不能用变量来检查条件?有人帮帮我吗?

请从图标小部件中删除常量

请检查我的代码

child: Icon(Icons.favorite,
              <this place where i got the mistake> 
              color: this.ctr%2==1 ? Colors.red : Colors.white),
              </this place where i got the mistake>

            );

这样你就可以使用可变值