I need deserialize JSON using code generation libraries from tutorial https://flutter.io/json/#code-generation When I do step "Running the code generation utility", (run in terminal 'flutter packages pub run build_runner build'), I have error:

C:\Users\Matusevich\StudioProjects\hr_metrics>flutter packages pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 486ms

[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 469ms

[INFO] Checking for unexpected pre-existing outputs....
[INFO] Checking for unexpected pre-existing outputs. completed, took 2ms

You have hit a bug in build_runner
Please file an issue with reproduction steps at https://github.com/dart-lang/build/issues

NoSuchMethodError: Attempted to use type 'FolderBasedDartSdk' as a function. Since types do not define a method 'call', this is not possible. Did you intend to call the FolderBasedDa
rtSdk constructor and forget the 'new' operator?
Receiver: FolderBasedDartSdk
Tried calling: FolderBasedDartSdk(Instance of 'PhysicalResourceProvider', Instance of '_PhysicalFolder')
dart:core                                                 Object.noSuchMethod
package:build_resolvers/src/resolver.dart 430:33          new AnalyzerResolvers
package:build_runner/src/generate/build_impl.dart 124:26  new BuildImpl._
package:build_runner/src/generate/build_impl.dart 154:21  BuildImpl.create
package:build_runner/src/generate/build_impl.dart 108:33  singleBuild
package:build_runner/src/generate/build_impl.dart 97:22   build
package:build_runner/src/generate/build.dart 69:5         build
package:build_runner/src/entrypoint/options.dart 329:24   _BuildCommand.run
package:args/command_runner.dart 194:27                   CommandRunner.runCommand
package:args/command_runner.dart 109:29                   CommandRunner.run.<fn>
dart:async                                                new Future.sync
package:args/command_runner.dart 109:11                   CommandRunner.run
package:build_runner/src/entrypoint/run.dart 22:31        run
.dart_tool\build\entrypoint\build.dart 11:22              main

pub finished with exit code 1

What to do to correct the error?

C:\Users\Matusevich\StudioProjects\hr_metrics>flutter --version
Flutter 0.5.7 • channel dev • https://github.com/flutter/flutter.git
Framework • revision 66091f9696 (5 weeks ago) • 2018-07-09 12:52:41 -0700
Engine • revision 6fe748490d
Tools • Dart 2.0.0-dev.63.0.flutter-4c9689c1d2

Solution 1: Nate Bosch

This is happening because flutter is using an older SDK where the VM doesn't support optional new and the build runner packages were published without correct SDK constraints.

This bug is reported at https://github.com/dart-lang/build/issues/1746