'The default constructor is already defined
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();
}
Solution 1:[1]
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();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
