flutter_firebase_phone_auth_riverpod
flutter_firebase_phone_auth_riverpod copied to clipboard
null safety enabled - long list of errors
Hi there,
great work with this riverpod phone auth example, thank you for that :)
There is a problem though. I am using latest version of Flutter SDK and this is my pubspec.yaml file:
name: flutter_firebase_phone_auth_riverpod
description: Using Riverpod to handle Firebase Phone Authentication
publish_to: "none"
version: 1.2.0
environment:
sdk: '>=2.18.0-159.0.dev <3.0.0'
dependencies:
cupertino_icons: ^1.0.4
firebase_auth: ^3.3.19
firebase_core: ^1.17.1
flutter:
sdk: flutter
flutter_libphonenumber: 1.1.0
flutter_riverpod: ^1.0.4
freezed_annotation: ^2.0.3
pinput: ^2.2.9
dev_dependencies:
build_runner: ^2.1.11
flutter_lints: ^1.0.0
flutter_test:
sdk: flutter
freezed: ^2.0.3+1
flutter:
uses-material-design: true
assets:
- assets/
When i try to run your example app, it outputs quite a lot of errors, seems like because of null-safety. Could you take a look and fix it perhaps, so we would have a working example?
flutter run
Using hardware rendering with device sdk gphone x86. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on sdk gphone x86 in debug mode...
lib/app/common_widgets/error_page.dart:5:9: Error: The parameter 'key' can't have a value of 'null' because of its type 'Key', but the implicit default value is 'null'.
- 'Key' is from 'package:flutter/src/foundation/key.dart' ('../../development/flutter/packages/flutter/lib/src/foundation/key.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
Key key,
^^^
lib/app/common_widgets/error_page.dart:6:10: Error: The parameter 'message' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.message,
^^^^^^^
lib/app/common_widgets/buttons.dart:5:9: Error: The parameter 'key' can't have a value of 'null' because of its type 'Key', but the implicit default value is 'null'.
- 'Key' is from 'package:flutter/src/foundation/key.dart' ('../../development/flutter/packages/flutter/lib/src/foundation/key.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
Key key,
^^^
lib/app/common_widgets/buttons.dart:6:10: Error: The parameter 'title' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.title,
^^^^^
lib/app/common_widgets/buttons.dart:7:10: Error: The parameter 'onPressed' can't have a value of 'null' because of its type 'void Function()', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.onPressed,
^^^^^^^^^
lib/app/sign_in/sign_in_phone_page.dart:71:9: Error: The parameter 'key' can't have a value of 'null' because of its type 'Key', but the implicit default value is 'null'.
- 'Key' is from 'package:flutter/src/foundation/key.dart' ('../../development/flutter/packages/flutter/lib/src/foundation/key.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
Key key,
^^^
lib/app/sign_in/sign_in_phone_page.dart:74:10: Error: The parameter 'errorText' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.errorText,
^^^^^^^^^
lib/app/sign_in/sign_in_phone_page.dart:75:10: Error: The parameter 'phoneCode' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.phoneCode,
^^^^^^^^^
lib/app/sign_in/sign_in_phone_page.dart:76:10: Error: The parameter 'phonePlaceholder' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.phonePlaceholder,
^^^^^^^^^^^^^^^^
lib/app/sign_in/sign_in_phone_page.dart:77:10: Error: The parameter 'formatter' can't have a value of 'null' because of its type 'LibPhonenumberTextFormatter', but the implicit default value is 'null'.
- 'LibPhonenumberTextFormatter' is from 'package:flutter_libphonenumber/src/input_formatter/input_formatter.dart' ('../../.pub-cache/hosted/pub.dartlang.org/flutter_libphonenumber-1.1.0/lib/src/input_formatter/input_formatter.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.formatter,
^^^^^^^^^
lib/app/sign_in/sign_in_phone_page.dart:78:10: Error: The parameter 'onSubmit' can't have a value of 'null' because of its type 'dynamic Function()', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.onSubmit,
^^^^^^^^
lib/app/sign_in/sign_in_verification_page.dart:64:9: Error: The parameter 'key' can't have a value of 'null' because of its type 'Key', but the implicit default value is 'null'.
- 'Key' is from 'package:flutter/src/foundation/key.dart' ('../../development/flutter/packages/flutter/lib/src/foundation/key.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
Key key,
^^^
lib/app/sign_in/sign_in_verification_page.dart:65:10: Error: The parameter 'phoneNumber' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.phoneNumber,
^^^^^^^^^^^
lib/app/sign_in/sign_in_verification_page.dart:68:10: Error: The parameter 'errorText' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.errorText,
^^^^^^^^^
lib/app/sign_in/sign_in_verification_page.dart:69:10: Error: The parameter 'delayBeforeNewCode' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.delayBeforeNewCode,
^^^^^^^^^^^^^^^^^^
lib/app/sign_in/sign_in_verification_page.dart:70:10: Error: The parameter 'resendCode' can't have a value of 'null' because of its type 'dynamic Function()', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.resendCode,
^^^^^^^^^^
lib/app/sign_in/sign_in_verification_page.dart:71:10: Error: The parameter 'verifyCode' can't have a value of 'null' because of its type 'dynamic Function(String)', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.verifyCode,
^^^^^^^^^^
lib/app/common_widgets/error_text.dart:5:9: Error: The parameter 'key' can't have a value of 'null' because of its type 'Key', but the implicit default value is 'null'.
- 'Key' is from 'package:flutter/src/foundation/key.dart' ('../../development/flutter/packages/flutter/lib/src/foundation/key.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
Key key,
^^^
lib/app/common_widgets/error_text.dart:6:10: Error: The parameter 'message' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.message,
^^^^^^^
lib/app/sign_in/sign_in_phone_model.dart:8:10: Error: The parameter 'authService' can't have a value of 'null' because of its type 'AuthService', but the implicit default value is 'null'.
- 'AuthService' is from 'package:flutter_firebase_phone_auth_riverpod/services/auth_service.dart' ('lib/services/auth_service.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.authService,
^^^^^^^^^^^
lib/app/sign_in/sign_in_verification_model.dart:10:10: Error: The parameter 'authService' can't have a value of 'null' because of its type 'AuthService', but the implicit default value is 'null'.
- 'AuthService' is from 'package:flutter_firebase_phone_auth_riverpod/services/auth_service.dart' ('lib/services/auth_service.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.authService,
^^^^^^^^^^^
lib/app/routing/app_router.dart:39:16: Error: The value 'null' can't be returned from a function with return type 'Route<dynamic>' because 'Route<dynamic>' is not nullable.
- 'Route' is from 'package:flutter/src/widgets/navigator.dart' ('../../development/flutter/packages/flutter/lib/src/widgets/navigator.dart').
return null;
^
lib/app/sign_in/sign_in_phone_page.dart:24:19: Error: The value 'null' can't be returned from a function with return type 'CountryWithPhoneCode' because 'CountryWithPhoneCode' is not nullable.
- 'CountryWithPhoneCode' is from 'package:flutter_libphonenumber/src/country_data.dart' ('../../.pub-cache/hosted/pub.dartlang.org/flutter_libphonenumber-1.1.0/lib/src/country_data.dart').
orElse: () => null,
^
lib/app/sign_in/sign_in_phone_page.dart:49:12: Error: Method 'replaceAll' cannot be called on 'String?' because it is potentially null.
Try calling using ?. instead.
.replaceAll('+${selectedCountry.phoneCode} ', ''),
^^^^^^^^^^
lib/app/sign_in/sign_in_phone_page.dart:63:23: Error: The value 'null' can't be returned from a function with return type 'String' because 'String' is not nullable.
orElse: () => null,
^
lib/app/sign_in/sign_in_phone_page.dart:162:58: Error: The argument type 'Color?' can't be assigned to the parameter type 'Color' because 'Color?' is nullable and 'Color' isn't.
- 'Color' is from 'dart:ui'.
BorderSide(color: Colors.grey[300], width: 1.0),
^
lib/app/sign_in/sign_in_phone_page.dart:176:45: Error: The argument type 'dynamic Function()?' can't be assigned to the parameter type 'void Function()' because 'dynamic Function()?' is nullable and 'void Function()' isn't.
onPressed: widget.canSubmit ? widget.onSubmit : null,
^
lib/app/sign_in/sign_in_verification_page.dart:56:23: Error: The value 'null' can't be returned from a function with return type 'String' because 'String' is not nullable.
orElse: () => null,
^
lib/app/sign_in/sign_in_verification_page.dart:102:46: Error: The argument type 'Color?' can't be assigned to the parameter type 'Color' because 'Color?' is nullable and 'Color' isn't.
- 'Color' is from 'dart:ui'.
border: Border.all(color: Colors.grey[300]),
^
lib/app/sign_in/sign_in_verification_page.dart:147:53: Error: Property 'length' cannot be accessed on 'String?' because it is potentially null.
Try accessing using ?. instead.
if (widget.errorText == null && s.length == 6)
^^^^^^
lib/app/sign_in/sign_in_verification_page.dart:148:39: Error: The argument type 'String?' can't be assigned to the parameter type 'String' because 'String?' is nullable and 'String' isn't.
widget.verifyCode(s);
^
lib/services/auth_service.dart:19:52: Error: A value of type 'Stream<User?>' can't be returned from a function with return type 'Stream<User>' because 'User?' is nullable and 'User' isn't.
- 'Stream' is from 'dart:async'.
- 'User' is from 'package:firebase_auth/firebase_auth.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase_auth-3.3.19/lib/firebase_auth.dart').
Stream<User> authStateChanges() => _firebaseAuth.authStateChanges();
^
lib/services/auth_service.dart:30:14: Error: Method 'toLowerCase' cannot be called on 'String?' because it is potentially null.
Try calling using ?. instead.
.toLowerCase()
^^^^^^^^^^^
lib/services/auth_service.dart:31:38: Error: Method 'toLowerCase' cannot be called on 'String?' because it is potentially null.
Try calling using ?. instead.
.compareTo(b.countryName.toLowerCase());
^^^^^^^^^^^
package:flutter_firebase_phone_auth_riverpod/services/auth_service.dart: Error: The parameter 'resendToken' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
lib/services/auth_service.dart:77:17: Error: The argument type 'void Function(String, [int])' can't be assigned to the parameter type 'void Function(String, int?)' because 'int?' is nullable and 'int' isn't.
codeSent: (String verificationId, [int resendToken]) {
^
lib/app/sign_in/sign_in_phone_model.dart:28:14: Error: The getter 'message' isn't defined for the class 'Object'.
- 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'message'.
if (!e.message.contains('parse')) {
^^^^^^^
lib/app/sign_in/sign_in_phone_model.dart:29:37: Error: The getter 'message' isn't defined for the class 'Object'.
- 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'message'.
state = SignInState.error(e.message);
^^^^^^^
lib/app/sign_in/sign_in_phone_model.dart:43:35: Error: The getter 'message' isn't defined for the class 'Object'.
- 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'message'.
state = SignInState.error(e.message);
^^^^^^^
lib/app/sign_in/sign_in_verification_model.dart:51:35: Error: The getter 'message' isn't defined for the class 'Object'.
- 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'message'.
state = SignInState.error(e.message);
^^^^^^^
lib/app/sign_in/sign_in_verification_model.dart:62:13: Error: The getter 'code' isn't defined for the class 'Object'.
- 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'code'.
if (e.code == "invalid-verification-code") {
^^^^
lib/app/sign_in/sign_in_verification_model.dart:65:37: Error: The getter 'message' isn't defined for the class 'Object'.
- 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'message'.
state = SignInState.error(e.message);
^^^^^^^
lib/services/auth_service.dart:13:16: Error: Field '_firebaseAuth' should be initialized because its type 'FirebaseAuth' doesn't allow null.
- 'FirebaseAuth' is from 'package:firebase_auth/firebase_auth.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase_auth-3.3.19/lib/firebase_auth.dart').
FirebaseAuth _firebaseAuth;
^^^^^^^^^^^^^
lib/services/auth_service.dart:14:24: Error: Field '_selectedCountry' should be initialized because its type 'CountryWithPhoneCode' doesn't allow null.
- 'CountryWithPhoneCode' is from 'package:flutter_libphonenumber/src/country_data.dart' ('../../.pub-cache/hosted/pub.dartlang.org/flutter_libphonenumber-1.1.0/lib/src/country_data.dart').
CountryWithPhoneCode _selectedCountry;
^^^^^^^^^^^^^^^^
lib/services/auth_service.dart:15:7: Error: Field '_phoneNumber' should be initialized because its type 'Map<dynamic, dynamic>' doesn't allow null.
- 'Map' is from 'dart:core'.
Map _phoneNumber;
^^^^^^^^^^^^
lib/services/auth_service.dart:16:10: Error: Field '_verificationId' should be initialized because its type 'String' doesn't allow null.
String _verificationId;
^^^^^^^^^^^^^^^
lib/app/sign_in/sign_in_verification_model.dart:18:9: Error: Field '_timer' should be initialized because its type 'Timer' doesn't allow null.
- 'Timer' is from 'dart:async'.
Timer _timer;
^^^^^^
lib/app/sign_in/sign_in_verification_model.dart:20:7: Error: Field '_countdown' should be initialized because its type 'int' doesn't allow null.
int _countdown;
^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script '/home/dino/development/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1159
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/home/dino/development/flutter/bin/flutter'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
Running Gradle task 'assembleDebug'... 8.6s
Exception: Gradle task assembleDebug failed with exit code 1
Then i have also tried to run it with null safety disabled, but it produced errors as well.
flutter run --no-sound-null-safety
Using hardware rendering with device sdk gphone x86. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on sdk gphone x86 in debug mode...
lib/app/common_widgets/error_page.dart:5:9: Error: The parameter 'key' can't have a value of 'null' because of its type 'Key', but the implicit default value is 'null'.
- 'Key' is from 'package:flutter/src/foundation/key.dart' ('../../development/flutter/packages/flutter/lib/src/foundation/key.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
Key key,
^^^
lib/app/common_widgets/error_page.dart:6:10: Error: The parameter 'message' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.message,
^^^^^^^
lib/app/common_widgets/buttons.dart:5:9: Error: The parameter 'key' can't have a value of 'null' because of its type 'Key', but the implicit default value is 'null'.
- 'Key' is from 'package:flutter/src/foundation/key.dart' ('../../development/flutter/packages/flutter/lib/src/foundation/key.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
Key key,
^^^
lib/app/common_widgets/buttons.dart:6:10: Error: The parameter 'title' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.title,
^^^^^
lib/app/common_widgets/buttons.dart:7:10: Error: The parameter 'onPressed' can't have a value of 'null' because of its type 'void Function()', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.onPressed,
^^^^^^^^^
lib/app/sign_in/sign_in_phone_page.dart:71:9: Error: The parameter 'key' can't have a value of 'null' because of its type 'Key', but the implicit default value is 'null'.
- 'Key' is from 'package:flutter/src/foundation/key.dart' ('../../development/flutter/packages/flutter/lib/src/foundation/key.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
Key key,
^^^
lib/app/sign_in/sign_in_phone_page.dart:74:10: Error: The parameter 'errorText' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.errorText,
^^^^^^^^^
lib/app/sign_in/sign_in_phone_page.dart:75:10: Error: The parameter 'phoneCode' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.phoneCode,
^^^^^^^^^
lib/app/sign_in/sign_in_phone_page.dart:76:10: Error: The parameter 'phonePlaceholder' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.phonePlaceholder,
^^^^^^^^^^^^^^^^
lib/app/sign_in/sign_in_phone_page.dart:77:10: Error: The parameter 'formatter' can't have a value of 'null' because of its type 'LibPhonenumberTextFormatter', but the implicit default value is 'null'.
- 'LibPhonenumberTextFormatter' is from 'package:flutter_libphonenumber/src/input_formatter/input_formatter.dart' ('../../.pub-cache/hosted/pub.dartlang.org/flutter_libphonenumber-1.1.0/lib/src/input_formatter/input_formatter.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.formatter,
^^^^^^^^^
lib/app/sign_in/sign_in_phone_page.dart:78:10: Error: The parameter 'onSubmit' can't have a value of 'null' because of its type 'dynamic Function()', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.onSubmit,
^^^^^^^^
lib/app/sign_in/sign_in_verification_page.dart:64:9: Error: The parameter 'key' can't have a value of 'null' because of its type 'Key', but the implicit default value is 'null'.
- 'Key' is from 'package:flutter/src/foundation/key.dart' ('../../development/flutter/packages/flutter/lib/src/foundation/key.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
Key key,
^^^
lib/app/sign_in/sign_in_verification_page.dart:65:10: Error: The parameter 'phoneNumber' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.phoneNumber,
^^^^^^^^^^^
lib/app/sign_in/sign_in_verification_page.dart:68:10: Error: The parameter 'errorText' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.errorText,
^^^^^^^^^
lib/app/sign_in/sign_in_verification_page.dart:69:10: Error: The parameter 'delayBeforeNewCode' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.delayBeforeNewCode,
^^^^^^^^^^^^^^^^^^
lib/app/sign_in/sign_in_verification_page.dart:70:10: Error: The parameter 'resendCode' can't have a value of 'null' because of its type 'dynamic Function()', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.resendCode,
^^^^^^^^^^
lib/app/sign_in/sign_in_verification_page.dart:71:10: Error: The parameter 'verifyCode' can't have a value of 'null' because of its type 'dynamic Function(String)', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.verifyCode,
^^^^^^^^^^
lib/app/common_widgets/error_text.dart:5:9: Error: The parameter 'key' can't have a value of 'null' because of its type 'Key', but the implicit default value is 'null'.
- 'Key' is from 'package:flutter/src/foundation/key.dart' ('../../development/flutter/packages/flutter/lib/src/foundation/key.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
Key key,
^^^
lib/app/common_widgets/error_text.dart:6:10: Error: The parameter 'message' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.message,
^^^^^^^
lib/app/sign_in/sign_in_phone_model.dart:8:10: Error: The parameter 'authService' can't have a value of 'null' because of its type 'AuthService', but the implicit default value is 'null'.
- 'AuthService' is from 'package:flutter_firebase_phone_auth_riverpod/services/auth_service.dart' ('lib/services/auth_service.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.authService,
^^^^^^^^^^^
lib/app/sign_in/sign_in_verification_model.dart:10:10: Error: The parameter 'authService' can't have a value of 'null' because of its type 'AuthService', but the implicit default value is 'null'.
- 'AuthService' is from 'package:flutter_firebase_phone_auth_riverpod/services/auth_service.dart' ('lib/services/auth_service.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
this.authService,
^^^^^^^^^^^
lib/app/routing/app_router.dart:39:16: Error: The value 'null' can't be returned from a function with return type 'Route<dynamic>' because 'Route<dynamic>' is not nullable.
- 'Route' is from 'package:flutter/src/widgets/navigator.dart' ('../../development/flutter/packages/flutter/lib/src/widgets/navigator.dart').
return null;
^
lib/app/sign_in/sign_in_phone_page.dart:24:19: Error: The value 'null' can't be returned from a function with return type 'CountryWithPhoneCode' because 'CountryWithPhoneCode' is not nullable.
- 'CountryWithPhoneCode' is from 'package:flutter_libphonenumber/src/country_data.dart' ('../../.pub-cache/hosted/pub.dartlang.org/flutter_libphonenumber-1.1.0/lib/src/country_data.dart').
orElse: () => null,
^
lib/app/sign_in/sign_in_phone_page.dart:49:12: Error: Method 'replaceAll' cannot be called on 'String?' because it is potentially null.
Try calling using ?. instead.
.replaceAll('+${selectedCountry.phoneCode} ', ''),
^^^^^^^^^^
lib/app/sign_in/sign_in_phone_page.dart:63:23: Error: The value 'null' can't be returned from a function with return type 'String' because 'String' is not nullable.
orElse: () => null,
^
lib/app/sign_in/sign_in_phone_page.dart:162:58: Error: The argument type 'Color?' can't be assigned to the parameter type 'Color' because 'Color?' is nullable and 'Color' isn't.
- 'Color' is from 'dart:ui'.
BorderSide(color: Colors.grey[300], width: 1.0),
^
lib/app/sign_in/sign_in_phone_page.dart:176:45: Error: The argument type 'dynamic Function()?' can't be assigned to the parameter type 'void Function()' because 'dynamic Function()?' is nullable and 'void Function()' isn't.
onPressed: widget.canSubmit ? widget.onSubmit : null,
^
lib/app/sign_in/sign_in_verification_page.dart:56:23: Error: The value 'null' can't be returned from a function with return type 'String' because 'String' is not nullable.
orElse: () => null,
^
lib/app/sign_in/sign_in_verification_page.dart:102:46: Error: The argument type 'Color?' can't be assigned to the parameter type 'Color' because 'Color?' is nullable and 'Color' isn't.
- 'Color' is from 'dart:ui'.
border: Border.all(color: Colors.grey[300]),
^
lib/app/sign_in/sign_in_verification_page.dart:147:53: Error: Property 'length' cannot be accessed on 'String?' because it is potentially null.
Try accessing using ?. instead.
if (widget.errorText == null && s.length == 6)
^^^^^^
lib/app/sign_in/sign_in_verification_page.dart:148:39: Error: The argument type 'String?' can't be assigned to the parameter type 'String' because 'String?' is nullable and 'String' isn't.
widget.verifyCode(s);
^
lib/services/auth_service.dart:19:52: Error: A value of type 'Stream<User?>' can't be returned from a function with return type 'Stream<User>' because 'User?' is nullable and 'User' isn't.
- 'Stream' is from 'dart:async'.
- 'User' is from 'package:firebase_auth/firebase_auth.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase_auth-3.3.19/lib/firebase_auth.dart').
Stream<User> authStateChanges() => _firebaseAuth.authStateChanges();
^
lib/services/auth_service.dart:30:14: Error: Method 'toLowerCase' cannot be called on 'String?' because it is potentially null.
Try calling using ?. instead.
.toLowerCase()
^^^^^^^^^^^
lib/services/auth_service.dart:31:38: Error: Method 'toLowerCase' cannot be called on 'String?' because it is potentially null.
Try calling using ?. instead.
.compareTo(b.countryName.toLowerCase());
^^^^^^^^^^^
package:flutter_firebase_phone_auth_riverpod/services/auth_service.dart: Error: The parameter 'resendToken' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
lib/services/auth_service.dart:77:17: Error: The argument type 'void Function(String, [int])' can't be assigned to the parameter type 'void Function(String, int?)' because 'int?' is nullable and 'int' isn't.
codeSent: (String verificationId, [int resendToken]) {
^
lib/app/sign_in/sign_in_phone_model.dart:28:14: Error: The getter 'message' isn't defined for the class 'Object'.
- 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'message'.
if (!e.message.contains('parse')) {
^^^^^^^
lib/app/sign_in/sign_in_phone_model.dart:29:37: Error: The getter 'message' isn't defined for the class 'Object'.
- 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'message'.
state = SignInState.error(e.message);
^^^^^^^
lib/app/sign_in/sign_in_phone_model.dart:43:35: Error: The getter 'message' isn't defined for the class 'Object'.
- 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'message'.
state = SignInState.error(e.message);
^^^^^^^
lib/app/sign_in/sign_in_verification_model.dart:51:35: Error: The getter 'message' isn't defined for the class 'Object'.
- 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'message'.
state = SignInState.error(e.message);
^^^^^^^
lib/app/sign_in/sign_in_verification_model.dart:62:13: Error: The getter 'code' isn't defined for the class 'Object'.
- 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'code'.
if (e.code == "invalid-verification-code") {
^^^^
lib/app/sign_in/sign_in_verification_model.dart:65:37: Error: The getter 'message' isn't defined for the class 'Object'.
- 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'message'.
state = SignInState.error(e.message);
^^^^^^^
lib/services/auth_service.dart:13:16: Error: Field '_firebaseAuth' should be initialized because its type 'FirebaseAuth' doesn't allow null.
- 'FirebaseAuth' is from 'package:firebase_auth/firebase_auth.dart' ('../../.pub-cache/hosted/pub.dartlang.org/firebase_auth-3.3.19/lib/firebase_auth.dart').
FirebaseAuth _firebaseAuth;
^^^^^^^^^^^^^
lib/services/auth_service.dart:14:24: Error: Field '_selectedCountry' should be initialized because its type 'CountryWithPhoneCode' doesn't allow null.
- 'CountryWithPhoneCode' is from 'package:flutter_libphonenumber/src/country_data.dart' ('../../.pub-cache/hosted/pub.dartlang.org/flutter_libphonenumber-1.1.0/lib/src/country_data.dart').
CountryWithPhoneCode _selectedCountry;
^^^^^^^^^^^^^^^^
lib/services/auth_service.dart:15:7: Error: Field '_phoneNumber' should be initialized because its type 'Map<dynamic, dynamic>' doesn't allow null.
- 'Map' is from 'dart:core'.
Map _phoneNumber;
^^^^^^^^^^^^
lib/services/auth_service.dart:16:10: Error: Field '_verificationId' should be initialized because its type 'String' doesn't allow null.
String _verificationId;
^^^^^^^^^^^^^^^
lib/app/sign_in/sign_in_verification_model.dart:18:9: Error: Field '_timer' should be initialized because its type 'Timer' doesn't allow null.
- 'Timer' is from 'dart:async'.
Timer _timer;
^^^^^^
lib/app/sign_in/sign_in_verification_model.dart:20:7: Error: Field '_countdown' should be initialized because its type 'int' doesn't allow null.
int _countdown;
^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script '/home/dino/development/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1159
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/home/dino/development/flutter/bin/flutter'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 7s
Running Gradle task 'assembleDebug'... 8.4s
Exception: Gradle task assembleDebug failed with exit code 1
Kind regards, Neon
I did not try the example with Flutter 3, for the needs of another project, I cannot upgrade to Flutter 3 at the moment. But with Flutter 2.10.5, the example compiles fine and launches on my device. Could you try to revert to Flutter 2.10 and try to compile? If it works, then this is probably an issue due to Flutter 3 requirements and I will upgrade as soon as I can 😌
Err, can't revert back on this machine :) But i will try to look at it and see if i can fix it. Otherwise i will wait for you to make it Flutter 3 ready :D
I'm trying to make progress with null safety of the example, help would be appreciated https://github.com/julienlebren/flutter_firebase_phone_auth_riverpod/pull/6