flutter入门

什么是flutter

Flutter is Google’s mobile UI framework for crafting high-quality native interfaces on iOS and Android in record time. Flutter works with existing code, is used by developers and organizations around the world,and is free and open source.

环境安装

下载SDK

https://flutter.io/docs/development/tools/sdk/archive?tab=macos#macos 或者 git clone -b beta https://github.com/flutter/flutter.git

镜像

添加环境变量 .bash_profile

1
2
3
4
5
6
export ANDROID_HOME=~/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=/Users/chenyu/treasure/flutter/flutter/bin:$PATH

运行flutter doctor查看是否需要安装其它依赖项来完成安装:

该命令检查您的环境并在终端窗口中显示报告。Dart SDK已经在捆绑在Flutter里了,没有必要单独安装Dart。 仔细检查命令行输出以获取可能需要安装的其他软件或进一步需要执行的任务(以粗体显示)

创建项目

  1. 在AndroidStudio安装Dart插件。启动studio,搜索flutter,自动安装Dart插件,完成后重启studio。

  2. Android Studio - File - New -New Flutter Project

文件入口

项目路径下的lib文件夹下的main.dart文件

1
2
3
4
5
6
7
8
import 'package:flutter/material.dart'; //导包
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialAp
}
本文结束感谢您的阅读

本文标题:flutter入门

文章作者:陈宇(cosyer)

发布时间:2018年12月25日 - 01:12

最后更新:2019年01月02日 - 02:01

原始链接:http://mydearest.cn/flutter%E5%85%A5%E9%97%A8.html

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

坚持原创技术分享,您的支持将鼓励我继续创作!