Extract row data from csv file. Flutter - 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):

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 ?

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?

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 (!).

Unhandled Exception: RangeError (index): Index out of range: index should be less than

I am having a problem when trying to save a pdf using the "pdf_dart" library.
I assume the problem is linked to the image I'm downloading from the internet to try to attach to the pdf but I'm not sure what it is.
CODE
import 'dart:io';
import 'package:app_formulario/models/Customer.dart';
import 'package:path_provider/path_provider.dart';
import 'package:pdf/pdf.dart' as pdfDart;
import 'package:pdf/widgets.dart';
import 'package:image/image.dart' as imageDart;
import 'package:flutter/material.dart' as materialDart;
import 'package:http/http.dart' as http;
class PDFBloc {
PDFBloc() {
final Document pdf = Document();
http
.get(
"https://clsp.com.br/wp-content/uploads/2018/05/logo-clsp-500px.png")
.then((onValue) {
final image = pdfDart.PdfImage(
pdf.document,
image: onValue.bodyBytes,
width: 300,
height: 150,
);
pdf.addPage(Page(build: (Context context) {
return Center(
child: Image(image),
); // Center
}));
criarPDF(pdf);
});
}
void criarPDF(Document pdf) async {
Directory appDocDir = await getApplicationDocumentsDirectory();
String appDocPath = appDocDir.path;
appDocPath = "/storage/emulated/0/Android/data/com.rwrd.app_formulario";
final File file = File('$appDocPath/example.pdf');
file.writeAsBytesSync(pdf.save());
}
The error happens right when I am going to save the pdf with the image, that is, apparently the image is downloaded normally, however when inserting it in the pdf and trying to save it, the error is caused.
I don't know if the way I'm saving is the correct one, maybe that's it, but unfortunately I can't access the file folder without going all the way through it.
The error stack
E/flutter (18670): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: RangeError (index): Index out of range: index should be less than 6307: 6308
E/flutter (18670): #0 Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2209:7)
E/flutter (18670): #1 PdfImage._prepare
package:pdf/src/image.dart:183
E/flutter (18670): #2 PdfObject._write
package:pdf/src/object.dart:53
E/flutter (18670): #3 PdfOutput.write
package:pdf/src/output.dart:69
E/flutter (18670): #4 SetMixin.forEach (dart:collection/set.dart:148:30)
E/flutter (18670): #5 PdfDocument._write
package:pdf/src/document.dart:168
E/flutter (18670): #6 PdfDocument.save
package:pdf/src/document.dart:176
E/flutter (18670): #7 Document.save
package:pdf/widgets/document.dart:71
E/flutter (18670): #8 PDFBloc.criarPDF
package:app_formulario/blocs/pdfBloc.dart:53
E/flutter (18670): <asynchronous suspension>
E/flutter (18670): #9 new PDFBloc.<anonymous closure>
package:app_formulario/blocs/pdfBloc.dart:35
E/flutter (18670): #10 _rootRunUnary (dart:async/zone.dart:1134:38)
E/flutter (18670): #11 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (18670): #12 _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
E/flutter (18670): #13 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
E/flutter (18670): #14 Future._propagateToListeners (dart:async/future_impl.dart:709:32)
E/flutter (18670): #15 Future._completeWithValue (dart:async/future_impl.dart:524:5)
E/flutter (18670): #16 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:32:15)
E/flutter (18670): #17 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:290:13)
E/flutter (18670): #18 _withClient (package:http/http.dart)
E/flutter (18670): <asynchronous suspension>
E/flutter (18670): #19 get
package:http/http.dart:46
E/flutter (18670): #20 new PDFBloc
package:app_formulario/blocs/pdfBloc.dart:18
E/flutter (18670): #21 FormBloc._recoverCustomerInformations
package:app_formulario/blocs/formBloc.dart:37
E/flutter (18670): #22 _rootRunUnary (dart:async/zone.dart:1134:38)
E/flutter (18670): #23 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (18670): #24 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter (18670): #25 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:338:11)
E/flutter (18670): #26 _DelayedData.perform (dart:async/stream_impl.dart:593:14)
E/flutter (18670): #27 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:709:11)
E/flutter (18670): #28 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:669:7)
E/flutter (18670): #29 _rootRun (dart:async/zone.dart:1122:38)
E/flutter (18670): #30 _CustomZone.run (dart:async/zone.dart:1023:19)
E/flutter (18670): #31 _CustomZone.runGuarded (dart:async/zone.dart:925:7)
E/flutter (18670): #32 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
E/flutter (18670): #33 _rootRun (dart:async/zone.dart:1126:13)
E/flutter (18670): #34 _CustomZone.run (dart:async/zone.dart:1023:19)
E/flutter (18670): #35 _CustomZone.runGuarded (dart:async/zone.dart:925:7)
E/flutter (18670): #36 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
E/flutter (18670): #37 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
E/flutter (18670): #38 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
E/flutter (18670):
change pdf image widget to this,
final image = pdfDart.PdfImage.jpeg(
pdf.document,
image: onValue.bodyBytes,
);
now, your image should appear in the pdf but you will have to resize your image if you want to fix height and width.

Error while using games_services plugin: Unhandled Exception: PlatformException(error, 4: 4: , null)

I wanted to use google play services in my flutter application for which i used games_services plugin. I followed all the steps in this medium post. But it still gave me this error.
E/flutter (27643): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, 4: 4: , null)
E/flutter (27643): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569)
E/flutter (27643): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321)
E/flutter (27643): <asynchronous suspension>
E/flutter (27643): #2 GamesServices.signIn (package:games_services/games_services.dart:52)
E/flutter (27643): #3 _WelcomePageState.build.<anonymous closure> (package:quizbee/pages/home/welcome.dart:182)
E/flutter (27643): #4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706)
E/flutter (27643): #5 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789)
E/flutter (27643): #6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182)
E/flutter (27643): #7 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486)
E/flutter (27643): #8 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282)
E/flutter (27643): #9 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:199)
E/flutter (27643): #10 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:467)
E/flutter (27643): #11 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76)
E/flutter (27643): #12 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:117)
E/flutter (27643): #13 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379)
E/flutter (27643): #14 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:115)
E/flutter (27643): #15 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101)
E/flutter (27643): #16 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218)
E/flutter (27643): #17 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198)
E/flutter (27643): #18 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156)
E/flutter (27643): #19 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102)
E/flutter (27643): #20 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86)
E/flutter (27643): #21 _rootRunUnary (dart:async/zone.dart:1138)
E/flutter (27643): #22 _CustomZone.runUnary (dart:async/zone.dart:1031)
E/flutter (27643): #23 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933)
E/flutter (27643): #24 _invoke1 (dart:ui/hooks.dart:273)
E/flutter (27643): #25 _dispatchPointerDataPacket (dart:ui/hooks.dart:182)
Thank You in advance.

Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index' flutter new

