Flutter named paramter is not defined for Card widget

1k views Asked by At

I'm trying to create a reusable Card widget to use in other dart files throughout my app. I keep getting a named parameter is not defined error. What could the problem be here? Things I've already tried:

  • Reinstalling the flutter SDK.
  • Running flutter doctor throws no issues related to this.
  • Running a Dart re-analyse on VS-Code.

card.dart

Errors on line 14, 15 and 16

home.dart

import 'package:flutter/material.dart';
import 'card.dart';

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Card'),
        ),
        body: Card());
  }
}

Description of error

enter image description here

1

There are 1 answers

1
Deepak Ror On BEST ANSWER

Please change the class name differ from Card. Beacuse you already have Card class in dart pakage.

Solution:

class MyCard extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Card(color: Colors.red,));
  }
}