Flutter_web项目搭建AndroidStudio方式

15 篇文章 0 订阅
2 篇文章 0 订阅

1、下载flutter_web SDK

 

git clone https://github.com/flutter/flutter_web.git

2、安装flutter_web的编译工具webdev

 

flutter pub global activate webdev

成功会出现以下界面:

Precompiling executables…
Precompiled webdev:webdev.
Installed executable webdev.
Activated webdev 2.0.6    // 版本号以实际为准

3、如果实在以前的项目中添加web功能,继续往下看,如果创建新项目,请跳转到第6步:

cd <flutter_web目录>/examples/hello_world

4、执行

flutter pub upgrade 或 pub upgrade


如果出现以下界面说明配置正确

RandyWeideMacBook-Pro:hello_world wei$ flutter pub get
! flutter_web 0.0.0 from path ../../packages/flutter_web                
! flutter_web_ui 0.0.0 from path ../../packages/flutter_web_ui          
Running "flutter packages get" in hello_world...  

5、执行

flutter pub global run webdev serve


出现以下界面就是成功了

RandyWeideMacBook-Pro:hello_world wei$ flutter pub global run webdev serve
[INFO] Building new asset graph completed, took 1.5s
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
[INFO] Serving `web` on http://localhost:8080
[INFO] Running build completed, took 18.3s
[INFO] Caching finalized dependency graph completed, took 201ms
[INFO] Succeeded after 18.5s with 556 outputs (3217 actions)
[INFO] ------------------------------------------------------------------

6、安装stagehand,执行

flutter pub global activate stagehand

7、上一步成功之后执行:

flutter pub global run stagehand

出现以下界面说明成功

flutter pub global run stagehand

Stagehand will generate the given application type into the current directory.
usage: stagehand <generator-name>
    --[no-]analytics    Opt out of anonymous usage and crash reporting.
-h, --help              Help!
    --version           Display the version for stagehand.
    --author            The author name to use for file headers.
                        (defaults to "<your name>")

Available generators:
  console-full        - A command-line application sample.
  flutter-web-preview - A simple Flutter Web app.
  package-simple      - A starting point for Dart libraries or applications.
  server-shelf        - A web server built using the shelf package.
  web-angular         - A web app with material design components.
  web-simple          - A web app that uses only core Dart libraries.
  web-stagexl         - A starting point for 2D animation and games.

从第12行到18行是几种不同的模式,我以第17行为例,创建一个空白的web项目

8、打开新建的文件夹(是个空白文件夹就行)

cd 新建的文件夹

9、执行

flutter pub global run stagehand web-simple  //选择的的是web-simple模式

10、一个web项目就创建完成了,可以使用studio打开项目,使用flutter pub get配置好完之后,可以进行正常的代码了。

11、测试

命令行进入到项目中,直接执行

flutter pub global run webdev serve

12,成功!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

smile_raccoon

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值