Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
arpit999 opened this issue May 20, 2020 · 1 comment
Open

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

arpit999 opened this issue May 20, 2020 · 1 comment

Comments

@arpit999
Copy link

arpit999 commented May 20, 2020

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
Copy link

@arpit999
better make it this way

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

then you can implement it this way

ReusableCard(colour: activeCardColor)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants