You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.
import 'package:firebase_auth/firebase_auth.dart';
class AuthService {
//final FirebaseAuth _auth = FirebaseAuth.instance;
Future signInAnon() async {
try {
// UserCredential result = await _auth.signInAnonymously();
UserCredential result = await FirebaseAuth.instance.signInAnonymously();
User user = result.user;
return user;
} catch (e) {
print(e.toString());
return null;
}
}
}
import 'package:flutter/material.dart';
import 'package:newfirebase/services/auth.dart';
class SignIn extends StatefulWidget {
@OverRide
_SignInState createState() => _SignInState();
}
class _SignInState extends State {
final AuthService _auth = AuthService();
@OverRide
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.brown[100],
appBar: AppBar(
backgroundColor: Colors.brown[400],
elevation: 0.0,
title: Text('Sign in to My App'),
),
body: Container(
padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 50.0),
child: RaisedButton(
child: Text('Sign in'),
onPressed: () async {
dynamic result = await _auth.signInAnon();
if (result == null) {
print('error signing in');
} else {
print('signed in');
print(result);
}
},
),
),
);
}
}
The text was updated successfully, but these errors were encountered: