I tried using carousel_slider in my flutter project, it works but I get this warning in my debug console. What can I do to eradicate this? - flutter

The error is coming from the package
The error is coming from line 135
This is the warning I get from my debug console
This happens as the carousel slides
E/flutter (13716): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Null
check operator used on a null value
E/flutter (13716): #0 CarouselSliderState.getTimer.<anonymous closure>
package:carousel_slider/carousel_slider.dart:135
E/flutter (13716): #1 _rootRunUnary (dart:async/zone.dart:1436:47)
E/flutter (13716): #2 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
E/flutter (13716): #3 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
E/flutter (13716): #4 _CustomZone.bindUnaryCallbackGuarded.<anonymous closure>
(dart:async/zone.dart:1281:26)
E/flutter (13716): #5 _rootRunUnary (dart:async/zone.dart:1444:13)
E/flutter (13716): #6 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
E/flutter (13716): #7 _CustomZone.bindUnaryCallback.<anonymous closure>
(dart:async/zone.dart:1265:26)
E/flutter (13716): #8 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
E/flutter (13716): #9 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
E/flutter (13716): #10 _RawReceivePortImpl._handleMessage (dart:isolate-
patch/isolate_patch.dart:192:12)
E/flutter (13716):

According to the error and the screenshot, either carouselState, pageController or page is null, and you are using null check operator (!) to say that these variables can not be null. You can check these variables if they are null or not. Or you can use nullable operator (?) instead of null check operator (!).

Related

Firebase OTP was working but suddenly this error appears

