Flutterando / hasura_connect

Connect your Flutter/Dart apps to Hasura simply.
https://pub.dev/packages/hasura_connect
MIT License
204 stars 64 forks source link

Flutter Web dont' work with null safety #98

Closed maginkgo closed 2 years ago

maginkgo commented 3 years ago

I'm trying to run a project in Chrome with Flutter 2.12 and hasura_connect 3.0.2 and it throws me the following error: Note: On desktop it works without problems.

Launching lib/main.dart on Chrome in debug mode...
Unhandled exception:                                                    
Unsupported operation: Undetermined Nullability                         
#0      ProgramCompiler._emitFutureOrType (package:dev_compiler/src/kernel/compiler.dart:2857:7)
#1      ProgramCompiler._normalizeFutureOr (package:dev_compiler/src/kernel/compiler.dart:2730:12)
#2      ProgramCompiler.visitFutureOrType (package:dev_compiler/src/kernel/compiler.dart:2739:7)
#3      FutureOrType.accept (package:kernel/ast.dart:9269:42)           
#4      ProgramCompiler._emitType (package:dev_compiler/src/kernel/compiler.dart:2655:54)
#5      ProgramCompiler.visitFunctionType (package:dev_compiler/src/kernel/compiler.dart:2936:22)
#6      ProgramCompiler._emitFunctionTagged (package:dev_compiler/src/kernel/compiler.dart:2611:19)
#7      ProgramCompiler.visitFunctionExpression (package:dev_compiler/src/kernel/compiler.dart:5866:12)
#8      FunctionExpression.accept (package:kernel/ast.dart:6735:44)     
#9      ProgramCompiler._visitExpression (package:dev_compiler/src/kernel/compiler.dart:3623:20)
#10     ProgramCompiler._emitArgumentList (package:dev_compiler/src/kernel/compiler.dart:5315:11)
#11     ProgramCompiler._emitMethodCall (package:dev_compiler/src/kernel/compiler.dart:4633:16)
#12     ProgramCompiler.visitInstanceInvocation (package:dev_compiler/src/kernel/compiler.dart:4558:12)
#13     InstanceInvocation.accept (package:kernel/ast.dart:4536:44)     
#14     ProgramCompiler._visitExpression (package:dev_compiler/src/kernel/compiler.dart:3623:20)
#15     ProgramCompiler.visitReturnStatement (package:dev_compiler/src/kernel/compiler.dart:4152:38)
#16     ReturnStatement.accept (package:kernel/ast.dart:7786:43)        
#17     ProgramCompiler._visitStatement (package:dev_compiler/src/kernel/compiler.dart:3551:20)
#18     MappedListIterable.elementAt (dart:_internal/iterable.dart:411:31)
#19     ListIterator.moveNext (dart:_internal/iterable.dart:340:26)     
#20     new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:188:27)
#21     new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#22     new List.of (dart:core-patch/array_patch.dart:50:28)            
#23     ListIterable.toList (dart:_internal/iterable.dart:211:44)       
#24     ProgramCompiler.visitBlock (package:dev_compiler/src/kernel/compiler.dart:3717:62)
#25     Block.accept (package:kernel/ast.dart:7048:43)                  
#26     ProgramCompiler._visitStatement (package:dev_compiler/src/kernel/compiler.dart:3551:20)
#27     ProgramCompiler._emitFunctionScopedBody (package:dev_compiler/src/kernel/compiler.dart:3562:18)
#28     ProgramCompiler._emitSyncFunctionBody.<anonymous closure> (package:dev_compiler/src/kernel/compiler.dart:3355:17)
#29     ProgramCompiler._withLetScope (package:dev_compiler/src/kernel/compiler.dart:2235:25)
#30     ProgramCompiler._withCurrentFunction (package:dev_compiler/src/kernel/compiler.dart:3389:18)
#31     ProgramCompiler._emitSyncFunctionBody (package:dev_compiler/src/kernel/compiler.dart:3351:17)
#32     ProgramCompiler._emitFunction (package:dev_compiler/src/kernel/compiler.dart:3165:11)
#33     ProgramCompiler._emitLibraryFunction (package:dev_compiler/src/kernel/compiler.dart:2591:14)
#34     MappedIterator.moveNext (dart:_internal/iterable.dart:389:20)   
#35     new _GrowableList._ofOther (dart:core-patch/growable_array.dart:198:26)
#36     new _GrowableList.of (dart:core-patch/growable_array.dart:152:26)
#37     new List.of (dart:core-patch/array_patch.dart:50:28)            
#38     Iterable.toList (dart:core/iterable.dart:366:12)                
#39     ProgramCompiler._emitLibraryProcedures (package:dev_compiler/src/kernel/compiler.dart:2557:10)
#40     ProgramCompiler._emitLibrary (package:dev_compiler/src/kernel/compiler.dart:530:7)
#41     List.forEach (dart:core-patch/growable_array.dart:403:8)        
#42     ProgramCompiler.emitModule (package:dev_compiler/src/kernel/compiler.dart:394:15)
#43     JavaScriptBundler.compile (package:frontend_server/src/javascript_bundle.dart:144:33)
<asynchronous suspension>                                               
#44     FrontendCompiler.writeJavascriptBundle (package:frontend_server/frontend_server.dart:632:5)
<asynchronous suspension>                                               
#45     FrontendCompiler.compile (package:frontend_server/frontend_server.dart:545:9)
<asynchronous suspension>                                               
#46     listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1105:11)
<asynchronous suspension>                                               
the Dart compiler exited unexpectedly.                                  
Waiting for connection from debug service on Chrome...             12,3s
Failed to compile application.

My code is very simple, I am just trying to consume a subscription, and apparently everything is fine in my code. In fact, as I said, on desktop it works perfect.

When I remove the dependency with hasura_connect in the yaml the problem is solved.

Any idea? thanks

moreiralucas commented 3 years ago

I have the same problem.

smunozp commented 3 years ago

have the same problem with flutter 2.2.1

`Unhandled exception: Unsupported operation: Undetermined Nullability

0 ProgramCompiler._emitFutureOrType (package:dev_compiler/src/kernel/compiler.dart:2894:7)

1 ProgramCompiler._normalizeFutureOr (package:dev_compiler/src/kernel/compiler.dart:2763:12)

2 ProgramCompiler.visitFutureOrType (package:dev_compiler/src/kernel/compiler.dart:2776:7)

3 FutureOrType.accept (package:kernel/ast.dart:11126:42)

4 ProgramCompiler._emitType (package:dev_compiler/src/kernel/compiler.dart:2692:54)

5 ProgramCompiler.visitFunctionType (package:dev_compiler/src/kernel/compiler.dart:2975:22)

6 ProgramCompiler._emitFunctionTagged (package:dev_compiler/src/kernel/compiler.dart:2648:19)

7 ProgramCompiler.visitFunctionExpression (package:dev_compiler/src/kernel/compiler.dart:5971:12)

8 FunctionExpression.accept (package:kernel/ast.dart:8099:44)

9 ProgramCompiler._visitExpression (package:dev_compiler/src/kernel/compiler.dart:3705:20)

10 ProgramCompiler._emitArgumentList (package:dev_compiler/src/kernel/compiler.dart:5413:11)

11 ProgramCompiler._emitMethodCall (package:dev_compiler/src/kernel/compiler.dart:4721:16)

12 ProgramCompiler.visitInstanceInvocation (package:dev_compiler/src/kernel/compiler.dart:4641:12)

13 InstanceInvocation.accept (package:kernel/ast.dart:5178:44)

14 ProgramCompiler._visitExpression (package:dev_compiler/src/kernel/compiler.dart:3705:20)

15 ProgramCompiler.visitReturnStatement (package:dev_compiler/src/kernel/compiler.dart:4235:38)

16 ReturnStatement.accept (package:kernel/ast.dart:9497:43)

17 ProgramCompiler._visitStatement (package:dev_compiler/src/kernel/compiler.dart:3611:20)

18 MappedListIterable.elementAt (dart:_internal/iterable.dart:412:31)

19 ListIterator.moveNext (dart:_internal/iterable.dart:341:26)

20 new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:188:27)

21 new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)

22 new List.of (dart:core-patch/array_patch.dart:50:28)

23 ListIterable.toList (dart:_internal/iterable.dart:212:44)

24 ProgramCompiler.visitBlock (package:dev_compiler/src/kernel/compiler.dart:3799:62)

25 Block.accept (package:kernel/ast.dart:8518:43)

26 ProgramCompiler._visitStatement (package:dev_compiler/src/kernel/compiler.dart:3611:20)

27 ProgramCompiler._emitFunctionScopedBody (package:dev_compiler/src/kernel/compiler.dart:3644:18)

28 ProgramCompiler._emitSyncFunctionBody. (package:dev_compiler/src/kernel/compiler.dart:3415:17)

29 ProgramCompiler._withLetScope (package:dev_compiler/src/kernel/compiler.dart:2266:25)

30 ProgramCompiler._withCurrentFunction (package:dev_compiler/src/kernel/compiler.dart:3449:18)

31 ProgramCompiler._emitSyncFunctionBody (package:dev_compiler/src/kernel/compiler.dart:3411:17)

32 ProgramCompiler._emitFunction (package:dev_compiler/src/kernel/compiler.dart:3228:11)

33 ProgramCompiler._emitLibraryFunction (package:dev_compiler/src/kernel/compiler.dart:2628:14)

34 MappedIterator.moveNext (dart:_internal/iterable.dart:390:20)

35 new _GrowableList._ofOther (dart:core-patch/growable_array.dart:198:26)

36 new _GrowableList.of (dart:core-patch/growable_array.dart:152:26)

37 new List.of (dart:core-patch/array_patch.dart:50:28)

38 Iterable.toList (dart:core/iterable.dart:366:12)

39 ProgramCompiler._emitLibraryProcedures (package:dev_compiler/src/kernel/compiler.dart:2594:10)

40 ProgramCompiler._emitLibrary (package:dev_compiler/src/kernel/compiler.dart:542:7)

41 List.forEach (dart:core-patch/growable_array.dart)

42 ProgramCompiler.emitModule (package:dev_compiler/src/kernel/compiler.dart:401:15)

43 JavaScriptBundler.compile (package:frontend_server/src/javascript_bundle.dart:146:33)

#44 FrontendCompiler.writeJavascriptBundle (package:frontend_server/frontend_server.dart:638:32) #45 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:549:9) #46 listenAndCompile. (package:frontend_server/frontend_server.dart:1119:11) the Dart compiler exited unexpectedly. `
matthewtsmith commented 3 years ago

The flutter team has released a fix for this that is available on the master flutter branch. I was able to successfully run this in flutter web on the master branch. Hopefully we'll see this show up in beta soon.

cthurston commented 3 years ago

Switched to flutter master channel. Upgraded flutter. Was able to build and run web, so one thing fixed. However, when I receive a data response from the graphql server this happens (Which is also dealing with growable_array, but not the same nullability issue.):

Unhandled exception:
RangeError (index): Invalid value: Only valid value is 0: 1
#0      List.[] (dart:core-patch/growable_array.dart:254:60)
#1      listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1269:27)
#2      listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1120:15)
#3      _RootZone.runUnaryGuarded (dart:async/zone.dart:1620:10)

#4      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#5      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#6      _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
#7      _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
#8      _StringAdapterSink.add (dart:convert/string_conversion.dart:238:11)
#9      _LineSplitterSink._addLines (dart:convert/line_splitter.dart:151:13)
#10     _LineSplitterSink.addSlice (dart:convert/line_splitter.dart:126:5)
#11     StringConversionSinkMixin.add (dart:convert/string_conversion.dart:163:5)
#12     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
#13     _RootZone.runUnaryGuarded (dart:async/zone.dart:1620:10)
#14     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#15     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#16     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)

#17     _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
#18     _StringAdapterSink.add (dart:convert/string_conversion.dart:238:11)
#19     _StringAdapterSink.addSlice (dart:convert/string_conversion.dart:243:7)
#20     _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:317:20)
#21     _Utf8ConversionSink.add (dart:convert/string_conversion.dart:310:5)
#22     _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:72:18)
#23     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
#24     _RootZone.runUnaryGuarded (dart:async/zone.dart:1620:10)
#25     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#26     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#27     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
#28     _StreamController._add (dart:async/stream_controller.dart:607:7)
#29     _StreamController.add (dart:async/stream_controller.dart:554:5)
#30     _Socket._onData (dart:io-patch/socket_patch.dart:2165:41)
#31     _RootZone.runUnaryGuarded (dart:async/zone.dart:1620:10)
#32     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#33     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)

#34     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
#35     _StreamController._add (dart:async/stream_controller.dart:607:7)
#36     _StreamController.add (dart:async/stream_controller.dart:554:5)
#37     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1701:33)
#38     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1213:14)
#39     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#40     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#41     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:120:13)
#42     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)

the Dart compiler exited unexpectedly.
Bwolfs2 commented 2 years ago

This was working in the lastast version. If the problem persist with newrest version, pleas reopen the issue and provide a testable sample.