bazrafkan / google_place

A new Flutter package for handle google place api
MIT License
84 stars 126 forks source link

Error on example code #2

Closed domizilver closed 4 years ago

domizilver commented 4 years ago

i got this error while running the code from example.

'package:google_place/google_place.dart': Failed assertion: line 65 pos 12: 'apiKEY != null': is not true.

i have my api key in 'api_key'.

bazrafkan commented 4 years ago

Hello, This message show your apiKey is null.

Do you done these steps?

  1. Create .env file in root of this example
  2. Add your key for Google place API in this file (ex: API_KEY=XXXXXXXXXXX)??? API_KEY no api_key
  3. Get packages from the command line: flutter pub get
bazrafkan commented 4 years ago

I think if you change api_key to API_KEY in .env file, it working

domizilver commented 4 years ago

yes i have my api key in "API_KEY". what do you mean by create .env file in root?

bazrafkan commented 4 years ago

you show create a file with name .env in example directory, the write your key in this file like API_KEY=XXXXXXXXXXX

domizilver commented 4 years ago

you mean like this? i created key.env outside of lib folder same row as pubspec.yaml file

Annotation 2020-05-08 044252

bazrafkan commented 4 years ago

your file name is "key.env", should be ".env", just change name of file to ".env"

domizilver commented 4 years ago

renamed to .env still no success :(

Annotation 2020-05-08 050136

bazrafkan commented 4 years ago

Do you run flutter pub get?

domizilver commented 4 years ago

yes, flutter clean as well

bazrafkan commented 4 years ago

Now is working?

domizilver commented 4 years ago

still not working :( received same message

Annotation 2020-05-08 051229

bazrafkan commented 4 years ago

you can write directly your key in this line: 37: String apiKey = DotEnv().env['API_KEY']; to String apiKey ="your-key";

domizilver commented 4 years ago

still not working.

Annotation 2020-05-08 051845

i tried my key on different google place api code and it works fine

bazrafkan commented 4 years ago

Now , what's the problem? Can you show me error?

domizilver commented 4 years ago

same error

'package:google_place/google_place.dart': Failed assertion: line 65 pos 12: 'apiKEY != null': is not true.

bazrafkan commented 4 years ago

This error means you pass null to Google Place() for key, towmarrow I'll check again

bazrafkan commented 4 years ago

can I see your pubspec.yaml file in example directory?

bazrafkan commented 4 years ago

Thanks for your issue, I find the problem, if you get a new version and done 3 steps, should be working.

  1. Create .env file in example directory
  2. Add your Google Place API key in this file (ex: API_KEY=XXXXXXXXXXX)
  3. Get packages from the command line: flutter pub get