Flutter 颤振路线问题找不到用于路线设置的生成器

Flutter 颤振路线问题找不到用于路线设置的生成器,flutter,routes,Flutter,Routes,有大问题我和它斗争了2个小时,但仍然没有创建一个解决方案,所以我来这里寻求帮助,昨天当我打开我的应用程序,一切都很顺利,今天我改变了一点我的代码,但我甚至尝试删除这个检查是不是有问题,当我删除这个它仍然是坏的。这是我在终点站的问题 处理手势时引发了以下断言: 在中找不到路由路由设置(“/Category fends”,{id:c1,title:意大利语})的生成器 这个国家。 确保您的根应用程序小部件提供了生成 这条路。 将按以下顺序搜索路线的生成器: 对于“/”路由,如果不为null,则使用“

有大问题我和它斗争了2个小时,但仍然没有创建一个解决方案,所以我来这里寻求帮助,昨天当我打开我的应用程序,一切都很顺利,今天我改变了一点我的代码,但我甚至尝试删除这个检查是不是有问题,当我删除这个它仍然是坏的。这是我在终点站的问题

处理手势时引发了以下断言: 在中找不到路由路由设置(“/Category fends”,{id:c1,title:意大利语})的生成器 这个国家。 确保您的根应用程序小部件提供了生成 这条路。 将按以下顺序搜索路线的生成器:

对于“/”路由,如果不为null,则使用“home”属性。 否则,如果“routes”表中有路由条目,则使用该表。 否则,将调用onGenerateRoute。它应该为任何无效路由返回非空值 由“总部”和“路线”处理。 最后,如果所有其他操作都失败,则调用unknownRoute。 不幸的是,没有设置onUnknownRoute。 这是我的文件,使用route命令

主飞镖

`import 'package:flutter/material.dart';

import './category_meals.dart';
import 'categories_screen.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'DeliMeals',
      theme: ThemeData(
          primarySwatch: Colors.pink,
          accentColor: Colors.amber,
          canvasColor: Color.fromRGBO(255, 254, 229, 1),
          textTheme: ThemeData.light().textTheme.copyWith(
                bodyText1: TextStyle(
                  color: Color.fromRGBO(20, 51, 51, 1),
                ),
                bodyText2: TextStyle(
                  color: Color.fromRGBO(20, 51, 51, 1),
                ),
                headline6: TextStyle(
                  fontSize: 24,
                ),
              )),
      home: CategoriesScreen(),
      routes: {
        CategoryMeals.routeName: (ctx) => CategoryMeals(),
      },
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('DeliMeals'),
      ),
      body: Center(
        child: Text('Navigation Time!'),
      ),
    );
  }
}
`
如果有人知道解决方案,我将非常感谢你的帮助,并解释出问题所在,谢谢

`import 'package:flutter/material.dart';
import './dummy_data.dart';

class CategoryMeals extends StatelessWidget {
  static const routeName = 'Category-meals';
  /* final String categoryId;
  final String categoryTitle;
  
  CategoryMeals(this.categoryId, this.categoryTitle); */
  
  @override
  Widget build(BuildContext context) {
    final routesArgs = ModalRoute.of(context).settings.arguments as Map<String, String>;
    final categoryTitle = routesArgs['title'];
    final categoryId = routesArgs['id'];
    final categoryMeals = DUMMY_MEALS.where((meal) {
      return meal.categories.contains(categoryId);
    }).toList();
    return Scaffold(
      appBar: AppBar(
        title: Text(categoryTitle),
      ),
      body: ListView.builder(itemBuilder: (ctx, index) {
        return Text(categoryMeals[index].title);
      }, itemCount: categoryMeals.length,), 
    );
  }
}
`
`import 'package:flutter/material.dart';
import './category_meals.dart';

class CategoryItem extends StatelessWidget {
  final String id;
  final String title;
  final Color color;

  CategoryItem(this.id, this.title, this.color);

  void selectCategory(BuildContext ctx) {
    Navigator.of(ctx).pushNamed('/Category-meals', arguments: {
      'id': id,
      'title': title
    });
  }

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () => selectCategory(context),
      splashColor: Theme.of(context).primaryColor,
      borderRadius: BorderRadius.circular(15),
      child: Container(
        padding: const EdgeInsets.all(15),
        child: Text(
          title,
          style: Theme.of(context).textTheme.headline6,
        ),
        decoration: BoxDecoration(
          gradient: LinearGradient(
            colors: [
              color.withOpacity(0.7),
              color,
            ],
            begin: Alignment.topLeft,
            end: Alignment.bottomRight,
          ),
          borderRadius: BorderRadius.circular(15),
        ),
      ),
    );
  }
}