Reputation: 1
When trying to declare CardView
class in my Flutter application, I get the error The default constructor is already defined
.
import 'package:flutter/material.dart';
import 'package:untitled5/model/card_model.dart';
class CardView extends StatefulWidget {
const CardView({Key? key, required this.card}) : super(key: key);
final CardModel card;
CardView(this.card) : super();
@override
_CardViewState createState() => _CardViewState();
}
Upvotes: 0
Views: 476
Reputation: 6357
The class CardView
is defined with two constructors which is not allowed in dart.
Remove the second constructor, as shown the line below, from the code shown above.
CardView(this.card) : super();
Upvotes: 1