从Android 开发到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.

优点

  • 号称是可以一次开发Android和iOS的原生级别的应用,热重新加载 ,表现灵活的用户界面 ,

  • 使用Dart语言编写一套代码即可同时在Android和iOS平台运行,性能无限接近原生,支持android 4.1以上 和 iOS8以上,一般都没有听过Dart 这个语言是什么鬼,但是啊,不要紧张,dart的语言可以说就是Java的语法,so,对于我们Android开发者来说就很容易接受

  • flutter 里面调用了Java和kotlin的类库 ,当然还有swift ,不用开发者在配置一遍

  • 并且flutter的正式版可以实现跨平台

  • -在现有的开发工具中完全支持开发

我们Android开发者直接可以使用Android studio进行开发 很简单

作为Google 的亲儿子,发展是不可限量的,并且Flutter 在近期完善成都非常高,几乎是涵盖了开发的领域的各个功能,是时候使用Flutter 来开发一款运行在ios 和 Android两个平台的应用了,


windows 电脑开发的时候我们是不能将我们的Flutter程序运行到ios模拟器或真机的,当然你也可以安装黑苹果来完成部署,本文中涉及到的所有安装和使用都基于Mac


安装Flutter

  • 创建一个新的文件夹(作为以后项目的使用文件及Flutetr SDK的安装文件夹)
  • cd到创建的文件夹中 运行
git clone -b beta https://github.com/flutter/flutter.git

2.代码下载之后在终端中打开bash_profile文件 进行配置(这个文件用Mac开发过的应该都会有,如果没有,自己创建bash_profile(找度娘))

export PATH=$PATH:XXX/flutter/bin 或者
export PATH="XXX/flutter/bin:$PATH"

这里写图片描述

  • 然后使用flutter doctor 命令进行安装,几分钟后会显示

Android toolchain - develop for Android devices
• Android SDK at /Users/obiwan/Library/Android/sdk
✗ Android SDK is missing command line tools; download from https://goo.gl/XxQghQ
• Try re-installing or updating your Android SDK,
visit https://flutter.io/setup/#android-setup for detailed instructions.

  • 再这个过程先不要处理任何error
    之后将会显示
iOS toolchain - develop for iOS devices (Xcode 10.0)
    ✗ libimobiledevice and ideviceinstaller are not installed. To install with
      Brew, run:
        brew update
        brew install --HEAD usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    ✗ ios-deploy not installed. To install:
        brew install ios-deploy
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS platform side's plugin code that
        responds to your plugin usage on the Dart side.
        Without resolving iOS dependencies with CocoaPods, plugins will not work
        on iOS.
        For more info, see https://flutter.io/platform-plugins
      To install:
        brew install cocoapods
        pod setup

安照提示将相关的东西全部安装

  • 再次运行flutter doctor 知道不会报类似错误

配置Android Studio

下载插件flutter ,在下载的过程中会自动下载dart

这里写图片描述

点击instsll 重启Android studio

新建Flutter项目

点击new --> new Flutter project --> Flutter Application --> 选择Flutter SDK(刚才下载的) --> finish 创建完成

点击运行 :
这里写图片描述

这就完成了Flutter的环境的搭建和创建第一个Flutter程序


⚠️: 第一次创建项目会非常慢,推荐使用命令创建

  • 打开终端
  • cd 到 一 中创建的文件夹目录下 运行
flutter create 项目名

创建速度会提升很多

  • 打开AS File->Open 打开项目

目前为止已经创建好了第一个项目

此时会发现AS中有运行选择设备
在这里插入图片描述

  • open ios simulator 打开iOS模拟器
  • 打开其他模拟器
  • 并且显示已经连接的iOS设备及Android设备

此时我们能将项目运行到模拟器或者Android的任何设备中 但是我们不能运行到ios真机中,我们需要点击ios 模块,右键 显示
在这里插入图片描述

flutter 会显示 open ios moudle in xcode

打开XCode 等待编译
command+; 打开设置 选择添加APPId账号 编译完成 就可以运行到iOS设备中了

支持原创 转载请注明 图你怀中安稳 https://blog.csdn.net/qq_32648731/article/details/80007499

从Android开发到Flutter 之开屏页和广告页《二》

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值