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 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);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        color: Colors.black,
        child: Stack(
          children: [
            Positioned.fill(
              child: Opacity(
                opacity: 0.3,
                child: Image.asset('assets/images/of_main_bg.png', fit: BoxFit.cover),
                ),
                ),
                
                  ThemeButton(
                    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(
            context,
            MaterialPageRoute(
              builder: (context) {
                return TabsScreen(**ERROR**#What should I write here);
              },
            ),



         

Routes in main.dart

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

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;

  TabsScreen(this.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.

From https://docs.flutter.dev/cookbook/navigation/named-routes

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

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