-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Firebase / initializeApp() #16
Comments
Seems I have "fixed" the problem, in what I admit is a non-ideal way. Create a import 'package:flutter/material.dart';
class RestartWidget extends StatefulWidget {
RestartWidget({required this.child});
final Widget child;
static void restartApp(BuildContext context) {
context.findAncestorStateOfType<_RestartWidgetState>()!.restartApp();
}
@override
_RestartWidgetState createState() => _RestartWidgetState();
}
class _RestartWidgetState extends State<RestartWidget> {
Key key = UniqueKey();
void restartApp() {
setState(() {
key = UniqueKey();
});
}
@override
Widget build(BuildContext context) {
return KeyedSubtree(
key: key,
child: widget.child,
);
}
} Import it in RestartWidget(
child: MyApp(
databaseBuilder: (_, uid) => FirestoreDatabase(uid: uid),
key: Key('wdev'),
),
), Import Navigator.pop(context);
Navigator.of(context).pushNamedAndRemoveUntil(
Routes.login, ModalRoute.withName(Routes.login)); with RestartWidget.restartApp(context); What this does, is re-start the app which in itself restarts the Again, this isn't great, but it works. |
@arturjnt hello there. Thanks a lot for sharing this and also the details info. The RestartWidget seems to be a quick fix. Very sorry for late response, was working on another projects. I'm open up to anyone that are interested to continue improving this open project. |
I also have been encountering the same issues. I had a good chuckle to myself when I saw that someone had the exact same issues and we even implemented the same kind of fixes even though I hadn't taken a look at this post. |
Hello,
First of all, thank you for the code, it can have a lot of value.
That being said, I found some issues when trying to start the app.
First I had to go to
pubspec.yaml
and do:and change line 27 on the
app_localizations.dart
toor the app wouldn't even start.
Then I had to add
between lines 15/16 of the main.dart and main_prod.dart, or again, the app wouldn't even start. (Also had to add
firebase_core: ^1.6.0
to thepubspec.yaml
, and the import tomain.dart
and andmain_prod.dart
of course).Then in line 81 of the
my_app.dart
I had to change it to:because
userSnapshot.hasData
always had "something", and that was causing records to be inserted in the database withuid as null
meaning/user/null/todos/<todo_item_id>
.But now I can't move on.
The issue itself is when I log out and login with another user, I have the data from the old user.
I know you say on the
README.md
that:But this doesn't seem to be happening.
Might be due to my changes as mentioned above.
Any help would be much appreciated. Regards to all.
The text was updated successfully, but these errors were encountered: