* Add platform_services sample * update build.gradle to use latest scripts * use FlutterActivity * Updated ExampleInstrumentedTest.java and deleted FlutterPlugin.groovy * Remove getRandom code from main.dart * remove unused import
2.2 KiB
Example of calling platform services from Flutter
This project demonstrates how to connect a Flutter app to platform specific services.
You can read more about accessing platform and third-party services in Flutter.
iOS
Configure
Create an ios/Flutter/Generated.xcconfig
file with this entry:
FLUTTER_ROOT=[absolute path to the Flutter SDK]
There are a number of other parameters you can control with this file:
FLUTTER_APPLICATION_PATH
: The path to the directory that contains yourpubspec.yaml
file relative to yourxcodeproj
file.FLUTTER_BUILD_MODE
: Whether to build fordebug
,profile
, orrelease
. Defaults torelease
.FLUTTER_TARGET
: The path to yourmain.dart
relative to yourpubspec.yaml
. Defaults tolib/main.dart
.FLUTTER_FRAMEWORK_DIR
: The absolute path to the directory that containsFlutter.framework
. Defaults to theios-release
version ofFlutter.framework
in thebin/cache
directory of the Flutter SDK.
Build
Once you've configured your project, you can open ios/Runner.xcodeproj
in Xcode and build the project as usual.
Android
Configure
Create an android/local.properties
file with these entries:
sdk.dir=[path to the Android SDK]
flutter.sdk=[path to the Flutter SDK]
There are a number of other parameters you can control with this file:
flutter.buildMode
: Whether to build fordebug
,profile
, orrelease
. Defaults torelease
.flutter.jar
: The path toflutter.jar
. Defaults to theandroid-arm-release
version offlutter.jar
in thebin/cache
directory of the Flutter SDK.
See android/app/build.gradle
for project specific settings, including:
source
: The path to the directory that contains yourpubspec.yaml
file relative to yourbuild.gradle
file.target
: The path to yourmain.dart
relative to yourpubspec.yaml
. Defaults tolib/main.dart
.
Build
To build directly with gradle
, use the following commands:
cd android
gradle wrapper
./gradlew build
To build with Android Studio, open the android
folder in Android Studio and
build the project as usual.