首页 > 解决方案 > 为localStorage运行“flutter run -d chrome”时如何设置Chrome的端口?

问题描述

运行“flutter run -d chrome”时,有什么方法可以设置 Chrom 的端口吗?没有它,由于新的端口/来源,我的 localStorage 在每次运行时都会丢失。

或者是否有另一种方法可以跨不同端口保持 localStorage

标签: flutter

解决方案


我也面临同样的问题。因此,我查找了与 flutter run 命令相关的资源,并找到了该命令的 Web 选项。

https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/runner/flutter_command.dart#L137

--web-port您可以使用该选项设置任何端口。

flutter run -d chrome --web-port 8080


推荐阅读