:::

3. flutter初體驗

  1. https://flutter.io/
  2. https://flutterchina.club/
  3. https://www.dartlang.org/
  4. http://dart.goodev.org/
  5. 範例App下載

安裝Dart及Flutter

  1. 安裝Chocolatey:https://chocolatey.org/ (管理員身份+power shell)
    Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
  2. 安裝Dart SDK(管理員身份+power shell)
    choco install dart-sdk
  3. 看起來像這樣:
  4. 接著請於 VS Code 編輯器安裝各種關於Dart以及flutter的外掛。
  5. https://flutter.io/setup-windows/ 下載 flutter_windows_xxx.zip,並解壓縮到 C:\tools 底下即可
  6. 編輯環境變數,加入 C:\tools\flutter\bin 即可
  7. 執行C:\tools\flutter\flutter_console.bat即可在flutter命令列運行flutter命令
  8. 日後要更新flutter只要在終端機輸入以下指令即可:
    flutter upgrade
  9. 要驗證設定只要在終端機輸入(在VSCode中按Ctrl+`即可)以下指令即可:
    flutter doctor
  10. 安裝 Android Studio, 3.0或更高版本
  11. 點擊 Configation→plugin→Browse repositories…,安裝和flutter相關的外掛
  12. 建立新的flutter專案,然後從 Tools→AVD Manager 去新增模擬器
  13. 如果執行F5跑模擬器時,遇到以下問題
    Launching lib\main.dart on Android SDK built for x86 in debug mode...
    Initializing gradle...
    Resolving dependencies...
    Finished with error: Please review your Gradle project setup in the android/ folder.
    * Error running Gradle:
    Exit code 1 from: D:\tad\app1\android\gradlew.bat app:properties:
    Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Build file 'D:\tad\app1\android\app\build.gradle' line: 25
    
    * What went wrong:
    A problem occurred evaluating project ':app'.
    > Could not resolve all files for configuration 'classpath'.
       > Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
         Searched in the following locations:
             https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 2s
    
    

    請修改C:\tools\flutter\packages\flutter_tools\gradle\flutter.gradle,把jcenter()位置調整一下及即可:

    buildscript {
        repositories {
    
            jcenter()
            maven {
                url 'https://dl.google.com/dl/android/maven2'
            }
    
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.2'
        }
    }

    改為

    buildscript {
        repositories {
            maven {
                url 'https://dl.google.com/dl/android/maven2'
            }
            jcenter()
    
        }
        dependencies {`enter code here`
            classpath 'com.android.tools.build:gradle:3.1.2'
        }
    }

     

IOS安裝

  1. https://astr0baby.wordpress.com/2018/04/22/installing-high-sierra-10-13-4-in-virtualbox-5-x/?fbclid=IwAR2z8Ks4VFS-IdufpuoVtjgM2hVzYUGqofpmzJjlNKKHcQJp2t1SEoPCjlM
  2. 下載 VirtualBox 並安裝
  3. 下載 MacOS 10.13.4 iso 並解壓縮
  4. 啟動VirtualBox,並建立新電腦
    • 名稱:  High Sierra
    • 類型:  Mac OS X
    • 版本:  macOS High Sierra (64-bit)
  5. 2個CPU
  6. 記憶體至少 4 GB ( 或 70% 記憶體 )
  7. 顯示記憶體 128MB
  8. 在光碟掛載剛剛下載的MacOSHighSierra10.13.4.iso檔
  9. 到終端機輸入:
    cd "C:\Program Files\Oracle\VirtualBox\"
    VBoxManage modifyvm "High Sierra" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
    VBoxManage setextradata "High Sierra" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
    VBoxManage setextradata "High Sierra" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
    VBoxManage setextradata "High Sierra" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
    VBoxManage setextradata "High Sierra" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
    VBoxManage setextradata "High Sierra" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

     

  10. 啟動剛剛新建的電腦 

:::

書籍目錄

展開 | 闔起

https%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1347%26tbsn%3D36

計數器

今天: 617617617
昨天: 2027202720272027
總計: 7971658797165879716587971658797165879716587971658