Flutter - Android Native Platform Integration - flutter

When an external component such as a Camera or File picker is needed, the Flutter for Android Developers documentation (currently in the works) states that we would have to build a native platform integration.
I currently have a device that has a built-in barcode reader with a manufacturer-provided Android API. So, for that I would need to pursue this native platform integration method - or even for playing videos or using the camera for that matter I would think.
Is there an example repo that demonstrates how a well-integrated app should be? ..a project that integrated ExoPlayer for example?

You can use platform channels to call native APIs that aren't exposed by the Flutter platform.
There is an example in the Writing custom platform-specific code docs:
The full, runnable source-code for this example is available in /examples/platform_channel/ for Android with Java and iOS with Objective-C.
If you want to make your code reusable by others, you can publish it as a package, but this is optional. There is a repo of plugins maintained by the Flutter team that you can use for inspiration.

Related

Build SDK in Flutter/Dart and use it from Java / Web

We are building an application in Flutter, which is composed of an SDK (no UI Code) and a Flutter UI, using the SDK.We have now the requirement to provide the SDK for other, native target platforms (iOS, Android, Web, JVM) and use it in existing applications. As far as we have understood this is possible for iOS and Android. But is this also possible (or planned) for Web and JVM? We simply want to minimise the effort to build the similar SDK in various platform specific technologies.
Thank you!
You can build your Flutter app targeting web https://docs.flutter.dev/development/platform-integration/web/faq#is-the-web-version-of-flutter-ready-for-production
If you want to target the Desktop then check https://docs.flutter.dev/development/platform-integration/desktop to see if it meets your requirements.

How can I access device information without using packages in Flutter?

How can I access device information without using packages in Flutter? How can I get the information of the device where the app is installed in my Flutter app?
First, you'd be better off using packages. But if you really want/need to do it, you'd have to write platform-specific code code in the native language of the targeted platform (ie. Swift or Objective-C for iOS/Mac, Kotlin or Java for Android, etc), then use so-called platform channels to pass messages between your app and the platform-specific code.
If you'd like to get details about the device, on iOS you'd use UIDevice, on Android you'd typically want Build.
This can only be done through Method Channel

Do iOS and Android Flutter widgets also work on Flutter Web(PWA)

I'm interested in using Flutter primarily for my startup MVP on Web and possibly Android. I see the flutter community has made a lot of widgets but a lot of them are tagged iOS or Android. Since Futter is all about using one codebase is it wrong to assume that these widgets would work on web too? I imagine the setup would be different but similar with a Flutter web app as opposed to a Flutter Android app.
I couldn't find a whole lot about this on the Flutter site. I also know that web is still beta but by the time I'm done with the MVP it'll probably be at stable release or close enough.
Well... It depends. If the widget has some sort of native code the answer is no. In Flutter there are two type of packages: the "normal" package, and the plugin.
The packages are made only of dart code, so there are no bounds to native, and you can use everywhere dart (and Flutter) can run.
The plugins are packages with native code and you can use only on the platform supported by that plugin.
For example the package provider, it's a package, and you can use in every supported platform where dart (and Flutter) can run. But url_launcher, it's a plugin, so you can run only on Android, iOS, and web, but for example on desktop, it will no work.
If the package if you found it's only a widget, you should be able to use on the web.
TLDR: No,a PWA it's a web app, so it can't run Android or iOS specific code.

Setting Flutter project: iOS and Android languages

When I create a new Flutter project, it asks me to choose between Java/Kotlin for Android and Objective-c/Swift for iOS. But, what does this mean? Is it in case I want to write something for Android or iOS specifically?
Yes that is correct. In Flutter you have the option to call into platform-specific APIs. This is especially useful if you need to access functionality that is not available in Flutter directly (e.g. accessing the keychain on iOS or the keystore on Android).
To do so you can open up a message channel which bridges the Dart world with the platform-specific world. You can use this message channel to send a message from Dart to you platform-specific code. This platform-specific code is either Java/Kotlin for Android or Objective-C/Swift for iOS, depending on your selections during the creation of the project.
More detailed information can be found in the Flutter documentation here: https://flutter.dev/docs/development/platform-integration/platform-channels
Just a heads up, the Flutter team and the Flutter community already wrote a lot of OSS packages and plugins that will take care of the platform-specific stuff and offer you an easy Dart API. You can search for these packages in the Pub: https://pub.dev

Does Ionic compile the Code to Native?

I've searched some times here but could't find an Answer to this.
Does someone know this and can explain how Ionic handles it?
Does Ionic compile the Code to Native? NO
Ionic is for developing Hybrid apps.
What are Hybrid apps?
Hybrid apps are essentially websites embedded in a mobile app through
what we call a webview. They are developed using HTML5, CSS, and
Javascript, and execute the same code regardless of the platform in
which they run. They can, with tools like PhoneGap and Cordova, use
the native features of a device, like GPS or camera.
What are Native apps?
Native apps are developed in the language required by the platform it
targets, Objective-C or Swift for iOS, Java for Android, etc. The code
written is not shared across platforms and their behavior varies. They
have direct access to all features offered by the platform without any
restriction.
Here is a nice article about it.
Cordova converts the project into a native which has only ONE Page, that is a WebView (WKV WEB View in iOS, etc). And all of the ionic code is run on that webview. Basically an ionic/cordova app is a website which looks like an app!