Error stating: 1 positional argument(s) expected, but 0 found. Try adding the missing arguments

I am trying to navigate from welcomepage to screen tab but unable to do so because of the above error.

Part of welcome screen.dart

class WelcomePage extends StatelessWidget {
  static const routeName = '/welcome-screen';
  const WelcomePage({Key key}) : super(key: key);

  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: Stack(
          children: [
              child: Opacity(
                opacity: 0.3,
                child: Image.asset('assets/images/of_main_bg.png', fit: BoxFit.cover),
                    label: "Get Started!",
                    labelColor: AppColors.MAIN_COLOR,
                    color: Colors.transparent,
                    highlight: AppColors.MAIN_COLOR.withOpacity(0.5),
                    borderColor: AppColors.MAIN_COLOR,
                    borderWidth: 4,
                    onPressed: ()  {Navigator.push(
              builder: (context) {
                return TabsScreen(**ERROR**#What should I write here);


Routes in main.dart

initialRoute: '/', // default is '/'
  routes: {
    '/': (ctx) => WelcomePage(),
    CategoryMealsScreen.routeName: (ctx) => CategoryMealsScreen(_availableMeals),
    MealDetailScreen.routeName: (ctx) => MealDetailScreen(_toggleFavorite, _isMealFavorite),
    FiltersScreen.routeName: (ctx) => FiltersScreen(_filters, _setFilters),
    TabsScreen.routeName: (ctx) => TabsScreen(_favoriteMeals),
    WelcomePage.routeName: (ctx) => WelcomePage(),

class code in tabscreen.dart

 class TabsScreen extends StatefulWidget {
  static const routeName = '/tabs-screen';
  final List<Meal> favoriteMeals;


How should i navigate from welcomepage to tabs_screen page?In order to navigate for the same what should I write in that ERROR place in welcome_screen.dart.
If there’s another method for navigation please do tell.

>Solution :

Don’t use named routes.


Note: Named routes are no longer recommended for most applications. For more information, see Limitations in the navigation overview page.

Leave a Reply