当传递参数时,在dispose之前调用Build函数。使用命名路由。
这是代码的输出
I/flutter (12390): called init statment
I/flutter (12390): build context is run
I/flutter (12390): called button function to pop
I/flutter (12390): build context is run
I/flutter (12390): dispose is called
Dart代码:
class ShowProducts extends StatefulWidget {
当我构建一个flutter应用程序时,有三个屏幕,屏幕A,屏幕B,屏幕C。当点击按钮时,它会重定向到下一个屏幕。所以它是将A重定向到B,而不是将B重定向到C。我不知道原因。它显示错误。它显示的错误是
Could not find a generator for route RouteSettings("/extractArguments1", Instance of 'ScreenArguments') in the _WidgetsAppState.
我的代码如下所示
import 'package:flutter/material.dart&
地图??.settings.arguments= ModalRoute.of(context)?.settings.arguments as Map;因为它将接收空值,但是使用它会得到一个错误。我是flutter的初学者。请任何人帮助我解决这个问题。 ***** From home page******
GestureDetector(
onTap: () {
Navigator.pushNamed(context, "/loading",arguments:
我试着在我的网页应用程序中进行动态路由。但我不知道如何在动态路由中使用参数。
class Path {
const Path(this.pattern, this.builder);
/// A RegEx string for route matching.
final String pattern;
/// The builder for the associated pattern route. The first argument is the
/// [BuildContext] and the second argument is a RegEx m
在使用PageRouteBuilder()转换为自定义页面动画后,我将获得一个黑色屏幕。不使用自定义动画,它的工作非常完美。但是当我添加自定义动画时,Navigator.push()仍然工作,但是当屏幕弹出时,它返回一个黑色屏幕。
以下是代码:
// This is the button to change the route.
// I'm using the condition statements to change the behaviour
// depending on the route from which it is clicked.
NavigationBarBu
我正在尝试添加到我的颤音应用程序中,在仪表板上显示不同的屏幕名称。我使用了在此链接中的堆栈溢出中找到的方法:
我在一个单独的文件中添加了这个代码:
import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:flutter/widgets.dart';
// A Navigator observer that notifies RouteAwares of changes to state of their Route
final routeObserver = Ro
我想在initState方法中从数据库中获取一个值。因此,我尝试通过使用Provider.of(context)方法调用函数来访问值。但是,我得到了以下错误:
E/flutter ( 6424): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Error: Could not find the correct Provider<RestaurantTimings> above this MyApp Widget
E/flutter ( 6424):
E/flutter ( 6424): This