david2tdw / blog

学习记录
1 stars 1 forks source link

[Flutter] Flutter相关 #63

Open david2tdw opened 5 years ago

david2tdw commented 5 years ago

升级 Flutter channel 和 packages 要同时更新Flutter SDK和你的依赖包,在你的应用程序根目录(包含pubspec.yaml文件的目录)中运行flutter upgrade 命令:

flutter upgrade
david2tdw commented 5 years ago

flutter upgrade报错: 需安装:Windows PowerShell 5.0 or newer (this is pre-installed with Windows 10) 官网:https://docs.microsoft.com/zh-cn/powershell/scripting/install/installing-windows-powershell?view=powershell-6 下载 Win7AndW2K8R2-KB3191566-x64.zip 安装后 在开始里 查找windows powershell 打开后输入 $PSVersionTable 查看版本

PS C:\Users\tdw> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14409.1005
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1005
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

PS C:\Users\tdw>
david2tdw commented 5 years ago

更新channel和Dart sdk

进入flutter sdk的目录。 找到 flutter_console.bat 文件。 双击运行后 输入flutter doctor 去更新Dart sdk。

david2tdw commented 5 years ago

如果手机连接上电脑无法识别, 要检查ADB是否在设别管理器里有显示出来。 我的电脑右键 -> 管理 -> 计算机管理 image 如果没有显示 , 去下载一个ADB驱动 下载地址 下载完在设备上右键选择更新驱动,安装已下载驱动里的文件。 打开手机,选择允许授权。 打开androidstudio 即可看见手机。

222

david2tdw commented 5 years ago

查看所有分支:

flutter channel

升级flutter sdk

flutter upgrade

获取项目所有的依赖包。

flutter packages get

获取项目所有依赖包的最新版本

flutter packages upgrade

验证Flutter识别您连接的Android设备

flutter devices
david2tdw commented 5 years ago

运行flutter 在项目的根目录运行: flutter run image

david2tdw commented 4 years ago

Flutter 调试技巧

david2tdw commented 4 years ago

Bloc (Business Logic Component):

BloC模式

david2tdw commented 4 years ago

如果在导入项目后提示import的路径找不到, 运行

flutter packages get

之后重启vs code

david2tdw commented 4 years ago

json_serializable使用:

运行命令:

flutter packages pub run build_runner build
E:\flutter_workspace\hello_flutter>flutter packages pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 574ms

[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 19.6s

[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 1.8s

[INFO] Checking for unexpected pre-existing outputs....
[INFO] Checking for unexpected pre-existing outputs. completed, took 2ms

[INFO] Running build...
[INFO] Generating SDK summary...
[INFO] 6.5s elapsed, 0/16 actions completed.
[INFO] Generating SDK summary completed, took 6.4s

[INFO] 7.5s elapsed, 9/25 actions completed.
[INFO] 8.6s elapsed, 9/25 actions completed.
[INFO] 9.6s elapsed, 9/25 actions completed.
[INFO] 10.7s elapsed, 9/25 actions completed.
[INFO] 12.6s elapsed, 10/25 actions completed.
[INFO] 14.8s elapsed, 10/26 actions completed.
[INFO] 16.3s elapsed, 12/26 actions completed.
[INFO] 17.4s elapsed, 45/57 actions completed.
[INFO] 19.0s elapsed, 45/61 actions completed.
[INFO] 20.5s elapsed, 61/76 actions completed.
[INFO] 21.5s elapsed, 115/131 actions completed.
[INFO] Running build completed, took 22.5s

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

[INFO] Succeeded after 22.7s with 2 outputs (291 actions)

E:\flutter_workspace\hello_flutter>

json_serializable

david2tdw commented 4 years ago

json_serializable使用:

在项目更目录下执行, 删除之前生成的文件: --delete-conflicting-outputs

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

类名上要添加 @JsonSerializable()