小编Oma*_* Fd的帖子

生成器无法定位尚未迁移到空安全的库

尝试以下命令时会出现此问题:

flutter pub run build_runner build --delete-conflicting-outputs

错误信息:

[SEVERE] json_serializable:json_serializable on lib/models/shipping_address/shipping_address.dart:

Generator cannot target libraries that have not been migrated to null-safety.
package:deals_and_delivery/models/shipping_address/shipping_address.dart:6:7
  ?
6 ? class ShippingAddress {
  ?       ^^^^^^^^^^^^^^^
  ?
[INFO] Running build completed, took 3.6s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 49ms

[SEVERE] Failed after 3.7s
pub finished with exit code 1
Run Code Online (Sandbox Code Playgroud)

pubspec.yaml:

dependencies:
  json_annotation: ^4.0.0
  flutter:
    sdk: flutter
...
dev_dependencies:
  build_runner: ^1.11.5
  json_serializable: ^4.0.2
  flutter_test:
    sdk: flutter
Run Code Online (Sandbox Code Playgroud)

这些是当前的 flutter …

dart flutter dart-null-safety

36
推荐指数
4
解决办法
1万
查看次数

Flutter:我在运行时遇到了这个问题:flutter pub run builder_runner watch

这是错误:

Bad state: Unexpected diagnostics:
C:\flutter\bin\cache\dart-sdk\lib\internal\internal.dart:172:16 - This requires the 'non-nullable' 
language feature to be enabled.
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Run Code Online (Sandbox Code Playgroud)

这只是在最后一次 flutter 升级之后发生的。我尝试了很多解决方案,但没有任何效果,即使我重新安装了 flutter SDK。

这是pubspec.yaml

environment:
 sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  json_annotation: ^3.0.1
  cupertino_icons: ^0.1.3

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner:
  json_serializable: ^3.3.0
Run Code Online (Sandbox Code Playgroud)

测试代码:

import 'package:json_annotation/json_annotation.dart';

part 'test.g.dart';

//@JsonSerializable(nullable: true)
//@JsonSerializable(nullable: false)
@JsonSerializable()
class Test{
  final String test;
  Test(this.test);
}
Run Code Online (Sandbox Code Playgroud)

dart flutter

8
推荐指数
1
解决办法
1270
查看次数

如何在颤振中获取设备字体大小

当高度有界时,我遇到了列表视图的问题,所以当我更改手机字体大小时,会发生溢出,我不想为容器提供额外的高度。

Container(
       height: fixed height goes here,
       child: ListView(
         scrollDirection: Axis.horizontal,
         children: <Widget>[
           some widgets goes here...
         ],
       ),
     )
Run Code Online (Sandbox Code Playgroud)

flutter

4
推荐指数
1
解决办法
3765
查看次数

标签 统计

flutter ×3

dart ×2

dart-null-safety ×1