Flutter TextButton报错:不存在名为‘primary’的命名参数
你遇到的错误是因为Flutter版本更新后,TextButton.styleFrom的API发生了变更:旧版本中的primary参数已被移除,取而代之的是foregroundColor参数。
修改后的代码如下:
TextButton( onPressed: () {}, child: Text('Forgot your password?'), style: TextButton.styleFrom( foregroundColor: Theme.of(context).colorScheme.primary, ), ),
另外,不需要检查Gradle版本,这个错误和Gradle没有关系,完全是Flutter Material组件库的API变更导致的。
内容的提问来源于stack exchange,提问作者umarkaa
相关产品推荐
相关产品推荐

