I'd like to give a try with flutter, but so far I have found only NFC reader plugin. I will need two other things.
react on NFC tag present intent and then maybe use NFC plugin to read it
write to NFC tag, probably using Platform channels
I just need to confirm it is feasible at all with flutter and will need the kick in the right direction, before I will leave plain android.
perhaps I am a little late to the party, however as I just tackled a very similar problem, I want to weigh in on this topic:
So reading/writing NFC with Flutter is possible. As mentioned before you need a platform channel in order hand the command to the native system, AND an event channel, if you want to read data to your flutter app, to accomplish this task.
The best way would be, if a plugin was available to handle this, however I could not get the one which you mentioned too to work with my flutter app (specifically, because I tried with IOS and swift).
However here are some ressources, from which I puzzled together my system:
Communication from flutter to native system via platform channels: This link is the offical flutter page which interestingly only described the communication from flutter to native system, but not the other way around. For the other way you need:
Communication from native system to flutter app via event channels: (yes you need a different channel for the communication back to the flutter app). This example is only for android. For swift, all I could find was this ressource, which however seems to be a bit old.
NFC Tutorial for IOS: This is actually pretty simple as long as you have a developper account. A good minimalistic tutorial can be found here
NFC Tutorial for Android: This is actually even simpler, as nfc is longer established on android. I like this one
I think what you're looking to do is definitely possible, but as you mentioned in your question you will have to use Platform Channels.
The platform channels can go both ways; you should be able to set it up so that your main activity receives the NFC tag present intent, and then you send a method call from android to dart. Or you could start listening from dart and then have the method return when the intent is received.
Writing to NFC is about the same, you use method channels to call across.
Depending on what you're doing, you may want to consider splitting the NFC functionality into a plugin, even if you don't end up publishing the plugin.
With this fork from flutter-nfc-reader you can now read and write nfc tags from android and read them from ios https://github.com/semakers/flutter-nfc-reader
to install add the following dependency your pubspec.yaml
dependencies:
flutter_nfc_reader:
git:
url: git: //github.com/semakers/flutter-nfc-reader.git
ref: master
In the Readme.md of the repo are the installation and use instructions.
Happy NFC Tag writing!!
Related
I have an application that use Flutter. In application, i am using flutter_blue_plus package to communicate ble devices. I wrote also a bluetooth service to handle packaging, encoding (AES for example) sending data. i want to make that bluetooth service(dart code) like package to use in other application like native android or iOS applications. Is there a way to make it?
Appreciated any documention, video or example code.
Check the officials docs Developing packages & plugins
Else check for some tutorials.
As the title says, I want to implement a Git interface in my Flutter app: I need it to have basic functionality (commit, push, pull, merge) on an internal path repo (no external storage access). There is this git package for Dart, which is only a CLI interface, i.e. not compatible with Android, which is the main issue I'm facing, as I need my app to be compatible with that and Windows.
I happen to use GitJournal, an Android note-taking app that uses Git to sync. I found out that it is also built in Flutter -- it does essentially the same things I need out of this Git implementation, so eureka, maybe?
It seems to be using libgit2, along with both(?) this custom git_bindings Dart package (related pub.dev page) and this other dart-git custom implementation fully in Dart. This last package apparently isn't fully-featured, is experimental and maybe only used in parallel with the previous git_bindings thingy.
Last thing I found, one could write custom ffigen-libgit2 bindings, but I'm positive that some of the things I posted before are already using this in some way. Plus, I would have no clue on where to start with this.
I don't require a bullet-proof implementation, meaning that I'd be willing to play around with an experimental / bleeding-edge solution, as long as it does the job and doesn't require me to reinvent the wheel.
I have no familiarity with bindings, interfaces between languages and such trickeries, but I'd be willing to do some learning if necessary. Needless to say, the simplest the solution, the better -- I chose Flutter for a reason, after all :D
Thanks in advance
I'm trying to add native android code to an already existing Flutter app, that does something quite different.
So I'd just like to have all of that functionality on top of my current app.
The native android app is using Bluetooth to connect to an external device and is collecting data periodically.
I know, that there is the possibility to call native code via platform channels, but it seemed to me, that you'd have to call that code every time you want to use it? Is this a reasonable way to implement the app or should it be rewritten in Dart? What's the best practice here?
Hope you can help me, thanks a lot!
The purpose of platform channels is to call platform-specific APIs.
...you'd have to call that code every time you want to use it...
Correct.
...Is this a reasonable way to implement the app or should it be rewritten in dart? What's the best practice here...
Check the source code of any package that relies on platform channels (for example camera, file picker, etc.) and read the official documentation. As a short summary, platform-specific code is written in Kotlin/Java (Android), Swift/Objective-C (iOS) or C/C++. Dart is used for building the UI and communicating with said code via platform channels and messages.
We want to develop mobile keyboard app - (Third party keyboard) that have some unique features (such translate on the keyboard).
We would like to know if there is a way to developed it once both for IOS and Android, with Flutter, or any other solution?
There's a long and a short answer to this. The short answer is basically no, it's not feasible at this time to do this.
The long answer is that it may be somewhat possible but with a fairly large amount of work for you to do. You're going to have to first create and appropriate project type in android and ios, and then import the dart code & set up the build. You may be able to start with a normal flutter application and modify the xcode/gradle builds to match the specifics for ios/android, but I'd guess that's somewhat unlikely. So you'll probably still have to maintain two separate projects, but which could import the same dart library for the UI.
Because Android and iOS use different APIs for their keyboards, you're going to need to write a Platform Plugin or at least method channels which communicate between your app and the native code, for each of iOS and Android. You'll also probably have to embed the flutter view yourself - see this example as I'd bet the normal FlutterApplication etc won't apply.
I'd guess that on android you could probably get this to work eventually with a lot of work (depending on how familiar you are with android, platform channels, and integrating libraries such as flutter's into the build); on iOS you might have luck but it's somewhat conceivable that iOS blocks certain features that flutter needs in the keyboard for performance or security reasons - just guessing from my experiences developing apps in native iOS although I haven't done a keyboard specifically.
That being said, if you do try this I'd be interested to hear the results, and if you were to go about it in a somewhat generic way that could be re-used it would be of great benefit to the flutter community!
What I hope to do is tell something that I think is important to Dart community.
If somehow it was possible to code android and or iPhone apps using Dart that would be very awesome and same for Dart.
There is one path, that is making program in Dart compiling it to JavaScript and then making app using Adobe air.
But looks inefficient.
So is there any other way which I am unaware of, via which I can build an Android app at least? Using Dart I know you can build an app, using JavaScript and HTML/CSS. So I am looking for HTML + CSS + Dart.
It'd be cool if adobe air supports Dart language directly.
great question! You can connect to the Dart community in a few ways.
Discuss Dart with other community members and engineers at the Dart mailing list.
File bugs and features requests in our public bug tracker: dartbug.com
Ask questions on Stack Overflow using the tag dart. :)
For news and updates, I suggest following:
new.dartlang.org for a blog style feed
+Dart on Google+
#dart_lang on Twitter
In you specific case, when you have a big idea like the one you are suggesting, I would recommend the mailing list.
Just to add to Seth's comments. One other way of interacting with the Dart Community is the #dart channel on irc.freenode.net which you can access from any irc client (such as mIRC, xchat, etc), or from the Freenode webclient
Something to look at for using Dart to build phone apps, though it would still involve first converting to JS, is PhoneGap. You're right: it would be cool if Dart were directly supported on more platforms, but it's really only one simple step to produce the JS from Dart.
To check out some of my own experiments with standalone iPhone web apps (games, of course) created in Dart, click here.
The short answer, then, is, yes: it certainly is possible to create apps for mobile devices with Dart, but, at least for now, it will probably involve clicking the "Generate Javascript" option in DartEditor somewhere along the line.