Comments (15)
I believe #85 now closes this issue right?
from exer_log.
this a function i use for the splash screen
import 'package:flutter/material.dart';
class SplashScreen extends StatefulWidget {
Widget whatToReturn; // we are gonna get a widget to return in these case it will be the HomePage
SplashScreen({Key? key, required Widget this.whatToReturn}) : super(key: key);
@override
State<SplashScreen> createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
void initState() {
super.initState();
_navigateToTheMainPage();
}
_navigateToTheMainPage() async {
// we are making a delay for 3 seconds then navigating to the widget that got pass to the whatToReturn variable
await Future.delayed(Duration(seconds: 3), () {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (context) => widget.whatToReturn));
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
// your spalsh screen content
);
}
}
this is how i use it in my project
the ShowPage widget is what i call as the home in the MaterialApp btw
class ShowPage extends StatelessWidget {
const ShowPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return StreamBuilder<User?>(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return SplashScreen(whatToReturn: HomePage()); //return the splash screen that make a delay for 3 seconds then return the HomePage() in case of been login in
} else {
return LoginPage(); // return the login screen in case of not been login in
}
});
}
}
pls if i have a mistake or something that well help emprove this then tell me i'am still a beginner at flutter,
from exer_log.
@0RaMsY0 This is mostly similar to what I have in mind. But instead of stream builder, we will rely on providers from riverpod. I will work on this today. You can check my implementation and let me know if you have suggestions.
from exer_log.
I guess it's better to stick with native splash rather than making our own in flutter. The native splash will be displayed from start app until calling the runApp()
and you can initialize Firebase part before runApp
.
from exer_log.
from exer_log.
@suzanpradhan but we need to customize the UI. Are you suggesting we customize the native UI?
from exer_log.
There are already many packages that will do it for us. Popular one might be: https://pub.dev/packages/flutter_native_splash
from exer_log.
@suzanpradhan i think it better to hardcode it then using a third-party package
from exer_log.
Yeah, you are right and you will have more customization too like adding animations in splash screen. But, since we are having only logo and name, it's fine to let package do it instead of doing manual work.
from exer_log.
@suzanpradhan Ok i see what you mean
from exer_log.
Personally I would actually use the splashscreen in flutter. This would give us more flexibility in customising the splash screen (adding animations and such). It would also allow us to be able to put all the initialization logic (firebase, getting data from database/api, etc.) there, instead of putting all this before the runApp, which isn't really desirable imo. If we make the flutter splash look the same as the native one, the users wouldn't even notice the transition.
from exer_log.
Hmm, putting all the initializations before runApp()
could be tedious. Then, lets create the same splash screen as native one. Native splash will be displayed on app bootup then flutter one is shown during initialization.
from exer_log.
I believe #85 now closes this issue right?
Yes. I am not able to link issues to PR for some reason. Is that normal? I think only people with write-access can do that.
from exer_log.
I believe #85 now closes this issue right?
Yes. I am not able to link issues to PR for some reason. Is that normal? I think only people with write-access can do that.
Anyone can link issues by doing #
If you just want to reference it then you can do Ref #85, or if it closes it then you can do Closes #85
from exer_log.
Nah that is not working. I will close this now.
from exer_log.
Related Issues (20)
- Workouts not saved to database and historical workouts not show in calendar HOT 6
- Error, while creating a new workout in debug-mode HOT 7
- Unit Tests For essential features HOT 6
- Mergeable not working now HOT 3
- Refactor: replace ThemeProvider HOT 1
- Proposing to change license from MIT to GPLv3 HOT 18
- Implement named routing HOT 1
- Run build checks in every PR HOT 3
- Add template for pull requests
- Request to create a website for this open-source project HOT 10
- Add stalebot to manage stale and irrelevant PRs and issues HOT 8
- Proposal to add issue templates HOT 3
- Please add logo to @EXERLOG organization HOT 2
- Implement Exercise type
- Firebase config: add workoutId in documents returned from getWorkoutOnDate HOT 2
- Ensure all contributors are added HOT 4
- Configure stale management in mergeable
- Firebase configuration HOT 3
- Dart Legacy code and Null Safety HOT 1
- [BUG] Cannot build the app for android HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exer_log.