Flutter Web環境搭建


接上篇Flutter Windows下AndroidStudio環境搭建

1、https://github.com/flutter/flutter_web 下載放到本地路徑下

2、系統Path增加(根據你自己的實際用戶目錄修改)

 

3、flutter packages pub global activate webdev 

4、 webdev serve

 5、安裝dart(不需要這一步)

https://gekorm.com/dart-windows/

下載,安裝

 6、從新運行

如果提示

No pubspec.yaml file found.

請進example具體項目目錄hello_world

7、執行webdev serve

Can't load Kernel binary: Invalid kernel binary format version.
No active package webdev.

網上查資料說是需要sdk自帶的dart,不需要單獨安裝下載安裝dart

8、從新配置sdk路徑

系統變量Path配置:C:\flutter\bin\cache\dart-sdk\bin

9、這下成功了

 打開提示的url鏈接

 10、打開vscode,安裝下面插件

 

 11、在lib中從新增加一個hello.dart

import 'package:flutter_web/material.dart';

//Flutter程序入口
void main() => runApp(getApp());

Widget getApp() {
  return new Container(
      child: new Text(
        "Hello World",
        style: new TextStyle(
          fontSize: 24.0,
          fontWeight: FontWeight.w900,
          fontFamily: "Georgia",
        ),
        textDirection: TextDirection.ltr,
      ),
      width: 320.0,
      height: 240.0,
      color: Colors.grey[300]);
}

12、main.dart代碼修改如下

import 'package:flutter_web/material.dart';
import 'hello.dart';
void main() {
  var v=getApp();
  runApp(v);
}

13、刷新頁面,運行效果

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM