Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Navigator.pushReplacementNamed parameters

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(),
      routes: <String, WidgetBuilder> {
        '/form': (BuildContext context) => new FormPage(), //new
      },
    );
  }
}

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      floatingActionButton: new FloatingActionButton(
        onPressed: () {
          Navigator.of(context).pushReplacement(                                                         //new
            new MaterialPageRoute(                                                                       //new
              settings: const RouteSettings(name: '/form'),                                              //new
              builder: (context) => new FormPage(email: 'myemail@flutter.com', header: {'auth': '1234'}) //new
            )                                                                                            //new
          );                                                                                             //new
        },
        child: new Icon(Icons.navigate_next),
      ),
    );
  }
}

class FormPage extends StatefulWidget {
  FormPage({Key key, this.email, this.header}) : super(key: key);
  String email;
  Map header;
  @override
  FormPageState createState() => new FormPageState();
}

class FormPageState extends State<FormPage> {
  @override
  Widget build(BuildContext context) {
    return new Container(
      child: new Column(
        children: <Widget>[
          new Text(widget.email),
          new Text(widget.header['auth'])
        ],
      ),
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: flutter build runner json serializable 
Javascript :: javascript getting input from console 
Javascript :: javascript next month from date 
Javascript :: @tippyjs/react 
Javascript :: ruby write json to file 
Javascript :: node print variable 
Javascript :: electron hide devtools 
Javascript :: firebase timestamp to date angular 
Javascript :: node promisify without err 
Javascript :: input type number maxlength in react 
Javascript :: jquery make visible 
Javascript :: js script 
Javascript :: javascript get phone number from string 
Javascript :: javascript check if object 
Javascript :: add new items in a select input using js 
Javascript :: jquery mobile or desktop 
Javascript :: how to copy value instead of reference js 
Javascript :: javascript object to query string 
Javascript :: before page load javascript 
Javascript :: regex for comments javascript 
Javascript :: dynamodb pagination nodejs 
Javascript :: change class Name in react 
Javascript :: duplicate numbers in an array javascript 
Javascript :: render markdown in nextjs 
Javascript :: javascript button add input to list item 
Javascript :: javascript join array 
Javascript :: stop page refresh on button click react 
Javascript :: CREATE A BUTTON THAT INCREMENTS A COUNTER WHEN CLICKED 
Javascript :: jquery 1 cdn 
Javascript :: add array to array javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =