Flutter

Flutter Activity Navigate another Activity

This Flutter tutorial will teach you how Flutter Activity Navigate one Activity to  another Activity step by step.this tutorial will teach the the basic steps.

Main.dart

import 'package:flutter/material.dart';
import 'package:my_course/splash_screen/splash_screen.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        
        primarySwatch: Colors.blue,
      ),
      home: SplashScreen(),
    );
  }
}

constants.dart

class Constants
{
static const IMAGE_PATH = 'assets/images/';
}

Splash_screen.dart

import 'package:flutter/material.dart';
import 'package:my_course/home_screen/home_screen.dart';
import 'package:my_course/utils/constants.dart';
import '';

class SplashScreen extends StatefulWidget {
  const SplashScreen({ Key key }) : super(key: key);

  @override
  State<SplashScreen> createState() => _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {
@override
  void initState() {
    navigateToHome();
    super.initState();
  }
  void navigateToHome()
  {
    Future.delayed(Duration(seconds: 5),
    (){
      Navigator.push(context, MaterialPageRoute(builder: (context) => HomeScreen()));

    });
  }

  @override
  Widget build(BuildContext context) {
    var size = MediaQuery.of(context).size;
    return Scaffold(
      body: Center(
        child: Column(
          children: [
            Container(
              child: Image.asset('${Constants.IMAGE_PATH}p2.jpg',
              width: size.width / 1.8,
              height: size.height / 7,
              fit: BoxFit.fill,
              ),
              
              ),
              Text("Mobile Shop",
              style: TextStyle(
                  fontSize: 30,
                  fontWeight: FontWeight.bold

               ),
              )
          ],
        ),
      ), 
    );
  }
}

home_screen.dart

import 'package:flutter/material.dart';

class HomeScreen extends StatefulWidget {
  const HomeScreen({ Key key }) : super(key: key);

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body:SafeArea(
        child: Center(child: Text("home Screen")),
      )
      
    );
  }
}

I have attached the video tutorial below it will help you  to do this  step by step.

 

admin

Recent Posts

Building JSP AJAX CRUD Application

Introduction to JSP AJAX CRUD Applications Building web applications has become more dynamic with the…

1 hour ago

Hotel Management System using Laravel 11

Relationships: Hotel ↔ Rooms (One-to-Many) A hotel can have many rooms, but a room belongs…

3 weeks ago

Creating Grocery Inventory App Using React

Introduction to Grocery Inventory Apps Managing grocery inventory can be a daunting task, but with…

4 weeks ago

Fish Inventory Shop Management System in Angular

This article explain how to make a Fish Inventory Management App in Angular.this app explain…

1 month ago

Fish Inventory Management with React

Introduction to Fish Inventory Management In the aquaculture industry, managing fish inventory is crucial for…

1 month ago

Java GUI CRUD for Beginners

Introduction to Java GUI CRUD Java is a powerful programming language widely used for building…

1 month ago