How to unzip in Flutter, got error "Invalid uncompressed block header" - flutter

I'm trying to unzip a password-protected zip file in Flutter. But got an error:
Unhandled Exception: FormatException: Invalid uncompressed block header
The codes:
import 'package:archive/archive_io.dart';
...
extractFileToDisk(path + "/a.zip", path, password: "a_password");
...
The complete log:
E/flutter (11745): #0 Inflate._parseUncompressedBlock (package:archive/src/zlib/inflate.dart:198:7)
E/flutter (11745): #1 Inflate._parseBlock (package:archive/src/zlib/inflate.dart:116:9)
E/flutter (11745): #2 Inflate._inflate (package:archive/src/zlib/inflate.dart:92:20)
E/flutter (11745): #3 new Inflate.buffer (package:archive/src/zlib/inflate.dart:22:5)
E/flutter (11745): #4 ArchiveFile.decompress (package:archive/src/archive_file.dart:76:28)
E/flutter (11745): #5 ArchiveFile.content (package:archive/src/archive_file.dart:67:7)
E/flutter (11745): #6 extractFileToDisk (package:archive/src/io/extract_archive_to_disk.dart:67:29)
E/flutter (11745): #7 _MyHomePageState.initState.extractFile (package:my_project/main.dart:116:9)
Does anyone know how to fix this?

Related

How do i resolve this issue with polyline not showing up on the map?

hoping someone is able to help me with this error i keep getting. I am using async - await method to call the function "drawPolylinefrompickuptodestination", but i keep getting this error..
[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: RangeError (index): Invalid value: Valid value range is empty: 0
E/flutter ( 7629): #0 List.[] (dart:core-patch/growable_array.dart:264:36)
E/flutter ( 7629): #1 AssistantMethods.pickupToDestinationDirections (package:parcel_you_driver_app/assistant/assistant_methods.dart:52:70)
E/flutter ( 7629): <asynchronous suspension>
E/flutter ( 7629): #2 _NewTripScreenState.drawPolylineFromPickupToDestination (package:parcel_you_driver_app/mainScreens/new_trip_screen.dart:395:33)
E/flutter ( 7629): <asynchronous suspension>
E/flutter ( 7629): #3 _NewTripScreenState.build.<anonymous closure> (package:parcel_you_driver_app/mainScreens/new_trip_screen.dart:252:29)
E/flutter ( 7629): <asynchronous suspension>

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):

How to use dart:ffi in Flutter?

I'm stuck on how I would implement dart::ffi in Flutter, specifically the hello_world example.
Starting with the basic flutter create project (and an already compiled hello_world.dll) just trying:
void main() {
final dylib = ffi.DynamicLibrary.open('hello_world.dll');
final HelloWorld hello = dylib
.lookup<ffi.NativeFunction<hello_world_func>>('hello_world')
.asFunction();
hello();
runApp(MyApp());
}
leads to:
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
package:testing_flutter/main.dart:1
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:61913/wRTGFN76kik=/ws
E/flutter (11980): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library (dlopen failed: library "hello_world.dll" not found)
E/flutter (11980): #0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11:55)
E/flutter (11980): #1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:20:12)
E/flutter (11980): #2 main
package:testing_flutter/main.dart:8
E/flutter (11980): #3 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:140:25)
E/flutter (11980): #4 _rootRun (dart:async/zone.dart:1354:13)
E/flutter (11980): #5 _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (11980): #6 _runZoned (dart:async/zone.dart:1788:10)
E/flutter (11980): #7 runZonedGuarded (dart:async/zone.dart:1776:12)
E/flutter (11980): #8 _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:133:5)
E/flutter (11980): #9 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:283:19)
E/flutter (11980): #10 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (11980):
Would I also need a .dylib version, something like what's in the example?
var libraryPath =
path.join(Directory.current.path, 'hello_library', 'libhello.so');
if (Platform.isMacOS)
libraryPath =
path.join(Directory.current.path, 'hello_library', 'libhello.dylib');
if (Platform.isWindows)
libraryPath = path.join(
Directory.current.path, 'hello_library', 'Debug', 'hello.dll');

Flutter/Dart compiler in IntelliJ IDea throwing `NoSuchMethodError: The getter 'file' was called on null.`

When trying to compile/run my Flutter project in IntelliJ IDEA I get this error (with no hint what part of my code it relates to). Any ideas please? Thanks!!
Unhandled exception:
NoSuchMethodError: The getter 'file' was called on null.
Receiver: null
Tried calling: file
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 ProgramCompiler.visitAssertStatement (package:dev_compiler/src/kernel/compiler.dart:3468:59)
#2 ProgramCompiler._initializeFields (package:dev_compiler/src/kernel/compiler.dart:1521:20)
#3 ProgramCompiler._emitConstructorBody (package:dev_compiler/src/kernel/compiler.dart:1392:14)
#4 ProgramCompiler._emitConstructor.<anonymous closure>.<anonymous closure> (package:dev_compiler/src/kernel/compiler.dart:1355:19)
#5 ProgramCompiler._superDisallowed (package:dev_compiler/src/kernel/compiler.dart:3122:24)
#6 ProgramCompiler._emitConstructor.<anonymous closure> (package:dev_compiler/src/kernel/compiler.dart:1354:15)
#7 ProgramCompiler._withLetScope (package:dev_compiler/src/kernel/compiler.dart:2096:25)
#8 ProgramCompiler._withCurrentFunction (package:dev_compiler/src/kernel/compiler.dart:3112:18)
#9 ProgramCompiler._emitConstructor (package:dev_compiler/src/kernel/compiler.dart:1352:16)
#10 ProgramCompiler._defineConstructors (package:dev_compiler/src/kernel/compiler.dart:972:38)
#11 ProgramCompiler._emitClassDeclaration (package:dev_compiler/src/kernel/compiler.dart:567:19)
#12 ProgramCompiler._emitClass (package:dev_compiler/src/kernel/compiler.dart:510:21)
#13 List.forEach (dart:core-patch/growable_array.dart:282:8)
#14 ProgramCompiler._emitLibrary (package:dev_compiler/src/kernel/compiler.dart:459:23)
#15 List.forEach (dart:core-patch/growable_array.dart:282:8)
#16 ProgramCompiler.emitModule (package:dev_compiler/src/kernel/compiler.dart:345:15)
#17 JavaScriptBundler.compile (package:frontend_server/src/javascript_bundle.dart:133:33)
<asynchronous suspension>
....
Finished with error: the Dart compiler exited unexpectedly.
Failed to compile application.

Flutter: type 'String' is not a subtype of type 'int' when parsing json from hosting

I'm parsing json from server and display it on screen. That is work when i parsing from localhost, but when i parsing from hosting there is an error like this
I/flutter (18089): [{"id":10,"reservation":"497538","order":"900000025301","equipment":"F6U-EA112","matcode":"6166357","description":"GASKET:2JKT;HE2;1302X1342X3MM;NASB\/CS","q_need":"1","q_available":"0","q_debt":"0","unit":"EA","location":"","required_date":null,"created_at":null,"updated_at":null},{"id":11,"reservation":"497538","order":"900000025301","equipment":"F6U-EA112","matcode":"6166345","description":"GASKET:2JKT;HE1;1302X1342X3MM;NASB\/CS","q_need":"1","q_available":"1","q_debt":"0","unit":"EA","location":"GD AUTOMOTIVE","required_date":null,"created_at":null,"updated_at":null},{"id":27,"reservation":"497566","order":"900000025329","equipment":"F6U-FA112","matcode":"6166298","description":"GASKET,SPW:IOR;24IN;150LB;GR;304\/304\/CS","q_need":"1","q_available":"0","q_debt":"0","unit":"EA","location":"GD AUTOMOTIVE","required_date":null,"created_at":null,"updated_at":null}]
E/flutter (18089): [ERROR:flutter/runtime/dart_isolate.cc(717)] Isolate (398792005) 'main.dart:_spawn()' exited with an error
E/flutter (18089): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (18089): type 'String' is not a subtype of type 'int'
E/flutter (18089): #0 new Matl.fromJson (package:tams/model/material.dart:49:26)
E/flutter (18089): #1 parseMatl.<anonymous closure> (package:tams/services/material.dart:22:42)
E/flutter (18089): #2 MappedListIterable.elementAt (dart:_internal/iterable.dart:414:29)
E/flutter (18089): #3 ListIterable.toList (dart:_internal/iterable.dart:219:19)
E/flutter (18089): #4 parseMatl (package:tams/services/material.dart:22:58)
E/flutter (18089): #5 _IsolateConfiguration.apply (package:flutter/src/foundation/isolates.dart:88:16)
E/flutter (18089): #6 _spawn.<anonymous closure> (package:flutter/src/foundation/isolates.dart:96:30)
E/flutter (18089): #7 Timeline.timeSync (dart:developer/timeline.dart:168:22)
E/flutter (18089): #8 _spawn (package:flutter/src/foundation/isolates.dart:93:12)
E/flutter (18089): #9 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:292:17)
E/flutter (18089): #10 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
thanks.
i found it.
it because there is different json response from localhost and shared host
localhost
[{"id":10,"reservation":497538,"order":900000025301,"equipment":"F6U-EA112","matcode":6166357,"description":"GASKET:2JKT;HE2;1302X1342X3MM;NASB\/CS","q_need":1,"q_available":0,"q_debt":0,"unit":"EA","location":"","required_date":null,"created_at":null,"updated_at":null},{"id":11,"reservation":497538,"order":900000025301,"equipment":"F6U-EA112","matcode":6166345,"description":"GASKET:2JKT;HE1;1302X1342X3MM;NASB\/CS","q_need":1,"q_available":1,"q_debt":0,"unit":"EA","location":"GD AUTOMOTIVE","required_date":null,"created_at":null,"updated_at":null},{"id":27,"reservation":497566,"order":900000025329,"equipment":"F6U-FA112","matcode":6166298,"description":"GASKET,SPW:IOR;24IN;150LB;GR;304\/304\/CS","q_need":1,"q_available":0,"q_debt":0,"unit":"EA","location":"GD AUTOMOTIVE","required_date":null,"created_at":null,"updated_at":null}]
shared host
[{"id":10,"reservation":"497538","order":"900000025301","equipment":"F6U-EA112","matcode":"6166357","description":"GASKET:2JKT;HE2;1302X1342X3MM;NASB\/CS","q_need":"1","q_available":"0","q_debt":"0","unit":"EA","location":"","required_date":null,"created_at":null,"updated_at":null},{"id":11,"reservation":"497538","order":"900000025301","equipment":"F6U-EA112","matcode":"6166345","description":"GASKET:2JKT;HE1;1302X1342X3MM;NASB\/CS","q_need":"1","q_available":"1","q_debt":"0","unit":"EA","location":"GD AUTOMOTIVE","required_date":null,"created_at":null,"updated_at":null},{"id":27,"reservation":"497566","order":"900000025329","equipment":"F6U-FA112","matcode":"6166298","description":"GASKET,SPW:IOR;24IN;150LB;GR;304\/304\/CS","q_need":"1","q_available":"0","q_debt":"0","unit":"EA","location":"GD AUTOMOTIVE","required_date":null,"created_at":null,"updated_at":null}]