Splash Screen

 import "package:flutter/material.dart";

import "package:practice/IntroPage.dart";
import "package:practice/splash_screen.dart";

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

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Hello",
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.deepPurple,
),
home: const SplashScreen(),
);
}
}

class FlutterApp extends StatelessWidget {
var nameFromHome;

FlutterApp(this.nameFromHome, {super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
const UserAccountsDrawerHeader(
accountName: Text("John"),
accountEmail: Text("John4215@google.com"),
currentAccountPicture: Icon(
Icons.account_circle,
size: 85,
),
),
ListTile(
leading: const Icon(
Icons.message,
color: Colors.black,
),
title: const Text("message"),
onTap: () {
Navigator.pop(context);
},
),
const Divider(
thickness: 1,
color: Colors.black,
),
ListTile(
leading: const Icon(
Icons.account_circle,
color: Colors.black,
),
title: const Text("profile"),
onTap: () {
Navigator.pop(context);
},
),
const Divider(thickness: 1, color: Colors.black),
ListTile(
leading: const Icon(
Icons.settings,
color: Colors.black,
),
title: const Text("Settings"),
onTap: () {
Navigator.pop(context);
},
),
const Divider(
thickness: 1,
color: Colors.black,
),
ListTile(
leading: const Icon(Icons.help_outline, color: Colors.black),
title: const Text("Help & feedback"),
onTap: () {
Navigator.pop(context);
},
),
const Divider(
thickness: 1,
color: Colors.black,
),
ListTile(
leading: const Icon(
Icons.restore_from_trash,
color: Colors.black,
),
title: const Text("Trash"),
onTap: () {
Navigator.pop(context);
},
),
],
),
),
//endDrawer: const Drawer(),
appBar: AppBar(
title: const Text(
"Switching One to another Screen",
style: TextStyle(fontWeight: FontWeight.bold),
),
centerTitle: true,
backgroundColor: Colors.grey,
),
body: Container(
color: Colors.amber.shade300,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
"Page No : 2",
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 40.0),
const Text(
"Hello World",
style: TextStyle(
fontSize: 34,
),
),
const SizedBox(height: 40.0),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Welcome, $nameFromHome",
style: const TextStyle(
fontSize: 34,
color: Colors.teal,
),
),
const SizedBox(height: 40.0),
ElevatedButton(
onPressed: () {
Navigator.pop(
/*Top of the stack will pop*/
context,
MaterialPageRoute(
builder: (context) {
return IntroPage();
},
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey,
fixedSize: const Size(350.0, 50.0),
),
child: const Text(
"Back",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
color: Colors.white),
),
), /*The MaterialPageRoute object is a subclass of Route
that specifies the transition animations for Material Design*/
],
),
],
),
),
),
//Text("Hello World"),
);
}
}
import "dart:async";
import "package:flutter/material.dart";
import "package:practice/IntroPage.dart";

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

@override
State<SplashScreen> createState() {
return SplashScreenState();
}
}

class SplashScreenState extends State<SplashScreen> {
@override
void initState() {
super.initState();

Timer(
const Duration(seconds: 2),
() {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) {
return IntroPage();
},
),
);
},
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
color: Colors.blue,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
"Flutter Application",
style: TextStyle(
fontSize: 34,
fontWeight: FontWeight.w700,
color: Colors.white,
),
),
Image.asset("assets/images/flutter.png"),
],
),
),
),
);
}
}

import "package:flutter/material.dart";
import "package:practice/switching_screen.dart";

class IntroPage extends StatelessWidget {
var nameController = TextEditingController();

IntroPage({super.key});

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
FocusManager.instance.primaryFocus?.unfocus();
},
child: Scaffold(
endDrawer: const Drawer(),
appBar: AppBar(
title: const Text(
"Intro -> Page 1",
style: TextStyle(fontWeight: FontWeight.bold),
),
centerTitle: true,
backgroundColor: Colors.grey,
),
body: Center(
child: SizedBox(
width: 300.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
"Page No : 1",
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 40.0),
const Text(
"Welcome",
style: TextStyle(
fontSize: 34,
fontWeight: FontWeight.bold,
),
),
const SizedBox(
height: 11,
),
TextField(
controller: nameController,
),
const SizedBox(height: 50.0),
ElevatedButton(
onPressed: () {
Navigator.push(
/*New page will push in stack following LIFO(Last In First Out)*/
context,
MaterialPageRoute(
builder: (context) {
return FlutterApp(nameController.text.toString());
},
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
fixedSize: const Size(350.0, 50.0),
),
child: const Text(
"Next",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
color: Colors.white),
),
),
],
),
),
),
),
);
}
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter