Git Product home page Git Product logo

qmsggg / qmsggg_flutter Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 1.0 152 KB

Google跨平台UI框架 Flutter beta 重磅发布,这里有你需要了解的一切 2018年2月27日,在西班牙巴塞罗那世界移动大会上,Google发布 Flutter 的第一个 beta 版本。Flutter 是 Google 用以帮助开发者在 iOS 和 Android 两个平台开发高质量的原生应用的全新移动 UI 框架。现在就可以去 flutter.io 快速上手开发精美的原生应用。为了方便开发者了解和掌握 Flutter,一颗香菜准备了以下关于 Flutter 的内容。

we-b website ios android flutter

qmsggg_flutter's People

Contributors

hankcoder avatar qmsggg avatar

Forkers

jinyanchou

qmsggg_flutter's Issues

Build beautiful native apps in record time

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.

  • Fast developme
    Flutter's hot reload helps you quickly and easily experiment, build UIs, add features, and fix bugs faster. Experience sub-second reload times, without losing state, on emulators, simulators, and hardware for iOS and Android.
    image
  • Expressive, beautiful UIs
    image
    image
    image
    image
    Browse the widget catalog.
  • Modern, reactive framework
    Easily compose your UI with Flutter's modern reactive framework and rich set of platform, layout, and foundation widgets. Solve your tough UI challenges with powerful and flexible APIs for 2D, animation, gestures, effects, and more.
class CounterState extends State<Counter> {
  int counter = 0;

  void increment() {
    // Tells the Flutter framework that state has changed,
    // so the framework can run build() and update the display.
    setState(() {
      counter++;
    });
  }

  Widget build(BuildContext context) {
    // This method is rerun every time setState is called.
    // The Flutter framework has been optimized to make rerunning
    // build methods fast, so that you can just rebuild anything that
    // needs updating rather than having to individually change
    // instances of widgets.
    return new Row(
      children: <Widget>[
        new RaisedButton(
          onPressed: increment,
          child: new Text('Increment'),
        ),
        new Text('Count: $counter'),
      ],
    );
  }
}

Browse the widget catalog and learn more about the reactive framework.

  • Access native features and SDKs
    Make your app come to life with platform APIs, 3rd party SDKs, and native code. Flutter lets you reuse your existing Java, Swift, and ObjC code, and access native features and SDKs on iOS and Android.

Accessing platform features is easy. Here is a snippet from our interop example:

Future<Null> getBatteryLevel() async {
  var batteryLevel = 'unknown';
  try {
    int result = await methodChannel.invokeMethod('getBatteryLevel');
    batteryLevel = 'Battery level: $result%';
  } on PlatformException {
    batteryLevel = 'Failed to get battery level.';
  }
  setState(() {
    _batteryLevel = batteryLevel;
  });
}

Learn how to use packages, or write platform channels, to access native code, APIs, and SDKs.

  • Unified app development
    Flutter has the tools and libraries to help you easily bring your ideas to life on iOS and Android. If you don't have any mobile development experience, Flutter is an easy and fast way to build beautiful mobile apps. If you are an experienced iOS or Android developer, you can use Flutter for your views and leverage much of your existing Java/ObjC/Swift investment.
    image
    Learn more about what makes Flutter special in the technical overview.
  • Try Flutter today. Getting started is easy.
    GET STARTED

入门: 在Linux上搭建Flutter开发环境

系统要求

要安装并运行Flutter,您的开发环境必须满足以下最低要求:

  • 操作系统: Linux (64-bit)
  • 磁盘空间: 600 MB (不包括Android Studio的磁盘空间).
  • 工具: Flutter 依赖下面这些命令行工具.
    • bash, mkdir, rm, git, curl, unzip, which

获取Flutter SDK

要获得Flutter,请先使用git克隆Flutter,然后将该flutter工具添加到您的用户路径。运行 flutter doctor 显示您可能需要安装的剩余依赖项。

Clone Flutter repo

如果这是您第一次在此机器上安装Flutter,请克隆beta分支,然后将该flutter工具添加到您的系统路径中:

git clone -b beta https://github.com/flutter/flutter.git
export PUB_HOSTED_URL=https://pub.flutter-io.cn //国内用户需要设置
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn //国内用户需要设置
export PATH=`pwd`/flutter/bin:$PATH

注意: 由于一些flutter命令需要联网获取数据,如果您是在国内访问,由于众所周知的原因,直接访问很可能不会成功。 上面的PUB_HOSTED_URL和FLUTTER_STORAGE_BASE_URL是google为国内开发者搭建的临时镜像。详情请参考 Using Flutter in China

上述命令为当前终端窗口临时设置PATH变量。要将Flutter永久添加到路径中,请参阅更新路径

要更新现有版本的Flutter,请参阅升级Flutter

运行 flutter doctor

运行以下命令查看是否需要安装其它依赖项来完成安装:

flutter doctor

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

例如:

[-] 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.

一般的错误会是xcode或Android Studio版本太低、或者没有ANDROID_HOME环境变量等,请按照提示解决。下面贴一个笔者本机(mac)的环境变量配置,您可以对比修正:

  export PATH=/Users/用户名/Documents/flutter/flutter/bin:$PATH
  export ANDROID_HOME="/Users/用户名/Documents/android_sdk" //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

第一次运行一个flutter命令(如flutter doctor)时,它会下载它自己的依赖项并自行编译。以后再运行就会快得多。

以下各部分介绍如何执行这些任务并完成设置过程。你会看到在flutter doctor输出中, 如果你选择使用IDE,我们提供了,IntelliJ IDEA,Android Studio和VS Code的插件, 请参阅编辑器设置 以了解安装Flutter和Dart插件的步骤。

一旦你安装了任何缺失的依赖,再次运行flutter doctor命令来验证你是否已经正确地设置了。
该flutter工具使用Google Analytics匿名报告功能使用情况统计信息和基本崩溃报告。 这些数据用于帮助改进Flutter工具。Analytics不是一运行或在运行涉及flutter config的任何命令时就发送, 因此您可以在发送任何数据之前退出分析。要禁用报告,请执行flutter config --no-analytics并显示当前设置,然后执行flutter config。 请参阅Google的隐私政策。

更新环境变量

您在命令行只能更新当前会话的PATH变量,如Clone Flutter repo所示。 但是,您可能需要的是永久更新此变量,以便您可以运行flutter命令在任何终端会话中。

对于所有终端会话永久修改此变量的步骤是和特定计算机系统相关的。通常,您会在打开新窗口时将设置环境变量的命令添加到执行的文件中。例如

  1. 确定您Flutter SDK的目录,您将在步骤3中用到。
  2. 打开(或创建) $HOME/.bash_profile. 文件路径和文件名可能在您的机器上不同.
  3. 添加以下行并更改[PATH_TO_FLUTTER_GIT_DIRECTORY]为克隆Flutter的git repo的路径:
export PUB_HOSTED_URL=https://pub.flutter-io.cn //国内用户需要设置
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn //国内用户需要设置
export PATH= PATH_TO_FLUTTER_GIT_DIRECTORY/flutter/bin:$PATH

注意:PATH_TO_FLUTTER_GIT_DIRECTORY 为你flutter的路径,比如“~/document/code”

 export PATH= ~/document/code/flutter/bin:$PATH
  1. 运行 source $HOME/.bash_profile 刷新当前终端窗口.

注意: 如果你使用的是zsh,终端启动时 ~/.bash_profile 将不会被加载,解决办法就是修改 ~/.zshrc ,在其中添加:source ~/.bash_profile

  1. 通过运行flutter/bin命令验证目录是否在已经在PATH中:
echo $PATH

更多详细信息,请参阅this StackExchange question.

编辑器设置

使用 flutter 命令行工具,您可以使用任何编辑器来开发Flutter应用程序。输入**flutter help**在提示符下查看可用的工具。

我们建议使用我们的插件来获得丰富的IDE体验,支持编辑,运行和调试Flutter应用程序。请参阅编辑器设置了解详细步骤

Android设置

安装Android Studio
要为Android开发Flutter应用,您可以使用Mac,Windows或Linux(64位)机器.

Flutter需要安装和配置Android Studio:

  1. 下载并安装 Android Studio.
  2. 启动Android Studio,然后执行“Android Studio安装向导”。这将安装最新的Android SDK,Android SDK平台工具和Android SDK构建工具,这是Flutter为Android开发时所必需的

设置您的Android设备

要准备在Android设备上运行并测试您的Flutter应用,您需要安装Android 4.1(API level 16)或更高版本的Android设备.

  1. 在您的设备上启用 开发人员选项USB调试 。详细说明可在Android文档中找到。
  2. 使用USB将手机插入电脑。如果您的设备出现提示,请授权您的计算机访问您的设备。
  3. 在终端中,运行 flutter devices 命令以验证Flutter识别您连接的Android设备。
  4. 运行启动您的应用程序 flutter run
    默认情况下,Flutter使用的Android SDK版本是基于你的 adb 工具版本。 如果您想让Flutter使用不同版本的Android SDK,则必须将该 ANDROID_HOME 环境变量设置为SDK安装目录。

设置Android模拟器

要准备在Android模拟器上运行并测试您的Flutter应用,请按照以下步骤操作:

  1. 在您的机器上启用 VM acceleration .
  2. 启动 Android Studio>Tools>Android>AVD Manager 并选择 Create Virtual Device.
  3. 选择一个设备并选择 Next
  4. 为要模拟的Android版本选择一个或多个系统映像,然后选择 Next. 建议使用 x86 或 x86_64 image .
  5. 在 Emulated Performance下, 选择 Hardware - GLES 2.0 以启用 硬件加速.
  6. 验证AVD配置是否正确,然后选择 Finish

有关上述步骤的详细信息,请参阅 Managing AVDs.

  1. 在 Android Virtual Device Manager中, 点击工具栏的 Run。模拟器启动并显示所选操作系统版本或设备的启动画面.
  2. 运行 flutter run 启动您的设备. 连接的设备名是 Android SDK built for <platform>,其中 platform 是芯片系列, 如 x86.

Get Started: Install on macOS

Get the Flutter SDK

  • Clone the repo
git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.