I am trying to use firebase OTP verification
I get this error when sending firebase OTP it was working
but suddenly this error appears
E/FirebaseAuth(17209): [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17499 API key not valid. Please pass a valid API key.
E/flutter (17209): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'String'
E/flutter (17209): #0 MethodChannelFirebaseAuth.verifyPhoneNumber.<anonymous closure> (package:firebase_auth_platform_interface/src/method_channel/method_channel_firebase_auth.dart:660:35)
E/flutter (17209): #1 _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10)
E/flutter (17209): #2 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (17209): #3 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (17209): #4 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
E/flutter (17209): #5 _HandleErrorStream._handleData (dart:async/stream_pipe.dart:253:10)
E/flutter (17209): #6 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
E/flutter (17209): #7 _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10)
E/flutter (17209): #8 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (17209): #9 _DelayedData.perform (dart:async/stream_impl.dart:515:14)
E/flutter (17209): #10 _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
E/flutter (17209): #11 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
E/flutter (17209): #12 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter (17209): #13 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
How to solve that ?

Extract row data from csv file. Flutter

I'm having a file containing multiple data in different rows, where in the first row is having some of the ANSI values and the other rows is having UTF-8 related values.
I was hoping to extract only the first row and decode the ANSI value with the help of the ascii.decoder and in the other rows with the help of utf-8.decoder.
I successfully did the decode when i removed the first row from the csv file manually and vice versa but how to do that programmatically?
This is what I'm trying to do
final ackFile = File(entities[i].path).openRead(); //To read the file
final ackFields = await ackFile.transform(utf8.decoder).transform(const CsvToListConverter()).toList(); //To extract it I'm getting error
//also here
final ackFile = File(entities[i].path).openRead().transform(utf8.decoder).transform(LineSplitter()).forEach((element) => print("Element is $element")); //When trying to read the csv file line by line
I'm getting an error stating as
I/flutter (22362): The supplied value (512.000000pt) will be discarded and treated as if it had not been specified.
E/flutter (22362): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: FormatException: Unexpected extension byte (at offset 82)
E/flutter (22362): #0 _Utf8Decoder.convertChunked (dart:convert-patch/convert_patch.dart:1893:7)
E/flutter (22362): #1 _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:314:28)
E/flutter (22362): #2 _Utf8ConversionSink.add (dart:convert/string_conversion.dart:310:5)
E/flutter (22362): #3 _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:72:18)
E/flutter (22362): #4 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
E/flutter (22362): #5 _rootRunUnary (dart:async/zone.dart:1436:47)
E/flutter (22362): #6 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
E/flutter (22362): #7 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
E/flutter (22362): #8 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (22362): #9 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (22362): #10 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
E/flutter (22362): #11 _StreamController._add (dart:async/stream_controller.dart:607:7)
E/flutter (22362): #12 _StreamController.add (dart:async/stream_controller.dart:554:5)
E/flutter (22362): #13 _FileStream._readBlock.<anonymous closure> (dart:io/file_impl.dart:98:19)
E/flutter (22362): #14 _rootRunUnary (dart:async/zone.dart:1436:47)
E/flutter (22362): #15 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
E/flutter (22362): <asynchronous suspension>
E/flutter (22362):

hydrated_bloc: Unhandled Exception: Null check operator used on a null value

I am trying to use the hydrated_bloc package to persist a Bloc state. I already setup everything but when I try to initialize the HydratedStorage, I get an error saying Null check operator used on a null value
This is the initialization code.
HydratedBloc.storage = await HydratedStorage.build(
storageDirectory: await getTemporaryDirectory(),
);
This is the full stack trace
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: Null check operator used on a null value
#0 MethodChannel.binaryMessenger
package:flutter/…/services/platform_channel.dart:121
#1 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:146
#2 MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:329
#3 MethodChannelPathProvider.getApplicationDocumentsPath
package:path_provider_platform_interface/src/method_channel_path_provider.dart:50
#4 getApplicationDocumentsDirectory
package:path_provider/path_provider.dart:138
#5 main
package:main.dart:50
#6 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:145:25)
#7 _rootRun (dart:async/zone.dart:1428:13)
#8 _CustomZone.run (dart:async/zone.dart:1328:19)
#9 _runZoned (dart:async/zone.dart:1863:10)
#10 runZonedGuarded (dart:async/zone.dart:1851:12)
#11 _runMainZoned.<anonymous closure> (<…>
Reloaded 1 of 1651 libraries in 1,207ms.

How to save values from query in shared_preferences with conditional statement flutter

I have a query function for data from the database that comes with the id number from the database, then the id is saved in shared_preferences in case the new id that comes from the database is larger than the old id that was in the shared_preferences previously.But after running the code, the following problem comes:
E/flutter (30884): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: NoSuchMethodError: Class 'String' has no instance method '<'.
E/flutter (30884): Receiver: ""
E/flutter (30884): Tried calling: <(7)
E/flutter (30884): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
E/flutter (30884): #1 AddCommentsState.getLogin.<anonymous closure> (package:flutter_apptestqeuriy/AddComment.dart:84:46)
E/flutter (30884): #2 State.setState (package:flutter/src/widgets/framework.dart:1240:30)
E/flutter (30884): #3 AddCommentsState.getLogin (package:flutter_apptestqeuriy/AddComment.dart:78:5)
E/flutter (30884): <asynchronous suspension>
E/flutter (30884): #4 AddCommentsState.initState.<anonymous closure> (package:flutter_apptestqeuriy/AddComment.dart:57:9)
E/flutter (30884): #5 interval.function (package:flutter_apptestqeuriy/AddComment.dart:21:9)
E/flutter (30884): #6 _rootRun (dart:async/zone.dart:1182:47)
E/flutter (30884): #7 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (30884): #8 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (30884): #9 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
E/flutter (30884): #10 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (30884): #11 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (30884): #12 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1021:23)
E/flutter (30884): #13 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter (30884): #14 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19)
E/flutter (30884): #15 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5)
E/flutter (30884): #16 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter (30884):
This is the code used to query from the database:
var user_id;
var my_pre_id;
Future<String> getLogin() async {
var response = await http.get(Uri.encodeFull("http://xxxxxxxxxxx/Application.php"),);
setState(() {
var convertDataToJson = json.decode(response.body);
data = convertDataToJson['result'];
if (data != null) {
user_id = int.parse(data[0]['id']);
my_pre_id = _myPreferences.id;
if (my_pre_id == null || my_pre_id < user_id ){
_myPreferences.id = user_id;
_myPreferences.commit();
// print("tappeeeeedddd $my_pre_id");
}
}
});
}
Does anyone know the cause of the problem?
I think the issue comes from my_pre_id < user_id where my_pre_id is actually a String. You might want to do an int.parse() on it as well or change its type in the class.

Not able to login with a Google email in Flutter

I'm trying to login in Flutter and this is the error I'm getting when I try to login with a Google email:
E/flutter (26329): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method '[]' was called on null.
`enter code here`E/flutter (26329): Receiver: null
E/flutter (26329): Tried calling: []("email")
E/flutter (26329): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
E/flutter (26329): #1 DocumentSnapshot.[] (package:cloud_firestore/src/document_snapshot.dart:29:42)
E/flutter (26329): #2 new User.fromDocument (package:buddiesgram/models/user.dart:23:17)
E/flutter (26329): #3 _HomePageState.saveUserInfoFirestore (package:buddiesgram/pages/HomePage.dart:83:26)
E/flutter (26329): <asynchronous suspension>
E/flutter (26329): #4 _HomePageState.controlSignIn (package:buddiesgram/pages/HomePage.dart:54:13)
E/flutter (26329): #5 _HomePageState.initState.<anonymous closure> (package:buddiesgram/pages/HomePage.dart:40:9)
E/flutter (26329): #6 _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (26329): #7 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (26329): #8 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (26329): #9 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (26329): #10 _DelayedData.perform (dart:async/stream_impl.dart:594:14)
E/flutter (26329): #11 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:710:11)
E/flutter (26329): #12 _PendingEvents.schedule.<anonymous closure> *emphasized text*(dart:async/stream_impl.dart:670:7)
E/flutter (26329): #13 _rootRun (dart:async/zone.dart:1180:38)
E/flutter (26329): #14 _CustomZone.run (dart:async/zone.dart:1077:19)
E/flutter (26329): #15 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
E/flutter (26329): #16 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)`**`*enter code here*`**`
E/flutter (26329): #17 _rootRun (dart:async/zone.dart:1184:13)
E/flutter (26329): #18 _CustomZone.run (dart:async/zone.dart:1077:19)
E/flutter (26329): #19 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
E/flutter (26329): #20 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)
E/flutter (26329): #21 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
E/flutter (26329): #22 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
E/flutter (26329):
What am I missing?
Please include a code snippet of what you are trying to do
In my understanding of your stackTrace you are trying to call list on a null object like this:
final UserData userData = someObjectHere;
function login(UserData userData){
//The problem is that userData might be null which causes your issue
String email = userData[]("Email");
}
You're solution might be to use null aware operators or to manually check whether the object you're calling a method on is not null.
String email = userData?.[]("Email");
or
if(userData != null) String email = userData?.[]("Email");