Skip to content

Commit 9051327

Browse files
leighajarettsfshaza2atsansoneTony Sansone
authored
Adding Apple frameworks > flutter plugins doc (#7747)
* Adding apple framewokrs > flutter plugins doc * Apply suggestions from code review Co-authored-by: Anthony Sansone <[email protected]> Co-authored-by: Shams Zakhour (ignore Sfshaza) <[email protected]> * Update src/development/platform-integration/ios/apple-frameworks.md Co-authored-by: Anthony Sansone <[email protected]> * Making modifications based on code review * Adding link * Modifying based on feedback * Small fixes and adding links * Adding link * Refactored for table display Co-authored-by: Shams Zakhour (ignore Sfshaza) <[email protected]> Co-authored-by: Anthony Sansone <[email protected]> Co-authored-by: Tony Sansone <[email protected]>
1 parent 4482c69 commit 9051327

2 files changed

Lines changed: 339 additions & 0 deletions

File tree

src/_data/sidenav.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@
170170
- title: iOS
171171
permalink: /development/platform-integration/ios
172172
children:
173+
- title: Leveraging Apple's system libraries
174+
permalink: /development/platform-integration/ios/apple-frameworks
173175
- title: Adding iOS App Clip support
174176
permalink: /development/platform-integration/ios/ios-app-clip
175177
- title: C interop
Lines changed: 337 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,337 @@
1+
---
2+
title: Leveraging Apple's System APIs and Frameworks
3+
description: Learn about Flutter plugins that offer equivalent functionalities to Apple's frameworks
4+
---
5+
6+
When you come from iOS development, you might need to find
7+
Flutter plugins that offer the same abilities as Apple's system
8+
libraries. This might include accessing device hardware or interacting
9+
with specific frameworks like `HealthKit` or `MapKit`.
10+
11+
<!-- Add once SwiftUI PR is merged -->
12+
<!-- For an overview of how the SwiftUI framework compares to Flutter,
13+
see [Learning Flutter as a SwiftUI developer][]. -->
14+
15+
### Introducing Flutter plugins
16+
Dart calls libraries that contain platform-specific code _plugins_.
17+
When developing an app with Flutter, you use _plugins_ to interact
18+
with system libraries.
19+
20+
In your Dart code, you use the plugin's Dart API to call the native
21+
code from the system library being used. This means that you can write
22+
the code to call the Dart API. The API then makes it work for all
23+
platforms that the plugin supports.
24+
25+
To learn more about plugins, see [Using packages][].
26+
Though this page links to some popular plugins,
27+
you can find thousands more, along with examples,
28+
on [pub.dev][]. The following table does not endorse any particular plugin.
29+
If you can't find a package that meets your need,
30+
you can create your own or use platform channels directly in your project.
31+
To learn more, see [Writing platform-specific code][].
32+
33+
### Adding a plugin to your project
34+
To use an Apple framework within your native project,
35+
import it into your Swift or Objective-C file.
36+
37+
To add a Flutter plugin, run `flutter pub add package_name`
38+
from the root of your project.
39+
This adds the dependency to your [`pubspec.yaml`][] file.
40+
After you add the dependency, add an `import` statement for the package
41+
in your Dart file.
42+
43+
You might need to change app settings or initialization logic.
44+
If that's needed, the package's "Readme" page on [pub.dev][]
45+
should provide details.
46+
47+
### Flutter Plugins and Apple Frameworks
48+
49+
<table class="table table-striped nowrap">
50+
<tr>
51+
<th markdown="1">
52+
Use Case
53+
</th>
54+
<th markdown="1">
55+
Apple Framework or Class
56+
</th>
57+
<th markdown="1">
58+
Flutter Plugin
59+
</th>
60+
</tr>
61+
62+
<tr>
63+
<td markdown="1">
64+
Access the photo library
65+
</td>
66+
<td markdown="1">
67+
* `PhotoKit`<br>using the `Photos` and `PhotosUI ` frameworks
68+
* `UIImagePickerController`
69+
</td>
70+
<td markdown="1">
71+
[`image_picker`][]
72+
</td>
73+
</tr>
74+
75+
<tr>
76+
<td markdown="1">
77+
Access the camera
78+
</td>
79+
<td markdown="1">
80+
`UIImagePickerController`<br>using the `.camera` `sourceType`
81+
</td>
82+
<td markdown="1">
83+
[`image_picker`][]
84+
</td>
85+
</tr>
86+
87+
<tr>
88+
<td markdown="1">
89+
Use advanced camera features
90+
</td>
91+
<td markdown="1">
92+
`AVFoundation`
93+
</td>
94+
<td markdown="1">
95+
[`camera`][]
96+
</td>
97+
</tr>
98+
99+
<tr>
100+
<td markdown="1">
101+
Offer In-app purchases
102+
</td>
103+
<td markdown="1">
104+
`StoreKit`
105+
</td>
106+
<td markdown="1">
107+
[`in_app_purchase`][][^1]
108+
</td>
109+
</tr>
110+
111+
<tr>
112+
<td markdown="1">
113+
Process payments
114+
</td>
115+
<td markdown="1">
116+
`PassKit`
117+
</td>
118+
<td markdown="1">
119+
[`pay`][][^2]
120+
</td>
121+
</tr>
122+
123+
<tr>
124+
<td markdown="1">
125+
Send push notifications
126+
</td>
127+
<td markdown="1">
128+
`UserNotifications`
129+
</td>
130+
<td markdown="1">
131+
[`firebase_messaging`][][^3]
132+
</td>
133+
</tr>
134+
135+
<tr>
136+
<td markdown="1">
137+
Access GPS coordinates
138+
</td>
139+
<td markdown="1">
140+
`CoreLocation`
141+
</td>
142+
<td markdown="1">
143+
[`geolocator`][]
144+
</td>
145+
</tr>
146+
147+
<tr>
148+
<td markdown="1">
149+
Access sensor data[^4]
150+
</td>
151+
<td markdown="1">
152+
`CoreMotion`
153+
</td>
154+
<td markdown="1">
155+
[`sensors_plus`][]
156+
</td>
157+
</tr>
158+
159+
<tr>
160+
<td markdown="1">
161+
Embed maps
162+
</td>
163+
<td markdown="1">
164+
`MapKit`
165+
</td>
166+
<td markdown="1">
167+
[`google_maps_flutter`][]
168+
</td>
169+
</tr>
170+
171+
<tr>
172+
<td markdown="1">
173+
Make network requests
174+
</td>
175+
<td markdown="1">
176+
`URLSession`
177+
</td>
178+
<td markdown="1">
179+
[`http`][]
180+
</td>
181+
</tr>
182+
183+
<tr>
184+
<td markdown="1">
185+
Store key-values
186+
</td>
187+
<td markdown="1">
188+
* `@AppStorage` property wrapper
189+
* `NSUserDefaults`
190+
</td>
191+
<td markdown="1">
192+
[`shared_preferences`][]
193+
</td>
194+
</tr>
195+
196+
<tr>
197+
<td markdown="1">
198+
Persist to a database
199+
</td>
200+
<td markdown="1">
201+
`CoreData` or SQLite
202+
</td>
203+
<td markdown="1">
204+
[`sqflite`][]
205+
</td>
206+
</tr>
207+
208+
<tr>
209+
<td markdown="1">
210+
Access health data
211+
</td>
212+
<td markdown="1">
213+
`HealthKit`
214+
</td>
215+
<td markdown="1">
216+
[`health`][]
217+
</td>
218+
</tr>
219+
220+
<tr>
221+
<td markdown="1">
222+
Use machine learning
223+
</td>
224+
<td markdown="1">
225+
`CoreML`
226+
</td>
227+
<td markdown="1">
228+
[`google_ml_kit`][][^5]
229+
</td>
230+
</tr>
231+
232+
<tr>
233+
<td markdown="1">
234+
Recognize text
235+
</td>
236+
<td markdown="1">
237+
`VisionKit`
238+
</td>
239+
<td markdown="1">
240+
[`google_ml_kit`][][^5]
241+
</td>
242+
</tr>
243+
244+
<tr>
245+
<td markdown="1">
246+
Recognize speech
247+
</td>
248+
<td markdown="1">
249+
`Speech`
250+
</td>
251+
<td markdown="1">
252+
[`speech_to_text`][]
253+
</td>
254+
</tr>
255+
256+
<tr>
257+
<td markdown="1">
258+
Use augmented reality
259+
</td>
260+
<td markdown="1">
261+
`ARKit`
262+
</td>
263+
<td markdown="1">
264+
[`ar_flutter_plugin`][]
265+
</td>
266+
</tr>
267+
268+
<tr>
269+
<td markdown="1">
270+
Access weather data
271+
</td>
272+
<td markdown="1">
273+
`WeatherKit`
274+
</td>
275+
<td markdown="1">
276+
[`weather`][][^6]
277+
</td>
278+
</tr>
279+
280+
<tr>
281+
<td markdown="1">
282+
Access and manage contacts
283+
</td>
284+
<td markdown="1">
285+
`Contacts`
286+
</td>
287+
<td markdown="1">
288+
[`contacts_service`][]
289+
</td>
290+
</tr>
291+
292+
<tr>
293+
<td markdown="1">
294+
Expose quick actions on the home screen
295+
</td>
296+
<td markdown="1">
297+
`UIApplicationShortcutItem`
298+
</td>
299+
<td markdown="1">
300+
[`quick_actions`][]
301+
</td>
302+
</tr>
303+
304+
</table>
305+
306+
[^1]: Supports both Google Play Store on Android and Apple App Store on iOS.
307+
[^2]: Adds Google Pay payments on Android and Apple Pay payments on iOS.
308+
[^3]: Uses Firebase Cloud Messaging and integrates with APNs.
309+
[^4]: Includes sensors like accelerometer, gyroscope, etc.
310+
[^5]: Uses Google's ML Kit and supports various features like text recognition, face detection, image labeling, landmark recognition, and barcode scanning. You can also create a custom model with Firebase. To learn more, see [Use a custom TensorFlow Lite model with Flutter][].
311+
[^6]: Uses the [OpenWeatherMap API][]. Other packages exist that can pull from different weather APIs.
312+
313+
<!-- [Learning Flutter as a SwiftUI developer]: -->
314+
[Using packages]: {{ site.url }}/development/packages-and-plugins/using-packages
315+
[pub.dev]: {{site.pub-pkg}}
316+
[`shared_preferences`]: {{site.pub-pkg}}/shared_preferences
317+
[`http`]: {{site.pub-pkg}}/http
318+
[`sensors_plus`]: {{site.pub-pkg}}/sensors_plus
319+
[`geolocator`]: {{site.pub-pkg}}/geolocator
320+
[`image_picker`]: {{site.pub-pkg}}/image_picker
321+
[`pubspec.yaml`]: {{ site.url }}/development/tools/pubspec
322+
[`quick_actions`]: {{site.pub-pkg}}/quick_actions
323+
[`in_app_purchase`]: {{site.pub-pkg}}/in_app_purchase
324+
[`pay`]: {{site.pub-pkg}}/pay
325+
[`firebase_messaging`]: {{site.pub-pkg}}/firebase_messaging
326+
[`google_maps_flutter`]: {{site.pub-pkg}}/google_maps_flutter
327+
[`google_ml_kit`]: {{site.pub-pkg}}/google_ml_kit
328+
[Use a custom TensorFlow Lite model with Flutter]: https://firebase.google.com/docs/ml/flutter/use-custom-models
329+
[`speech_to_text`]: {{site.pub-pkg}}/speech_to_text
330+
[`ar_flutter_plugin`]: {{site.pub-pkg}}/ar_flutter_plugin
331+
[`weather`]: {{site.pub-pkg}}/weather
332+
[`contacts_service`]: {{site.pub-pkg}}/contacts_service
333+
[`health`]: {{site.pub-pkg}}/health
334+
[OpenWeatherMap API]: https://openweathermap.org/api
335+
[`sqflite`]: {{site.pub-pkg}}/sqflite
336+
[Writing platform-specific code]: {{ site.url }}/development/platform-integration/platform-channels
337+
[`camera`]: {{site.pub-pkg}}/camera

0 commit comments

Comments
 (0)