Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _MyHomePageState extends State<MyHomePage> {
TextEditingController _phoneNumberController = TextEditingController();
TextEditingController _otpController = TextEditingController();

FirebaseUser _firebaseUser;
User _firebaseUser;
String _status;

AuthCredential _phoneAuthCredential;
Expand All @@ -52,7 +52,7 @@ class _MyHomePageState extends State<MyHomePage> {
}

Future<void> _getFirebaseUser() async {
this._firebaseUser = await FirebaseAuth.instance.currentUser();
this._firebaseUser = await FirebaseAuth.instance.currentUser;
setState(() {
_status =
(_firebaseUser == null) ? 'Not Logged In\n' : 'Already LoggedIn\n';
Expand All @@ -79,7 +79,7 @@ class _MyHomePageState extends State<MyHomePage> {
try {
await FirebaseAuth.instance
.signInWithCredential(this._phoneAuthCredential)
.then((AuthResult authRes) {
.then((authRes) {
_firebaseUser = authRes.user;
print(_firebaseUser.toString());
}).catchError((e) => _handleError(e));
Expand Down Expand Up @@ -121,7 +121,7 @@ class _MyHomePageState extends State<MyHomePage> {
print(phoneAuthCredential);
}

void verificationFailed(AuthException error) {
void verificationFailed(error) {
print('verificationFailed');
_handleError(error);
}
Expand Down Expand Up @@ -174,7 +174,7 @@ class _MyHomePageState extends State<MyHomePage> {

/// when used different phoneNumber other than the current (running) device
/// we need to use OTP to get `phoneAuthCredential` which is inturn used to signIn/login
this._phoneAuthCredential = PhoneAuthProvider.getCredential(
this._phoneAuthCredential = PhoneAuthProvider.credential(
verificationId: this._verificationId, smsCode: smsCode);

_login();
Expand Down Expand Up @@ -261,22 +261,27 @@ class _MyHomePageState extends State<MyHomePage> {
SizedBox(height: 48),
Text('$_status'),
SizedBox(height: 48),
MaterialButton(
ElevatedButton(
onPressed: _login,
child: Text('Login'),
color: Theme.of(context).accentColor,
style: ElevatedButton.styleFrom(
primary: Theme.of(context).accentColor,
),
),
SizedBox(height: 24),
MaterialButton(
ElevatedButton(
onPressed: _logout,
child: Text('Logout'),
color: Theme.of(context).accentColor,
style: ElevatedButton.styleFrom(
primary: Theme.of(context).accentColor),
),
SizedBox(height: 24),
MaterialButton(
ElevatedButton(
onPressed: _displayUser,
child: Text('FirebaseUser'),
color: Theme.of(context).accentColor,
style: ElevatedButton.styleFrom(
primary: Theme.of(context).accentColor,
),
)
],
),
Expand Down
113 changes: 60 additions & 53 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,63 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety.1"
version: "2.6.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.1.0"
cloud_firestore:
dependency: "direct main"
description:
name: cloud_firestore
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
version: "2.2.2"
cloud_firestore_platform_interface:
dependency: transitive
description:
name: cloud_firestore_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.2"
cloud_firestore_web:
dependency: transitive
description:
name: cloud_firestore_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.3"
version: "1.15.0"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -63,42 +77,49 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
firebase:
version: "1.2.0"
firebase_auth:
dependency: "direct main"
description:
name: firebase_auth
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.1"
firebase_auth_platform_interface:
dependency: transitive
description:
name: firebase
name: firebase_auth_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "7.2.1"
firebase_auth:
dependency: "direct main"
version: "4.3.1"
firebase_auth_web:
dependency: transitive
description:
name: firebase_auth
name: firebase_auth_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.14.0+9"
version: "1.3.1"
firebase_core:
dependency: "direct main"
description:
name: firebase_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.4+3"
version: "1.3.0"
firebase_core_platform_interface:
dependency: transitive
description:
name: firebase_core_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "4.0.1"
firebase_core_web:
dependency: transitive
description:
name: firebase_core_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1+2"
version: "1.1.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -114,69 +135,55 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
http:
http_parser:
dependency: transitive
description:
name: http
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0+4"
http_parser:
version: "4.0.0"
intl:
dependency: transitive
description:
name: http_parser
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.4"
version: "0.17.0"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.1+1"
version: "0.6.3"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety.1"
version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.1"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.0"
version: "1.8.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "2.0.0"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -188,56 +195,56 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.2"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.1"
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety.2"
version: "0.3.0"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0"
sdks:
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.12.13+hotfix.4 <2.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5"
7 changes: 3 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ dependencies:
cupertino_icons: ^0.1.3

# Add the dependency for the Firebase Core Flutter SDK
firebase_core: ^0.4.0+9

firebase_auth: ^0.14.0+5
cloud_firestore: ^0.12.9+5
firebase_core: ^1.3.0
firebase_auth: ^1.4.1
cloud_firestore: ^2.2.2


dev_dependencies:
Expand Down