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.;
:16:3: Context: Found this candidate, but the arguments don’t match.
LandingPage({required this.vinNumber});

**Getting Started class:**

                    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: ,
                    textColor: Colors.white,
                    onPressed: () {
**Landing Page class**
class LandingPage extends StatefulWidget {
   String? vinNumber;

  LandingPage({required this.vinNumber});

  _LandingPageState createState() => _LandingPageState(vinNumber!);

class _LandingPageState extends State<LandingPage> {
   String? vinNumber;

**VIN Class**


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

Answered By – Giuseppe Colucci

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published