londonappbrewery / bmi-calculator-flutter

Learn to Code While Building Apps - The Complete Flutter Development Bootcamp
https://www.appbrewery.co
192 stars 837 forks source link

error: 2 positional argument(s) expected, but 1 found. #7

Open arpit999 opened 4 years ago

arpit999 commented 4 years ago

When I pass the argument it says both are compulsory. Maybe they changed it in flutter SDK I could not find the solution for that.

Help me thanks.

My Custom Widget Class

class ReusableCard extends StatelessWidget {
  ReusableCard(@required this.colour, this.cardChild);

  final Widget cardChild;
  final Color colour;

  @override
  Widget build(BuildContext context) {
    return Container(
      child: cardChild,
      margin: EdgeInsets.all(15.0),
      decoration: BoxDecoration(
        color: colour,
        borderRadius: BorderRadius.circular(10),
      ),
    );
  }
}

Here is the implement of the widget

Expanded(
              child: Row(
                children: <Widget>[
                  Expanded(
                    child: ReusableCard(activeCardColor),
                  ),
                ],
              ),
            ),
keyvnchristian commented 4 years ago

@arpit999 better make it this way

ReusableCard({@required this.colour, this.cardChild});

then you can implement it this way

ReusableCard(colour: activeCardColor)