Updated README, minor async fix in main.dart

This commit is contained in:
whysman 2024-11-09 23:19:59 -05:00
parent 996c294153
commit 44c964b889
2 changed files with 13 additions and 24 deletions

View File

@ -1,16 +1,3 @@
# pogdark
A new Flutter project.
## Getting Started
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
This is pogdark

View File

@ -32,15 +32,18 @@ class MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
_prefsReady =
Provider.of<SharedPreferencesProvider>(context, listen: false).ready;
// Retrieve SharedPreferencesProvider instance outside async function
final prefsProvider =
Provider.of<SharedPreferencesProvider>(context, listen: false);
_prefsReady = prefsProvider.ready;
_prefsReady!.then((_) {
final prefsProvider =
Provider.of<SharedPreferencesProvider>(context, listen: false);
// Check if username is not set; if so, show ProfileScreen initially
if (prefsProvider.getUserName().isEmpty) {
// Ensure the widget is still mounted before updating state
if (mounted) {
setState(() {
showProfileInitially = true;
// Check if the username is not set, then show ProfileScreen initially
showProfileInitially = prefsProvider.getUserName().isEmpty;
});
}
});
@ -89,8 +92,7 @@ class MyAppState extends State<MyApp> {
child: Center(
child: ProfileScreen(
isEditing: false,
onClose:
closeInitialProfileScreen, // Close after setup
onClose: closeInitialProfileScreen,
),
),
),
@ -103,7 +105,7 @@ class MyAppState extends State<MyApp> {
child: Center(
child: ProfileScreen(
isEditing: true,
onClose: toggleProfileScreen, // Toggle on edit
onClose: toggleProfileScreen,
),
),
),