swagger-api / swagger-api/swagger-codegen

[dart] Generated code does not compile in flutter. Ends with simple_type_transformer exception

Open
#8,423 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Generated code for dart does not run in flutter. Getting this error message which I don't know what i means. Using dart-2 preview.

compiler message: file:///home/xx/Software/flutter/.pub-cache/hosted/pub.dartlang.org/dartson-0.2.7/lib/src/simple_type_transformer.dart:8:20: Error: The parameter 'value' of the method '_SimpleTypeTransformer::encode' has type dartson::_SimpleTypeTransformer::T, which does not match the corresponding type in the overridden method (dynamic).
compiler message: Change to a supertype of dynamic (or, for a covariant parameter, a subtype).
compiler message:   dynamic encode(T value) => value;
compiler message:                    ^
compiler message: file:///home/xx/Software/flutter/.pub-cache/hosted/pub.dartlang.org/dartson-0.2.7/lib/type_transformer.dart:9:11: Context: This is the overriden method ('encode').
compiler message:   dynamic encode(T value);
compiler message:           ^
Compiler failed on /home/xx/workspace/smb-flutter/lib/main.dart

FAILURE: Build failed with an exception.
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.5.1, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] Android Studio (version 3.1)
[!] VS Code (version 1.25.0)
[✓] Connected devices (1 available)

! Doctor found issues in 1 category.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Flutter build failure using the provided environment details, then inspect dartson's lib/src/simple_type_transformer.dart and lib/type_transformer.dart at the reported method signatures. Compare the overridden encode declarations and determine what must change for the generated Dart code to compile successfully in Flutter.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.