颤振:使用颤振 2 而不迁移到空安全

时间:2021-03-15 07:42:48

标签: flutter flutter-dependencies

我正在尝试使用 flutter sdk 版本 2。所以在设置之后

environment:
  sdk: '>=2.12.0 <3.0.0'

在包的 pubspec.yaml 文件中,我准备使用稳定版本。在运行应用程序之前,我需要运行:

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

运行后我得到了很多错误,例如:

The parameter 'restClient' can't have a value of 'null' because of its type, but the implicit default value is 'null'.  Try adding either an explicit non-'null' default value or the 'required' modifier.

我的一些以前在我的项目中使用过的库,还没有迁移到空安全,所以现在我还没有准备好将我的项目迁移到空安全。

我现在想要使用flutter 2而不迁移到空安全的方法吗?

2 个答案:

答案 0 :(得分:1)

是的,我目前正在处理一个迁移到 Flutter 2 且 null 安全性不佳的项目,只需按如下方式更新您的 Sub Entry_Click() If Sheet1.Range("B4").Value = "" Then MsgBox "Please choose a store": Exit Sub If Sheet1.Range("B4").Value = "Store 1" Then Application.ScreenUpdating = False Dim iRow As Long iRow = Sheets(2).Range("B1048576").End(xlUp).Row + 1 With ThisWorkbook.Sheets(2) .Range("A" & iRow).Value = Sheet1.Range("C4").Value .Range("B" & iRow).Value = Sheet1.Range("D4").Value .Range("C" & iRow).Value = Sheet1.Range("E4").Value End With Application.ScreenUpdating = True ElseIf Sheet1.Range("B4").Value = "Store 2" Then Application.ScreenUpdating = False iRow = Sheets(3).Range("B1048576").End(xlUp).Row + 1 With ThisWorkbook.Sheets(3) .Range("A" & iRow).Value = Sheet1.Range("C4").Value .Range("B" & iRow).Value = Sheet1.Range("D4").Value .Range("C" & iRow).Value = Sheet1.Range("E4").Value End With Application.ScreenUpdating = True ElseIf Sheet1.Range("B4").Value = "Store 3" Then Application.ScreenUpdating = False iRow = Sheets(4).Range("B1048576").End(xlUp).Row + 1 With ThisWorkbook.Sheets(4) .Range("A" & iRow).Value = Sheet1.Range("C4").Value .Range("B" & iRow).Value = Sheet1.Range("D4").Value .Range("C" & iRow).Value = Sheet1.Range("E4").Value End With Application.ScreenUpdating = True ElseIf Sheet1.Range("B4").Value = "Store 4" Then Application.ScreenUpdating = False iRow = Sheets(5).Range("B1048576").End(xlUp).Row + 1 With ThisWorkbook.Sheets(5) .Range("A" & iRow).Value = Sheet1.Range("C4").Value .Range("B" & iRow).Value = Sheet1.Range("D4").Value .Range("C" & iRow).Value = Sheet1.Range("E4").Value End With Application.ScreenUpdating = True ElseIf Sheet1.Range("B4").Value = "Store 5" Then Application.ScreenUpdating = False iRow = Sheets(6).Range("B1048576").End(xlUp).Row + 1 With ThisWorkbook.Sheets(6) .Range("A" & iRow).Value = Sheet1.Range("C4").Value .Range("B" & iRow).Value = Sheet1.Range("D4").Value .Range("C" & iRow).Value = Sheet1.Range("E4").Value End With Application.ScreenUpdating = True End If End Sub

pubspec.yml

答案 1 :(得分:1)

<块引用>

我现在想要使用flutter 2而不迁移到空安全的方法吗?

是的,你可以!实际上,您也可以保留不支持空安全的旧包!但是有一个条件,您可以在使用 flutter 2 的同时保留旧包,而不会迁移到空安全中,并且只要您的基本包(如用于包本地化的 intl 和 flutter_localizations)兼容,就可以完成包迁移地狱。但请记住,您需要保持您的包与 flutter 2 兼容

或者你可以直接运行这个命令

flutter run --no-sound-null-safety
相关问题