ANDROID STUDIO SDK GCLOUD SDK ANDROIDYou could run the application directly from Android Studio or from the Terminal, go to the root folder of the application and give flutter run command. ANDROID STUDIO SDK GCLOUD SDK CODEIf you have followed the previous 2 links that I provided to the documentation, this code is heavily borrowed from there, so I suggest that you study that. The _getRandomQuote() function makes a call to the FUNCTION_URL (be sure to replace it with your function url), parses out the JSON and then sets the value in the _randomQuote variable.Our scaffolding for the widget includes a Text field that will contain the value of the random quote and a button, which will invoke the _getRandomQuote() function on clicking it.We are maintaining a variable named _randomQuote in our state.We begin with MyApp but notice that our home attribute is a Stateful Widget RandomQuotes. The source code is pretty standard for building out a single screen app in Flutter.Here are some key points from the above source code: Simply replace it with the source code given below: You will see some sample code present in the lib/main.dart file. They are worth your time to understand what is going on.Īssuming that you have setup the Flutter plugin in Android Studio, you can create a new Flutter project. I strongly recommend that you go through the above documentation links. Making HTTP Networking Requests in Flutter.Here are a couple of specific links that helped me understand the basics of a simple Flutter App. Since I have just started with Flutter, I heavily relied on the documentation to help me get started. Great! Now that we are done with developing our GCF, it is time to take a look at the Flutter App. You can also test out the FUNCTION_URL directly in your browser and you should get a similar JSON output for a particular quote. Please make a note of the FUNCTION_URL as mentioned earlier. Simply click on the Test the function button and you should get the output. In a real world scenario, I expect that you do your development locally and either deploy it from a repository or from your local machine via the gCloud SDK.Īssuming that you are logged into to Google Cloud Console and selected your specific Google Cloud Platform project, navigate to Cloud Functions. The only reason I am doing this is to keep things simple and our function is very compact and there is nothing much to it. I am going to demonstrate developing our function completely in the cloud via the Google Cloud console. Google Cloud Function : getrandomquote-function
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |