1

I'm trying to create a Facebook login plugin for Flutter and already got the native code running. There is one thing I don't get though. Where do the dependencies, uses permissions and meta data go? I guess the dependencies and permissions could be added to the plugin's android folder. But the meta data needs a key that only the user can provide. So I can not put it in the android folder of my plugin, only in an android folder in projects using the plugin. But I need the meta data to make the plugin work. So I'm kinda stuck atm. Any one who has experience with this?

Bram Vanbilsen
  • 5,763
  • 12
  • 51
  • 84

1 Answers1

1

Dependencies can be added in the build.gradle and podspec of the plugin. Though if it depends on a non-standard Maven or CocoaPods repo, users will need to specify that in their project.

Permissions are added by the user if needed. Same with configuration files. Use the README of the plugin to explain what needs to be done.

If the configuration info is the same across iOS and Android (API keys etc), passing it from Dart to native is a good practice to avoid duplication. If the configuration info is different for each platform, having it be read out of a file by the plugin (or specified in the AppDelegate/Activity) allows the Dart to be agnostic to which platform it's on.

Check out the google_sign_in plugin for inspiration.

Collin Jackson
  • 110,240
  • 31
  • 221
  • 152
  • Still a bit confused on this. Perhaps I'm mssing something. Will the plugin and user project work as 2 seperate things? And are AndroidManifest.xml and strings.xml merged in the sense that the plugin is aware of those files in the main project and can use that data? – Bram Vanbilsen Jun 22 '17 at 20:39
  • You can read data out of the user's AndroidManifest.xml or strings.xml in the plugin if you want. https://stackoverflow.com/questions/10311890/is-it-possible-to-have-custom-attributes-in-androidmanifest-xml-tags https://stackoverflow.com/questions/6583843/how-to-access-resource-with-dynamic-name-in-my-case – Collin Jackson Jun 22 '17 at 21:07
  • I'm not really an android guy. But to simplify the question a bit more: if I place some meta data in a project in androidmanifest, will the plugin be able to get to that data and use it. So i.e. an unique app key in androidmanifest in the project will be recognized and usable for the plugin? – Bram Vanbilsen Jun 22 '17 at 21:43