Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPIKE: Make Basic REST API Request #6

Closed
7 tasks done
nelsonic opened this issue Dec 27, 2019 · 19 comments
Closed
7 tasks done

SPIKE: Make Basic REST API Request #6

nelsonic opened this issue Dec 27, 2019 · 19 comments
Labels
enhancement New feature or request

Comments

@nelsonic
Copy link
Member

nelsonic commented Dec 27, 2019

We will need to make API requests to our Phoenix Backend App in order to save data to the remote database. With that in mind we need to write a quick tutorial on how to make API requests in Flutter.

Todo

Potential useful links:

If you have any questions on any part of this, please ask by commenting below.
If you are new to APIs or need a refresh/reminder, watch this video: dwyl/learn-api-design#38

@miguelmartins17 in case you are wondering why this issue has the word "SPIKE" in the title,
see: https://en.wikipedia.org/wiki/Spike_(software_development) 😉

@nelsonic nelsonic added the enhancement New feature or request label Dec 27, 2019
@miguelmartins17
Copy link
Collaborator

@nelsonic Working on this one right now 😎

@miguelmartins17
Copy link
Collaborator

Links that may be helpful in resolving this issue.

https://pub.dev/packages/giphy_picker

https://flutter.dev/docs/cookbook/networking/fetch-data

@miguelmartins17
Copy link
Collaborator

It is not possible to use the same API key as it was in elm because of an authentication error.

Screen Shot 2020-02-13 at 20 55 49

@nelsonic
Copy link
Member Author

failure + persistence = progress. 😉

@miguelmartins17
Copy link
Collaborator

Of course I'll get a new API key from the site and keep going until I get it.

@miguelmartins17
Copy link
Collaborator

I've got a new API key now.

Screen Shot 2020-02-14 at 08 19 09

@miguelmartins17
Copy link
Collaborator

This is the link that can help. When I have some progress I will comment here or in case I have more doubts I will open an issue.

https://stackoverflow.com/questions/53936739/how-to-control-gif-animation-in-flutter

@miguelmartins17
Copy link
Collaborator

@nelsonic I think the error was in using the API key. Where should I put ? Along with the link ?

@miguelmartins17
Copy link
Collaborator

miguelmartins17 commented Feb 18, 2020

@nelsonic I was looking at the example you did on elm but I can't figure out one thing where the API key is ?

@nelsonic
Copy link
Member Author

@miguelmartins17 we need to investigate how to use Environment Variables in Dart/Flutter. That way you can include the API key in your app but not hard-code it. see: dwyl/learn-environment-variables#20

@miguelmartins17
Copy link
Collaborator

@nelsonic I think I've now reached the point where I need help I haven't been able to get the random gifs to work

@nelsonic
Copy link
Member Author

Ok. In a comment here on GitHub, describe what you are trying to achieve in as much detail as possible and exactly what you have already tried. Then, while I am editing/expanding your comment, you open an account on https://stackoverflow.com
Once we have formulated the question, you will post the question on SO
and I will make sure it has the correct tags/exposure so you get an answer.
Having a good rating on SO is essential to working as a developer.

@miguelmartins17
Copy link
Collaborator

This is the repository I found at the github.
I have to see the output of the application in order to understand if it is not incomplete.

https://github.com/kcarta/flutter-random-gif

@miguelmartins17
Copy link
Collaborator

@nelsonic The code didn't work for me. It doesn't show the gifs like it's loading.
I'll try to change a few things to see if I can make it work.

@nelsonic
Copy link
Member Author

@miguelmartins17 I tried to run it on my localhost and got the following error:

[!] Your app isn't using AndroidX.
    To avoid potential build failures, you can quickly migrate your app by following the steps on https://goo.gl/CP92wY.
/Users/n/.gradle/caches/transforms-1/files-1.1/support-compat-28.0.0.aar/f997e1c9b9354953b2226f6c368165b8/res/values/values.xml:133:5-70: AAPT: error: resource android:attr/fontVariationSettings not found.

/Users/n/.gradle/caches/transforms-1/files-1.1/support-compat-28.0.0.aar/f997e1c9b9354953b2226f6c368165b8/res/values/values.xml:133:5-70: AAPT: error: resource android:attr/ttcIndex not found.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Failed to process resources, see aapt output above for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                         1.9s
Gradle task assembleDebug failed with exit code 1

Followed the instructions on https://flutter.dev/docs/development/androidx-migration

When I attempted to run Refactor > Migrate to AndroidX I see the following:
image

There wasn't anything to change in the project ... but it still didn't run. 🙄

Then while reading /kcarta/flutter-random-gif/pubspec.yaml#L22
we see that it is using a package called giphy_client > https://github.com/brianegan/giphy_client
This looks like a promising avenue of exploration. 💡

@miguelmartins17
Copy link
Collaborator

How can I push the files to GitHub except the one with the API key?

I'm trying to push the code to the GitHub but I don't want to put the file that contains the API key, how can I push without pushing that file.
If I use . all the files go to Github.

@nelsonic
Copy link
Member Author

nelsonic commented Apr 6, 2020

@miguelmartins17 did you read https://github.com/dwyl/learn-environment-variables ?
We use .env files in most of our projects and safely add the .env file to .gitignore.

The Dart/Flutter dotenv package: https://github.com/java-james/flutter_dotenv
shows us that it's the same in Dart/Flutter. See: .gitignore#L74

@miguelmartins17
Copy link
Collaborator

@nelsonic Thanks, so I'm gonna do that, and I'm gonna push it to the GitHub.

@nelsonic
Copy link
Member Author

Closing as the code created is now out-of-date. 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants