0

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

jaimish11
  • 536
  • 4
  • 15

1 Answers1

1

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,));
  }
}
Deepak Ror
  • 2,084
  • 2
  • 20
  • 26
  • This worked! The issue arose because the Card class already exists within Dart and I was trying to use that as a custom class right? – jaimish11 Jul 13 '20 at 06:34