Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The argument type 'Function' can't be assigned to the parameter type 'void Function()?'1

import 'package:flutter/material.dart';

class Answer extend`enter code here`s StatelessWidget {
  // const ({Key? key}) : super(key: key);
  final Function sel`enter code here`ectHandler ;

  Answer(this.selectHandler);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      child: RaisedButton(
          color: Colors.pink,
          child: Text('Pink'),
         // textColor: Colors.pink,
          onPressed:selectHandler,
      ),
    );
  }
}

hey guys please help me to solve this i am having issue in this code @ onPressed:selectHandler

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Use voidcallback

import 'package:flutter/material.dart';

class Answer extends StatelessWidget {
   const ({Key? key, this.selectHandler}) : super(key: key);
  final VoidCallback selectHandler ;

  Answer(this.selectHandler);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      child: RaisedButton(
          color: Colors.pink,
          child: Text('Pink'),
         // textColor: Colors.pink,
          onPressed:selectHandler,
      ),
    );
  }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading