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

Error: Required named parameter 'vinNumber' must be provided

Basically, I have got three classes, namely getting started, landing page, and vin. The user will be able to navigate from the getting started class to the landing page. I am getting some text or data value from VIN which I need to pass to the landing page and I did create a constructor in landing page class so that i can retrieve value from VIN. But i am receiving an error in the getting started class which do not need data from VIN. What parameter and value do i need to pass to the getting started route. I am receiving following error :

91:41: Error: Required named parameter ‘vinNumber’ must be provided.
Get.to(LandingPage());
:16:3: Context: Found this candidate, but the arguments don’t match.
LandingPage({required this.vinNumber});
^^^^^^^^^^^

**Getting Started class:**

FlatButton(
                    child: Text(
                      'Get a price quote for free!',
                      style: TextStyle(
                        fontSize: 12,
                        fontWeight: FontWeight.bold
                      ),
                    ),
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(10),
                    ),
                    padding: const EdgeInsets.all(10),
                    color: Colors.green ,
                    textColor: Colors.white,
                    onPressed: () {
                      **Get.to(LandingPage());**
                    },
                  ),
**Landing Page class**
class LandingPage extends StatefulWidget {
   String? vinNumber;

  LandingPage({required this.vinNumber});

    @override
  _LandingPageState createState() => _LandingPageState(vinNumber!);
}

class _LandingPageState extends State<LandingPage> {
   String? vinNumber;
 _LandingPageState(this.vinNumber);

**VIN Class**
    LandingPage(vinNumber:_getVin.text);

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

>Solution :

in Landing page you are saying that the vinNumber can be nullable, but also required
You only need to change
LandingPage({required this.vinNumber});
into
LandingPage({this.vinNumber});

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