Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Animated Splash Screen with Image to Learn Repository issue no #164 #171

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/images/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:learn/landing_page.dart';
import 'package:learn/splash_screen.dart';
import 'package:learn/utils/route/routes.dart';
import 'package:learn/theme_provider.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -33,7 +34,7 @@ class MyApp extends StatelessWidget {
theme: ThemeData.light(),
darkTheme: ThemeData.dark(),
themeMode: themeProvider.themeMode,
home: const LandingPage(),
home: SplashScreen(),
onGenerateRoute: Routers.generateRoute,
);
},
Expand Down
97 changes: 97 additions & 0 deletions lib/splash_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:learn/landing_page.dart';

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

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

class _SplashScreenState extends State<SplashScreen> with SingleTickerProviderStateMixin {
late AnimationController _controller;
late Animation<double> _fadeInAnimation;
late Animation<double> _scaleAnimation;

@override
void initState() {
super.initState();

_controller = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
);

_fadeInAnimation = Tween<double>(begin: 0.3, end: 1.0).animate(
CurvedAnimation(parent: _controller, curve: Curves.easeIn),
);

_scaleAnimation = Tween<double>(begin: 0.8, end: 1.0).animate(
CurvedAnimation(parent: _controller, curve: Curves.easeOutBack),
);

_controller.forward();

Timer(const Duration(seconds: 5), () {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => const LandingPage()),
);
});
}

@override
void dispose() {
_controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AnimatedBuilder(
animation: _controller,
builder: (context, child) {
return Transform.scale(
scale: _scaleAnimation.value,
child: Opacity(
opacity: _fadeInAnimation.value,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
),
child: Center(
child: Image.asset(
"assets/images/splash.png",
height: 200,
width: 200,
),
),
),
),
);
},
),
const SizedBox(height: 10),
FadeTransition(
opacity: _fadeInAnimation,
child: const Text(
"Curiosity Starts Here!",
style: TextStyle(
fontFamily: "Comic",
fontSize: 20,
color: Colors.black,
),
),
),
],
),
);
}
}
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ flutter:
- assets/explore/
- assets/seasons/
- assets/occupations/

- assets/fruitsVeges/

# An image asset can refer to one or more resolution-specific "variants", see
Expand Down