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

type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast #12

Open
Kahoulam opened this issue Nov 27, 2023 · 0 comments
Open

Comments

@Kahoulam
Copy link

Steps to reproduce

  1. Create a new project
  2. Add tokens.json file
  3. Execute the command dart run build_runner build

Expected results

Correctly generate tokens.dart file

Actual results

An error occurred:

type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast

Version

design_tokens_builder: ^0.2.0+1

Code sample

tokens.json
{
  "global": {
    "M3": {
      "sys": {
        "light": {
          "primary": {
            "value": "#626200",
            "type": "color"
          },
          "on-primary": {
            "value": "#ffffff",
            "type": "color"
          },
          "primary-container": {
            "value": "#eaea00",
            "type": "color"
          },
          "on-primary-container": {
            "value": "#1d1d00",
            "type": "color"
          },
          "primary-fixed": {
            "value": "#eaea00",
            "type": "color"
          },
          "on-primary-fixed": {
            "value": "#1d1d00",
            "type": "color"
          },
          "primary-fixed-dim": {
            "value": "#cdcd00",
            "type": "color"
          },
          "on-primary-fixed-variant": {
            "value": "#494900",
            "type": "color"
          },
          "secondary": {
            "value": "#606043",
            "type": "color"
          },
          "on-secondary": {
            "value": "#ffffff",
            "type": "color"
          },
          "secondary-container": {
            "value": "#e7e4bf",
            "type": "color"
          },
          "on-secondary-container": {
            "value": "#1d1d06",
            "type": "color"
          },
          "secondary-fixed": {
            "value": "#e7e4bf",
            "type": "color"
          },
          "on-secondary-fixed": {
            "value": "#1d1d06",
            "type": "color"
          },
          "secondary-fixed-dim": {
            "value": "#cac8a5",
            "type": "color"
          },
          "on-secondary-fixed-variant": {
            "value": "#49482d",
            "type": "color"
          },
          "tertiary": {
            "value": "#3d6657",
            "type": "color"
          },
          "on-tertiary": {
            "value": "#ffffff",
            "type": "color"
          },
          "tertiary-container": {
            "value": "#bfecd8",
            "type": "color"
          },
          "on-tertiary-container": {
            "value": "#002117",
            "type": "color"
          },
          "tertiary-fixed": {
            "value": "#bfecd8",
            "type": "color"
          },
          "on-tertiary-fixed": {
            "value": "#002117",
            "type": "color"
          },
          "tertiary-fixed-dim": {
            "value": "#a4d0bd",
            "type": "color"
          },
          "on-tertiary-fixed-variant": {
            "value": "#254e40",
            "type": "color"
          },
          "error": {
            "value": "#ba1a1a",
            "type": "color"
          },
          "on-error": {
            "value": "#ffffff",
            "type": "color"
          },
          "error-container": {
            "value": "#ffdad6",
            "type": "color"
          },
          "on-error-container": {
            "value": "#410002",
            "type": "color"
          },
          "outline": {
            "value": "#797869",
            "type": "color"
          },
          "background": {
            "value": "#fffbff",
            "type": "color"
          },
          "on-background": {
            "value": "#1c1c17",
            "type": "color"
          },
          "surface": {
            "value": "#fdf9f0",
            "type": "color"
          },
          "on-surface": {
            "value": "#1c1c17",
            "type": "color"
          },
          "surface-variant": {
            "value": "#e6e3d1",
            "type": "color"
          },
          "on-surface-variant": {
            "value": "#48473a",
            "type": "color"
          },
          "inverse-surface": {
            "value": "#31312b",
            "type": "color"
          },
          "inverse-on-surface": {
            "value": "#f4f0e8",
            "type": "color"
          },
          "inverse-primary": {
            "value": "#cdcd00",
            "type": "color"
          },
          "shadow": {
            "value": "#000000",
            "type": "color"
          },
          "surface-tint": {
            "value": "#626200",
            "type": "color"
          },
          "outline-variant": {
            "value": "#cac7b6",
            "type": "color"
          },
          "scrim": {
            "value": "#000000",
            "type": "color"
          },
          "surface-container-highest": {
            "value": "#e6e2d9",
            "type": "color"
          },
          "surface-container-high": {
            "value": "#ebe8df",
            "type": "color"
          },
          "surface-container": {
            "value": "#f1eee5",
            "type": "color"
          },
          "surface-container-low": {
            "value": "#f7f3ea",
            "type": "color"
          },
          "surface-container-lowest": {
            "value": "#ffffff",
            "type": "color"
          },
          "surface-bright": {
            "value": "#fdf9f0",
            "type": "color"
          },
          "surface-dim": {
            "value": "#dddad1",
            "type": "color"
          }
        }
      }
    }
  },
  "$themes": [],
  "$metadata": {
    "tokenSetOrder": [
      "global"
    ]
  }
}

Logs

Console logs
[INFO] Generating build script completed, took 235ms
[INFO] Reading cached asset graph completed, took 64ms
[INFO] Checking for updates since last build completed, took 843ms
[WARNING] design_tokens_builder|lib/design_tokens_builder.dart was not found in the asset graph, incremental builds will not work.
 This probably means you don't have your dependencies specified fully in your pubspec.yaml.
[WARNING] Invalidating asset graph due to build script update!
[INFO] Cleaning up outputs from previous builds. completed, took 1ms
[INFO] Generating build script completed, took 40ms
[WARNING] Invalidated precompiled build script due to missing asset graph.
[INFO] Precompiling build script... completed, took 596ms
[WARNING] design_tokens_builder|lib/design_tokens_builder.dart was not found in the asset graph, incremental builds will not work.
 This probably means you don't have your dependencies specified fully in your pubspec.yaml.
[INFO] Building new asset graph completed, took 900ms
[INFO] Checking for unexpected pre-existing outputs. completed, took 0ms
[SEVERE] design_tokens_builder on lib/$lib$:

type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast
[INFO] Running build completed, took 100ms
[INFO] Caching finalized dependency graph completed, took 39ms
[SEVERE] Failed after 145ms

Flutter Doctor output

Doctor output
  [✓] Flutter (Channel stable, 3.13.9, on macOS 14.0 23A344 darwin-arm64, locale en-TW)
  [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
  [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
  [✓] Chrome - develop for the web
  [✓] Android Studio (version 2022.3)
  [✓] VS Code (version 1.84.0)
  [✓] Connected device (1 available)
  [✓] Network resources
Kahoulam added a commit to howflutter/design_tokens_builder that referenced this issue Nov 27, 2023
Change defaultSys type to be nullable

Closes: simpleclub#12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant