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

CardThemeData exception #221

Open
Ian-Munashe opened this issue Jan 3, 2025 · 2 comments
Open

CardThemeData exception #221

Ian-Munashe opened this issue Jan 3, 2025 · 2 comments

Comments

@Ian-Munashe
Copy link

I am encountering a build error within a Flutter project using version 3.27.1 (stable channel). Velocity_x: 4.2.1 is causing a build-time failure, preventing successful compilation and execution of the application. The specific error message is as follows:

/C:/Users/***/AppData/Local/Pub/Cache/hosted/pub.dev/velocity_x-4.2.1/lib/src/flutter/universal.dart:805:43: Error: A value of type 'CardThemeData' can't be assigned to a variable of type 'CardTheme'.

  • 'CardThemeData' is from 'package:flutter/src/material/card_theme.dart' ('/D:/tools/flutter/packages/flutter/lib/src/material/card_theme.dart').
  • 'CardTheme' is from 'package:flutter/src/material/card_theme.dart' ('/D:/tools/flutter/packages/flutter/lib/src/material/card_theme.dart').
    final CardTheme cardTheme = CardTheme.of(context);
    ^
    Target kernel_snapshot_program failed: Exception

FAILURE: Build failed with an exception.

@iamtvirani
Copy link

iamtvirani commented Jan 3, 2025

@Ian-Munashe we already raised and give temporary solution you can check issue #216

@frkudn
Copy link

frkudn commented Jan 10, 2025

Temporary Solution

File Location

The file can be found at:

~/.pub-cache/hosted/pub.dev/velocity_x-4.2.1/lib/src/flutter/universal.dart

How to Apply the Fix Manually

  1. Open the specified file in your text editor
  2. Locate the existing cardWidget and material methods
  3. Replace them with the following code:
Widget cardWidget(Widget current, BuildContext context) {
    final ThemeData theme = Theme.of(context);
    final CardThemeData cardTheme = CardTheme.of(context);
    
    return material(current,
        mType: MaterialType.card,
        mShadowColor: shadowColor ?? cardTheme.shadowColor ?? theme.shadowColor,
        mColor: color ?? cardTheme.color ?? theme.cardColor,
        mElevation: elevation ?? cardTheme.elevation ?? 10,
        mShape: shape ??
            cardTheme.shape ??
            RoundedRectangleBorder(
                borderRadius: borderRadius == BorderRadius.zero
                    ? BorderRadius.circular(4)
                    : borderRadius),
        mClipBehavior: clipBehavior ?? cardTheme.clipBehavior ?? Clip.none,
        mBorderOnForeground: true);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants