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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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
1 2 3 4 | class Constants { static const IMAGE_PATH = 'assets/images/'; } |
Splash_screen.dart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 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.