-
Notifications
You must be signed in to change notification settings - Fork 219
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
google_sign_in and flutter_redux #14
Comments
Hey, ermagerd, so sorry I missed this notification! I'll take a look this evening and report back :) Thanks for the kind words and submitting this issue! |
No problem at all, thanks for being available to answer these questions! |
Hey there! Reading through the code, I don't see anything obviously wrong... You mentioned an error: Could you describe what error you're running into? Are you getting an error from the Flutter framework itself or from Firebase / parsing? Just to be sure: You're providing the |
Coded up a quick example showing navigation with a Middleware if this helps: https://github.com/brianegan/flutter_redux/blob/simple-navigation-example/example/lib/main.dart#L20 |
Hi, thanks for the quick response! The issue is that the The prompt that Something that could possibly help: do you know of any examples where someone has successfully used the Thanks again. |
No worries! I work on both redux and this plugin, so happy to cover both scopes :)
I tried a simplified test case to see if google sign in works within Middleware. When you tap the Button, it should launch google sign in from within the middleware. This worked from my end, does it work for you? Hrm, there are some projects I know of that use them in combination, but they're private repos or companies :( import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:redux/redux.dart';
void main() => runApp(new MyApp());
final _googleSignIn = new GoogleSignIn(
scopes: [
'email',
'https://www.googleapis.com/auth/contacts.readonly',
],
);
void signInMiddleware(
Store<String> store,
dynamic action,
NextDispatcher next,
) {
next(action);
try {
_googleSignIn.signIn();
} catch (error) {
print(error);
}
}
final store = new Store<String>((state, action) => action.toString(),
middleware: [signInMiddleware]);
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(
'You have pushed the button this many times:',
),
new Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: new FloatingActionButton(
onPressed: () {
store.dispatch("Sign in");
},
tooltip: 'Increment',
child: new Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
} |
I was somehow able to fix the problem by making my I have, however, run into another problem. It seems that calling the I found this out because I had to press my "sign in" button twice. The first time gave me the correct prompt, but set the account to Any idea why this might be happening? Attached is the updated relevant code:
|
"I was somehow able to fix the problem by making my GoogleSignIn instance a non-static field within the SignIn class rather than a static field in a different class (do you have any insight into why this worked?)." Dart is a bit weird about statics... if you use them in one file it will create the object, then if you use them in another file after importing it will recreate the object :( Don't ask me why :( Because of that, I generally avoid statics unless I'm hacking something together quickly for an idea. "I have, however, run into another problem. It seems that calling the googleSignIn.signIn() method works, but for some reason it does not return the signed in account" Unfortunately, I'm not sure why that would be the case. Did it work before you introduced Redux? If not, you'd probably have to file a bug against the Flutter repo. |
Wow, that's good to know, thank you for that insight. I'll be sure to rearrange the rest of my code to avoid them as much as possible.
It did work before, I'll go ahead and mess around with it to see if I can't figure out why it's broken. Thank you again for your help, you're a lifesaver. I will go ahead and mark this as closed. |
Sure thing, thanks for the Qs! Best of luck with the app :) |
Hi,
First of all, thank you guys for writing such a great library; I am still learning Redux but this package has been a wonderful first introduction.
I am trying to use the google_sign_in package in order to sign users into my app, and it worked fine before I moved to Redux. However, it now throws an error any time I try to sign in to the app. The sign in box that normally pops up now does not, so I think that it might have to do with trying to render the sign in box from Middleware, which doesn't really have a context (?)
Here is the associated code:
SignIn
Middleware
Any help would be appreciated!
The text was updated successfully, but these errors were encountered: