fluttter_env - ShenYj/ShenYj.github.io GitHub Wiki

Flutter 环境

安装Flutter SDK

下载、安装Flutter SDK

  1. 终端中将PUB_HOSTED_URL设置为镜像站点

    export PUB_HOSTED_URL="https://pub.flutter-io.cn"
  2. FLUTTER_STORAGE_BASE_URL 设置为镜像站点。

    export FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"
  3. 从镜像站点下载 Flutter SDK 压缩包,下载后解压到指定的目录中

    // 进入到指定的目录内,解压指定下载的版本
    unzip flutter_macos_v3.22.3-stable.zip
  4. 将 Flutter 添加到你的 PATH 环境变量中。

    export PUB_HOSTED_URL="https://pub.flutter-io.cn"
    export FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"
    export PATH="$HOME/dev/flutter/bin:$PATH"
    export PATH="$HOME/dev/flutter/bin:$PATH/bin/cache/dart-sdk/bin:$PATH"

    为了保证环境永久生效,需要将配置加到 *rc 或 *profile 文件中,这里我将环境配置到了 .zshrc

  5. 最后通过 Flutter doctor 命令来检查下环境

    ❯ flutter doctor
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 3.22.3, on macOS 14.5 23F79 darwin-x64, locale zh-Hans-JP)
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    [✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    [✓] Chrome - develop for the web
    [✓] Android Studio (version 2024.1)
    [✓] VS Code (version 1.91.1)
    [✓] Connected device (3 available)
        ! Error: Browsing on the local area network for ShenYj4 iPad Pro. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
        The device must be opted into Developer Mode to connect wirelessly. (code -27)
        ! Error: Browsing on the local area network for ShenYj4 iPhone 14 pro. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
        The device must be opted into Developer Mode to connect wirelessly. (code -27)
    [!] Network resources
        ✗ An HTTP error occurred while checking "https://github.com/": Connection closed before full header was received
    
    ! Doctor found issues in 1 category.

工程模式

统一管理

构建一个标准的 Flutter App 即统一管理模式

包含 Dart层和平台层(iOS/Android)

创建时选择 Application

项目结构

三端分离

创建一个Flutter模块,即三端分离模式

易模块的形式分别嵌入原生项目

创建时选择 Module

Package

纯 Dart 插件工程,不依赖 Flutter

仅包含Dart层的实现,通常用来定义一些公共库

Plugin

Flutter 平台插件,包含 Dart层与 Native 平台层实现

是一种特殊的 Flutter Packages

Skeleton

自动声测好难过 Flutter 模板

提供常用框架

参考资料

⚠️ **GitHub.com Fallback** ⚠️