How can I access device information without using packages in Flutter? - 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

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.

Local Notifications

I'm building my first app in Flutter and want to include local notifications for Android and iOS. I've searched quite extensively for how to implement these, but every search result on Medium, Youtube, or random website uses flutter_local_notifications on pub.dev (I can't find anything on api.flutter.dev except for icons). I'm sure it's a great resource, but I've been trying to code everything from scratch rather than use these plugins so I can understand the foundational mechanics better.Anyone know of a resource to guide me?
As Notifications are pretty platform-specific, there is no direct approach of calling notifications from flutter itself. You rather have to write your own native code for both ios and android in order to send notifications. For android, you can either use Java or Kotlin as a native language, and for iOS, you use Swift.
You can follow this tutorial in order to get your hands on a native method for calling notifications on android.

Including a native SDK (for IOS and Android) into flutter

i am currently facing the following problem and I hope someone can help me out:
I want to write an app in Flutter (yes I already compared this framework to others like React Native and Ionic) but i need to include the motiontag SDK and here is where the problem starts.
The Motion Tag SDK is only available for native App descreptive native programming language (Java/Kotlin, Swift).
Is there a way to include the SDK anyway to flutter??
Like some workaround!
Thanks for helping me out!
Flutter does have communication with native via Platform Channels, so if the sdk is just function calls you could call the function from flutter/dart , and then let the platform channel handle the call to the native function with arguments. If the sdk it's about rendering UI inside flutter then it's more complicated but it's possible as long as you use the boundaries of PlatformView . All the native plugins developed for flutter use this two methods to handle native code/UI

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

Flutter - Android Native Platform Integration

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.