-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Adding Apple frameworks > flutter plugins doc #7747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
87c3865
Adding apple framewokrs > flutter plugins doc
leighajarett a2119c0
Merge branch 'main' into appleframeworks
leighajarett bfd555d
Merge branch 'main' into appleframeworks
sfshaza2 38fc2d1
Apply suggestions from code review
leighajarett 1df3948
Update src/development/platform-integration/ios/apple-frameworks.md
leighajarett 32554a3
Making modifications based on code review
leighajarett 559efc5
Adding link
leighajarett 4bf08ef
Modifying based on feedback
leighajarett 1c9d94d
Small fixes and adding links
leighajarett 7f138dd
Adding link
leighajarett 3207d90
Refactored for table display
6b075cb
Merge branch 'main' into appleframeworks
atsansone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
200 changes: 200 additions & 0 deletions
200
src/development/platform-integration/ios/apple-frameworks.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,200 @@ | ||
| --- | ||
| title: Leveraging Apple's System Libraries | ||
| description: Learn how to apply knowledge of Apple's APIs and frameworks when building Flutter apps. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| --- | ||
|
|
||
| This document is for iOS developers looking to apply | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| their existing knowledge of Apple's APIs within Flutter. | ||
| This includes accessing the device hardware and interacting | ||
| with specific frameworks like `HealthKit` or `MapKit`. | ||
|
|
||
| <!-- Add once SwiftUI PR is merged --> | ||
| <!-- For an overview of how the SwiftUI framework compares to Flutter, | ||
| see [Learning Flutter as a SwiftUI developer][]. --> | ||
|
|
||
| ### Flutter plugin overview | ||
| When developing an app with Flutter, you can interact | ||
| with system libraries using plugins. | ||
| Plugins are Dart libraries that contain platform-specific code. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| In the case of an iOS app, | ||
| the platform code can be written in Objective-C or Swift. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| In your Dart code, you use the plugin's Dart API and | ||
| behind the scenes the native plugin code will directly call | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| the system library being used. This means that you can write | ||
| the code to call the Dart API once, | ||
| and it will work for all the platforms | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| that the plugin has been written for. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| To learn more about plugins see [Using packages][]. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| This document links out to some commonly used plugins, | ||
| and their examples, but there are thousands more available on [pub.dev][]. | ||
| And, if you can't find what you're looking for, you can create your own. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Adding a plugin to your project | ||
| When using Apple frameworks within your native project, | ||
| you usually just need to import it into your Swift or Objective-C file. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| In Flutter, you must first run `flutter pub add package_name` | ||
| in the terminal, from the root of your project. This adds | ||
| the dependency to your [`pubspec.yaml`][] file. You can then import | ||
| the package in your Dart file. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Occasionally, you may also need to change app settings or | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| initialization logic- which will be explained in the package's | ||
|
||
| "Readme" page on [pub.dev][]. | ||
|
|
||
| ### Accessing the photo library | ||
| In Swift and Objective-C, you use `PhotoKit` and the `PhotosUI` framework | ||
| to access user photos. | ||
|
|
||
| In Flutter, you can use the [`image_picker`][] plugin, | ||
| which supplies an `ImpagePicker` class that is used to | ||
| display the user's photo library. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Accessing the camera | ||
| In SwiftUI and UIKit, to allow your app's users to take a photo, | ||
| you use the `UIImagePickerController` class, | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| with the `.camera` `sourceType`. | ||
|
|
||
| In Flutter, to access the camera, | ||
| you'll use the same [`image_picker`][] plugin that was | ||
| referenced above. The code will look similar, | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| only now the `source` for `pickImage` is the camera. | ||
|
|
||
| ### In-app purchases | ||
| In Swift and Objective-c, you use `StoreKit` to | ||
| offer in-app purchases. | ||
|
|
||
| In Flutter, you can support in-app purchases through the | ||
| Google Play store on Android and the | ||
| Apple App Store on iOS by using the | ||
| [`in_app_purchase`][] plugin. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Payment processing | ||
| In Swift and Objective-C, you use `PassKit` to process | ||
| Apple Pay payments in your app. | ||
|
|
||
| In Flutter, you can use the [`pay`][] plugin to | ||
| add Google Pay payments on Android | ||
| and Apple pay payments on iOS. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Push notifications | ||
| In Swift and Objective-C, you use the `UserNotifications` | ||
| framework for pushing user-facing notifications. | ||
|
|
||
| In Flutter, you can use the [`firebase_messaging`][] plugin, | ||
| which uses Firebase Cloud Messaging. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Accessing GPS coordinates | ||
| In Swift and Objective-C, you use the `CLLocationManager` class, | ||
| of the `CoreLocation` framework, | ||
| to access the user's location. | ||
|
|
||
| In Flutter, to access the user's location, | ||
| you can use the [`geolocator`][] plugin. | ||
|
|
||
| ### Accessing sensor data | ||
| In Swift and Objective-C, you use the `CMMotionManager` class, | ||
| of the `CoreMotion` framework, to access sensor data | ||
| like the accelerometer or the gyroscope. | ||
|
|
||
| In Flutter, to read sensor data, | ||
| you can use the [`sensors_plus`][] plugin. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Embedding maps | ||
| In Swift and Objective-c, you use `MapKit` to embed | ||
| Apple Maps within your app. | ||
|
|
||
| In Flutter, you can embed Google Maps using the | ||
| [`google_maps_flutter`][] plugin. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Network requests | ||
| In Swift and Objective-C, to make an HTTP request you use the | ||
| `URLSession` class. | ||
|
|
||
| In Flutter, you can use the [`http`][] package. | ||
|
|
||
| ### Persisting data | ||
| In SwiftUI, to persist small pieces of data in your application, | ||
| you would likely use the `@AppStorage` property wrapper. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| In Flutter, to utilize the operating system's key-value storage, | ||
| you can use the [`shared_preferences`][] plugin. | ||
|
|
||
| ### Accessing health data | ||
| In Swift and Objective-C, you use the `HealthKit` framework | ||
| to access health and fitness data. | ||
|
|
||
| In Flutter, you can use the [`health`][] plugin | ||
| to access `HealthKit` data. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Leveraging machine learning | ||
| In Swift and Objective-C, you might use the `CoreML` framework | ||
| for integrating machine learning models into your app, | ||
| or `VisionKit` for text recognition. | ||
|
|
||
| In Flutter, you can leverage Google's ML Kit with the [`google_ml_kit`][] plugin. | ||
| This supports various features like text recognition, | ||
| face detection, image labeling, landmark recognition and barcode scanning. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Alternatively, you can create a custom model with Firebase. For more information, | ||
| see [Use a custom TensorFlow Lite model with Flutter][]. | ||
|
|
||
| ### Leveraging speech recognition | ||
| In Swift and Objective-C, you might use the `Speech` framework for performing | ||
| speech recognition. | ||
|
|
||
| In Flutter, you can use the [`speech_to_text`][] plugin, which exposes | ||
| device specific speech recognition capabilities. | ||
|
|
||
| ### Leveraging augmented reality | ||
| In Swift and Objective-C, you might use the `ARKit` framework | ||
| for creating augmented reality apps. | ||
|
|
||
| In Flutter, you can use the [`ar_flutter_plugin`][]. | ||
|
|
||
| ### Accessing weather data | ||
| In Swift and Objective-C, you might use the `WeatherKit` framework | ||
| for accessing weather conditions and forecasts. | ||
|
|
||
| In Flutter, you can use the [`weather`][] package, | ||
| which uses the [OpenWeatherMap API]. | ||
leighajarett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Alternatively, there are other packages | ||
| that pull from different weather APIs. | ||
|
|
||
| ### Accessing and managing contacts | ||
| In Swift and Objective-C, you might use the `Contacts` framework | ||
| for accessing the user's contacts. | ||
|
|
||
| In Flutter, you can use the [`contacts_service`][] plugin, | ||
| for accessing and managing contacts. | ||
|
|
||
| ### Adding quick actions | ||
| In Swift and Objective-C, you use the | ||
| `UIApplicationShortcutItem` class | ||
| for defining quick actions. Quick actions | ||
| expose commonly used functionality on the home screen. | ||
|
|
||
| In Flutter, you can use the [`quick_actions`][] plugin. | ||
|
|
||
| <!-- [Learning Flutter as a SwiftUI developer]: --> | ||
| [Using packages]: {{ site.url }}/development/packages-and-plugins/using-packages | ||
| [pub.dev]: {{site.pub-pkg}} | ||
| [`shared_preferences`]: {{site.pub-pkg}}/shared_preferences | ||
| [`http`]: {{site.pub-pkg}}/http | ||
| [`sensors_plus`]: {{site.pub-pkg}}/sensors_plus | ||
| [`geolocator`]: {{site.pub-pkg}}/geolocator | ||
| [`image_picker`]: {{site.pub-pkg}}/image_picker | ||
| [`pubspec.yaml`]: {{ site.url }}/development/tools/pubspec | ||
| [`quick_actions`]: {{site.pub-pkg}}/quick_actions | ||
| [`in_app_purchase`]: {{site.pub-pkg}}/in_app_purchase | ||
| [`pay`]: {{site.pub-pkg}}/pay | ||
| [`firebase_messaging`]: {{site.pub-pkg}}/firebase_messaging | ||
| [`google_maps_flutter`]: {{site.pub-pkg}}/google_maps_flutter | ||
| [`google_ml_kit`]: {{site.pub-pkg}}/google_ml_kit | ||
| [Use a custom TensorFlow Lite model with Flutter]: https://firebase.google.com/docs/ml/flutter/use-custom-models | ||
| [`speech_to_text`]: {{site.pub-pkg}}/speech_to_text | ||
| [`ar_flutter_plugin`]: {{site.pub-pkg}}/ar_flutter_plugin | ||
| [`weather`]: {{site.pub-pkg}}/weather | ||
| [`contacts_service`]: {{site.pub-pkg}}/contacts_service | ||
| [`health`]: {{site.pub-pkg}}/health | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.