google_fonts: ^2.3.1已经解决了google_fonts: 2.3.0存在的问题。
嗯!使用插入符号(^)的所有包含google_fonts的项目都会遇到这个问题。
在Dart中,插入符号(^)用于表示允许使用的版本号范围。具体来说,从指定版本开始,到下一个非破坏性版本之前的任何版本都可以。
因此,google_fonts: ^2.2.0与“>=2.2.0 <3.0.0”相同,是这种较长形式的简写方式。^表示,我希望自动使用来自Pub的最新程序包,只要该更新不会破坏我的应用程序。目前,google_fonts: 2.3.0存在一些问题。
解决步骤:
完成!您现在可以愉快地编码了!!!
我不知道您是否尝试过这个方法,但是这个问题在这里有描述:issue 219
简而言之,您需要使用google_fonts v2.3来配合Flutter v2.1或更高版本。
flutter test test/widget_test.dart
)时,它突然出现了。这个错误可能意味着在执行 flutter pub upgrade
后会有大量 Flutter 测试失败。我确认所提供的建议解决了这个问题-特别是,我将 pubspec.yaml
中的依赖从 google_fonts: ^2.2.0
更改为 google_fonts: 2.2.0
。 - mzimmermann请按以下步骤解决问题:
将软件包版本设置为google_fonts: 2.2.0,它应该可以正常工作
正如他们所说,在 pubspec.yaml 的依赖项中,只需从 Google 字体的版本号前面删除 ^(即将 google_fonts: ^2.3.1 改为 google_fonts: 2.3.1),然后运行 flutter clean && pub get。
我曾经遇到过同样的问题,但这并不是依赖项的问题,与其他人不同。当我将“shape”放在样式的范围内时,我不再遇到此错误。
以下是我的问题示例:
ElevatedButton(
child: Text('Sign in with Google'),
onPressed: _signInWithGoogle,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
foregroundColor: Colors.black,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
),
),
当“shape”停止出现错误时的示例:
ElevatedButton(
child: Text('Sign in with Google'),
onPressed: _signInWithGoogle,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
foregroundColor: Colors.black,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
),
),
),