Flutter Tutorial - Navigation using push(), pop() and routes

Flutter Tutorial - Navigation using push(), pop() and routes

Flutter Tutorial - Navigation using push(), pop() and routes. Navigation is a very important feature of any Web/Mobile application. We can achieve navigation in our flutter app using push(), pop() methods, or by writing our own routes.

Navigation is a very important feature of any Web/Mobile application as it allows you to browse from one page to another

We can achieve navigation in our flutter app using push(), pop() methods, or by writing our own routes.

Let’s consider FirstScreen and SecondScreen as two different classes in FirstScreen.dart file and SecondScreen.dart respectively.

FirstScreen.dart file as :

import 'package:flutter/material.dart';
import 'package:navigation/SecondScreen.dart';

class FirstScreen extends StatefulWidget {
  @override
  _FirstScreenState createState() => _FirstScreenState();
}

class _FirstScreenState extends State<FirstScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("First Screen"),
        ),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              "Hello to First Screen",
              style: TextStyle(
                fontSize: 20,
              ),
            ),
            SizedBox(
              height: 10,
            ),
            Center(
              child: RaisedButton(
                onPressed: () {},
                child: Text(
                  "First Screen",
                  style: TextStyle(
                      fontSize: 20, 
                      fontWeight: FontWeight.bold
                  ),
                ),
              ),
            ),
          ],
        ));
  }
}

Ans SecondScreen.dart file as,

import 'package:flutter/material.dart';

class SecondScreen extends StatefulWidget {
  @override
  _SecondScreenState createState() => _SecondScreenState();
}

class _SecondScreenState extends State<SecondScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Second Screen"),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text(
            "Welcome on Second Screen",
            style: TextStyle(
              fontSize: 20,
            ),
          ),
          SizedBox(
            height: 10,
          ),
          Center(
            child: RaisedButton(
              onPressed: () {},
              child: Text(
                "Second Screen",
                style: TextStyle(
                    fontSize: 20, 
                    fontWeight: FontWeight.bold
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}

And my main.dart should be,

import 'package:flutter/material.dart';
import 'package:navigation/FirstScreen.dart';

void main() {
  runApp(MaterialApp(
      home: FirstScreen()));
}

dart flutter mobile-apps web-development developer

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How long does it take to develop/build an app?

This article covers A-Z about the mobile and web app development process and answers your question on how long does it take to develop/build an app.

Google's Flutter 1.20 stable announced with new features - Navoki

Google has announced new flutter 1.20 stable with many improvements, and features, enabling flutter for Desktop and Web

Top Mobile App Developers & Leading App Development Companies in UK

Profusely examined top Mobile App Development companies in UK with ratings & reviews to help find the best Mobile App Development solution providers.

Mobile App Development North Carolina

Mobile App Development North Carolina In the era of globalization, technology has forced the businesses and industries to jump into the space of competition. Technology has both tangible and intangible benefits that help businesses from different ind...

Top 7 Mobile App Development Companies in Delhi NCR

Looking for a Mobile app development company in Delhi NCR? Here it a list of top mobile app development companies in Delhi for Android & iOS app Development.