0

I'm following through Google's code labs for Flutter Googlemaps,

https://codelabs.developers.google.com/codelabs/google-maps-in-flutter/#5

G Labs says

Once you've added this code, your IDE (if you are using one) should display some red squiggles, as it references a nonexistent sibling file, locations.g.dart. This generated file converts between untyped JSON structures and named objects. Create it by running the build_runner:

Build runner is supposed to output this:

$ flutter packages pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 291ms

[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 65ms

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 595ms

[INFO] Running build...
[INFO] 1.2s elapsed, 0/1 actions completed.
[INFO] Running build completed, took 1.2s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 27ms

[INFO] Succeeded after 1.2s with 1 outputs (1 actions)

$
  • I've added the 'build_runner: ^1.2.7' dev_dependency to my .yaml file, done some googling around, tried various commands in Android Studio Terminal, none of which were recognised.
  • I tried changing the Terminal directory from my app directory to the C:/flutter directory, but the commands still weren't recognised.

I've no clue how to do this. In their print out of their console the cursor carat is a $, which doesn't appear for Android Studio console on windows 10, so.... confusion.

Here's the .yaml file as requested

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  google_maps_flutter: ^0.5.11
  http: ^0.12.0+1
  json_serializable: ^2.0.2


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.3

dev_dependencies:
  pedantic: ^1.4.0
  build_runner: ^1.2.7
  flutter_test:
    sdk: flutter
Sam
  • 1,659
  • 4
  • 23
  • 42
  • 1
    What your pubspec.yaml looks like? – i6x86 Mar 29 '20 at 14:44
  • @i6x86 updated. According to the lab's tutorial though "your IDE (if you are using one) should display some red squiggles, as it references a nonexistent sibling file, locations.g.dart. This generated file converts between untyped JSON structures and named objects. Create it by running the build_runner:" How do I run build_runner from Windows 10 or Android Studio? – Sam Mar 29 '20 at 17:12
  • 1
    I'm on Mac but I suppose it's the same for Windows, you can run this command in the terminal of AS: flutter pub run build_runner build – i6x86 Mar 29 '20 at 17:37
  • Yes I've tried to do that from both the app directory & the flutter directory, it says "'flutter' is not recognized as an internal or external command, operable program or batch file. ". If I go into C:\flutter\bin and try it it says 'C:\flutter\bin>flutter pub run build_runner build Error: No pubspec.yaml file found. This command should be run from the root of your Flutter project. Do not run this command from the root of your git clone of Flutter.' – Sam Mar 29 '20 at 19:21
  • 1
    it's possible you don't have fluter added to your Path – i6x86 Mar 29 '20 at 19:28
  • Worked! Followed the instructions here: https://flutter.dev/docs/get-started/install/windows#update-your-path And rebooted Android Studio and VOILA, you are gold @i6x86 thankyou for your continued attention X Sam. – Sam Mar 29 '20 at 21:46

1 Answers1

0

@i6x86 correctly diagnosed the problem, I hadn't set Flutter up fully. I followed the instructions here: flutter.dev/docs/get-started/install/windows#update-your-path

Rebooted Android Studio and voila, it solved the problem.

halfer
  • 19,824
  • 17
  • 99
  • 186
Sam
  • 1,659
  • 4
  • 23
  • 42