I read this Android specific article and was wondering if some applications existed for Flutter aswell.
I know it is possible to run native code in Flutter, but I'd prefer a Dart native solution. I've noticed this package on pub.dev but I cannot make it work.
I've followed the posted example but I get a MissingPluginException for every call the plugin executes.
Yes You can do it by using this package .
https://pub.dev/packages/flutter_nearby_connections
Related
I'm building a Flutter app that will have the capability to execute some actions when the device connects to another bluetooth device. This app should work on Android and iOS but for the sake of simplicity I'll focus on Android in this post. Also, this has to work whether the app is in the foreground, in the background or killed.
Here is the architecture of the app:
I have an Android native code that registers to bluetooth events through a BroadcastReceiver.
I followed this tutorial to set up the communication between the Android code and the Flutter code: https://medium.com/#chetan882777/initiating-calls-to-dart-from-the-native-side-in-the-background-with-flutter-plugin-7d46aed32c47.
When the Android BroadcastReceiver is triggered by a bluetooth event, the information is sent to the Flutter code (even if the app was in the background or killed). A Flutter isolate is created to handle the Flutter code.
Everything works perfectly well. The Flutter code is called and I can use print(data) to log the data that have been provided by the Android code.
Things are becoming more tricky when, from the isolate, I want to call any Flutter plugin (like sqflite, package_info_plus, ...). I get this error every time:
[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception:
MissingPluginException(No implementation found for method xxx on
channel yyy)
I understand that spawned isolate can't natively run Flutter plugins. There are some posts (Unable to understand Flutter Isolate workaround for "'Window_sendPlatformMessage' (4 arguments) cannot be found" error, https://github.com/flutter/flutter/issues/13937) that explain how to create isolates that can run Flutter plugins by using a workaround or a plugin like https://pub.dev/packages/flutter_isolate.
However, I can't create the isolate with this package because the isolate is created from the Android code.
Can one of you tell me how I can achieve this? Is there a way to use Flutter plugins from an isolate that has been created by native code?
Thank you very much in advance
Sounds like the way you create the Flutter isolate may not be compatible with your goal. There are some solutions to integrate Flutter with native Android/iOS projects, such as flutter_boost (disclaimer: I have not tried it and not sure good or not; you may find many other alternatives as well, this is just an example). You can use that to create the Flutter environments. Since the solutions above allow some Android code to open a new normal Flutter page and Flutter code in that page is able to do anything (of course include calling native - otherwise things like flutter_boost is really useless), this should work.
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.
I have an application, written in flutter, that is heavily dependent on the feature of scanning pdf-417 type codes. In the Android port, it works easily, using the qr_code_scanner 0.0.13 library from pub.dev. I need a web application, for various reasons, and I want to implement the scanning functionality in it. I have tried searching librarys that support the web also, but couldn't find anything relevant. I tried creating a html/js scanner webpage, with zxing-js, that works in a normal browser, but not in the flutter webview, which uses the easy_web_view pub.dev package. It seems from the errors, that it cannot access the camera. What should be the easiest way of solving this? Thanks in advance for your answers.
You can use this package that support web, android and IOS in flutter.
Also see this link
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
I am developing a mobile application with Flutter framework and I want to scan bill bar-code and extract its code, so I need a bar-code scanner library for my app. Actually I've googled and found some libraries and SDKs, but they are not written in Dart and I have to import and implement them separately for Android and iOS directories, also it has lots of effort for me to import native codes to a Flutter project. Now I have following questions:
Is there any Dart written and Flutter compatible package, library, SDk, API or ... to use in Flutter project?
Hasn't Google made Flutter version of its ML-KIT or Google-Vision SDKs for its own multi platform framework?
Thanks in advance for helping me.
There are no direct flutter widgets available which supports Barcode reading as of now.
Anyway you can use firebase_ml_vision plugin which pretty straight forward and easy to integrate.
https://pub.dartlang.org/packages/firebase_ml_vision
There is, but I haven't ever used it myself. Just searched it on here: https://pub.dartlang.org/flutter
https://pub.dartlang.org/packages/barcode_scan or maybe this https://pub.dartlang.org/packages/barcode_flutter