defaultUnknownRoutePage function Null safety

PageRoute defaultUnknownRoutePage(
  1. RouteSettings settings
)

Implementation

PageRoute defaultUnknownRoutePage(RouteSettings settings) => MaterialPageRoute(
      builder: (ctx) => Scaffold(
        body: Container(
          color: Colors.redAccent,
          width: double.infinity,
          padding: const EdgeInsets.symmetric(horizontal: 16.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Padding(
                padding:
                    const EdgeInsets.symmetric(horizontal: 32, vertical: 8),
                child: Text(
                  'Route name ${settings.name} is not found!',
                  textAlign: TextAlign.center,
                  style: TextStyle(fontSize: 16),
                ),
              ),
              if (!ModalRoute.of(ctx)!.isFirst)
                OutlinedButton.icon(
                  label: Text('Back'),
                  icon: Icon(Icons.arrow_back),
                  onPressed: () => Navigator.of(ctx).pop(),
                )
            ],
          ),
        ),
      ),
    );