Passing command line arguments to a flutter app - flutter

Is package:args ArgParser compatible with flutter apps? I see on Github that it is used several times in some Flutter tools, but I'm not sure it's used in any of the sample apps.
If it is not compatible, is there another way to pass configuration options to my app at compile time as part of its build rule?

package:args operates on List<String>, which can come from anywhere. For example, I've used it in a browser app, in which the arguments came from Chrome's JS console. If you are OK with using the HostMessages API, then the following might work for you:
On Android, turn Intent.getExtras into List<String> and pass it to package:args. Similarly, this answer may help on the iOS side.

Related

How to read `--flavor` parameter value from flutter code?

Flutter run and build commands accept the --flavor parameter. I have found a tutorial on implementing it in Android and iOS projects. And, I also found a way to access the flavor name from the flutter code.
But I still have no idea how to access the flavor name on other platforms. It seems flutter documentation has no information about it.
Is there a way to read the --flavor parameter value from the flutter code on any platform?
The reason for my question in the comments is that you might be looking for using the --dart-define flag when building your app, instead of --flavor.
They serve different purposes, so both might be required depending on your desired outcome.
The value passed via the dart define flag can be accessed in the code via String.fromEnvironment(...)

What should I use for i18n in Flutter: S.of(context) or S.current?

I'm using the i18n plugin for Flutter (I believe it's this one) that comes with Android Studio.
And in every example I see it says to use S.of(context).my_string to get the Strings but it always returns null.
If I use S.current.my_string, it seems to work.
So is S.current the right way to do it and every doc/tutorial out there is wrong, are they the same or what?
What I'm basically asking here, is what is the difference between them.
Seems like S.of(context) is initially available way to access localised string.
But sometimes you need to use it without Build Context (in ViewModel, for example). So S.current was added for these cases.
More info here

Fluter/Dart code loading over network

Recently, I watched the first introduction of Flutter originally named Sky on Youtube https://www.youtube.com/watch?time_continue=10&v=PnIWl33YMwA .
At 1:54 Eric Seidel says something like this - This all is loaded over the network. Dart code of the network. What happenend to it in Flutter?
Is it possible to load Dart code like new versions directly over the network without using the AppStore?
I'm not sure Eric was talking about the data or the actual code. It does sound like he meant both.
It may have been possible to load code over the network because on these early days they shipped the dart VM on releases and code was JIT compiled. Since late 2015 Flutter moved to Dart's AOT compilation (see this video).
So no, it's not possible to update your flutter apps through the network.
This all is loaded over the network. Dart code of the network
After watching the video, I got the context of the line. It means the data getting fetched from the network and the code written is in the Dart rather than Java.

Facebook is not initialized when using Facebook Login with React in Production

I love React, it has quickly become my favorite development tool. It is a fantastic library that creates the kind of flexibility I've always dreamed about.
That said, I'm having a very hard time getting Facebook login to work with React in production.
I have tried all of the following methods. In all three cases, I implemented the examples exactly as shown in the code using the simplest possible technique:
https://github.com/seeden/react-facebook
https://github.com/keppelen/react-facebook-login
http://jslancer.com/blog/2017/11/27/facebook-google-login-react/
Everything works great in development. :)
When I create the production build using create-react-app and push it live, it breaks and reports: Error: Facebook is not initialized or Uncaught TypeError: Cannot read property 'login' of undefined where undefined is FB.
Basically it seems like the Facebook javascript SDK is not loaded or initialized.
The first two links above are for existing component libraries, but the third is a custom implementation that places the Facebook initialization code in the index.html file and creates an event listener. The results are the same in all three examples.
It is as if something about the create-react-app compression method is obfuscating the variables to the point that Facebook can no longer work, or at least is not available to the react code. This includes all calls to window.FB as recommended in many tutorials.
I've been working at this for a couple of weeks now (off and on) and am now turning to the hive mind. Anyone have any ideas on how to get Facebook to actually work with Facebook's own code library (React)? It seems so painfully odd that it causes this much trouble and I have been unable to find a clear solution that works in production.
Most of the debugging steps are already mentioned in the comments section.
Here are the steps laid down:
1) Check the network tab in your browser's console and see if the request to load FB's SDK is successful or not
2) Most common culprit is some extension like Ad-Blocker blocking such async requests which loads JS on your web page. Disable it or try it incognito mode
3) Other common mistake I have seen is forgetting to use the FB.init({ // config }); function - which is the actual call which initializes the fb sdk and makes available the FB variable globally.

Use protractor for desktop application testing

I have installed application on my desktop.I want to do the automation testing of this application with the use of protractor scripts.Please provide the suggestions.
Depends on what type of application you want to test. ProtractorJS is not the best tool for desktop app testing - since it designed for web-apps.
But if your desktop app built on electronjs - that changes the picture. In this case you can try to use this tutorial - https://github.com/electron/electron/blob/master/docs/tutorial/using-selenium-and-webdriver.md
Protractor provides method .wrapDriver() http://www.protractortest.org/#/api?view=Browser.wrapDriver
So i think you can try to wrap that driver from tutorial into protractor instance and work with it. I never tried that, and unfortunately you should try by your own, since it is not a common use-case of protractor.