Flutter 모듈을 Android 프로젝트에 통합
6252 단어 flutter


안드로이드 스튜디오 범블비 | 2021.1.1 패치 2
플러터 2.10.3 | 다트 2.16.1 | 개발자 도구 2.9.2
플러터 모듈
1) Flutter 확장 모듈
flutter create -t module flutter_counter

2) เข้า ไป เข้า เข้า flutter_counter แล้ว บิ้ว แบบ Aar (안드로이드 아카이브) เปิด หน้าจอ นี้ นี้ ไว้ เพื่อ จะ ก๊อปปี้ โค้ด โค้ด
cd flutter_counter
flutter build aar

안드로이드 프로젝트
1) สร้าง Android 프로젝트 แบบ 기본 활동

2) ก๊อปปี้โค้ดที่ได้มาจากการ 빌드 ของ 플러터
String storageUrl = System.env.FLUTTER_STORAGE_BASE_URL ?:
"https://storage.googleapis.com"

3) นำโค้ดไปวางไว้ที่ settings.gradle

4) ก๊อปปี้โค้ดที่ได้มาจากการ 빌드 ของ 플러터
maven {
url '/Users/bond/codebangkok/flutter_counter/build/host/outputs/repo'
}
maven {
url "$storageUrl/download.flutter.io"
}

5) นำโค้ดไปวางไว้ที่ settings.gradle ใน 저장소 กดเซฟ แล้วกดปุ่ม 지금 동기화

6) ก๊อปปี้โค้ดที่ได้มาจากการ 빌드 ของ 플러터
debugImplementation 'com.example.flutter_counter:flutter_debug:1.0'
profileImplementation 'com.example.flutter_counter:flutter_profile:1.0'
releaseImplementation 'com.example.flutter_counter:flutter_release:1.0'

7) build.gradle(모듈) ใน 종속성

8) ก๊อปปี้โค้ดที่ได้มาจากการ 빌드 ของ 설레다
profile {
initWith debug
}

9) นำโค้ดไปวางไว้ที่ build.gradle(모듈) ใน buildTypes กดเซฟ แล้วกดปุ่ม 지금 동기화

10) เพิ่ม 활동 ที่ AndroidManifest.xml
<activity
android:name="io.flutter.embedding.android.FlutterActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"/>

개방형 Flutter 모듈 테스트
ทดลอง เปิด 플러터 모듈 ด้วย การก ด ปุ่ม
1) เปิดไฟล์ FirstFragment ไปทำกัน ที่อีเว้น onClick โดยไป 주석 코드 เดิมอก แล้ว ใสโค้ด ดน ค้ด ดนดน
startActivity(FlutterActivity
.withNewEngine()
.backgroundMode(FlutterActivityLaunchConfigs.BackgroundMode.transparent)
.build(getContext()));

2) Android เพื่อทดสอบการทำงาน กดปุ่ม 다음 เพื่อเปิด Flutter Module


ติดตามผลงานได้ที่
페이지: https://fb.com/CodeBangkok
그룹: https://fb.com/groups/msdevth
블로그:
유튜브:
Reference
이 문제에 관하여(Flutter 모듈을 Android 프로젝트에 통합), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/codebangkok/flutter-module-integrate-into-android-project-2c34텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)