I am not getting output on my app and it should have give a output like many question is how to sisplay json data in my flutter app
class AppState extends State<AppName>{
var name ;
var email ;
int cgpa ;
TextEditingController user = new TextEditingController();
String url = 'http://10.42.0.243:8000/students/';
getData(String username) async{
String profile = url+'?search='+username;
var res = await http.get(profile,headers: {"Accept":"application/json"});
print(res.body);
debugPrint(res.body);
var resBody = json.decode(res.body);
name = resBody['sname'].toString();
email = resBody['email'].toString();
cgpa = resBody['cgpa'] ;
debugPrint(name);
setState(() {
print("Success");
});
}
my app screenshot is
JSON Data Screenshot
Error output:
Performing hot reload...
Syncing files to device Moto G 5 Plus...
Reloaded 0 of 576 libraries in 389ms.
E/BpSurfaceComposerClient(28411): Failed to transact (-1)
E/BpSurfaceComposerClient(28411): Failed to transact (-1)
I/flutter (28411): [{"id":1,"sname":"Ashutosh Lokhande","email":"2016bit053#sggs.ac.in","year":"2016","cgpa":7.2}]
I/flutter (28411): [{"id":1,"sname":"Ashutosh Lokhande","email":"2016bit053#sggs.ac.in","year":"2016","cgpa":7.2}]
E/flutter (28411): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index'
E/flutter (28411): #0 AppState.getData (package:json_flutter/main.dart:28:19)
E/flutter (28411):
E/flutter (28411): #1 AppState.build. (package:json_flutter/main.dart:56:34)
E/flutter (28411): #2 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:654:14)
E/flutter (28411): #3 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:729:32)
E/flutter (28411): #4 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (28411): #5 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:365:11)
E/flutter (28411): #6 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:275:7)
E/flutter (28411): #7 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:455:9)
E/flutter (28411): #8 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:75:13)
E/flutter (28411): #9 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:102:11)
E/flutter (28411): #10 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter (28411): #11 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (28411): #12 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (28411): #13 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (28411): #14 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (28411): #15 _rootRunUnary (dart:async/zone.dart:1136:13)
E/flutter (28411): #16 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (28411): #17 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter (28411): #18 _invoke1 (dart:ui/hooks.dart:263:10)
E/flutter (28411): #19 _dispatchPointerDataPacket (dart:ui/hooks.dart:172:5)
E/flutter (28411):