"No getter for 'focusAction'." exception in Dart - dart

I'm trying to bind a Polymer paper input element to an Angular variable but I get this exception:
No getter for 'focusAction'.
STACKTRACE:
#0 StaticClosureMap.lookupGetter (package:angular/core/parser/static_closure_map.dart:15:25)
#1 DynamicParserBackend.newAccessScope (package:angular/core/parser/dynamic_parser.dart:112:38)
#2 DynamicParserImpl.parseAccessOrCallScope (package:angular/core/parser/dynamic_parser_impl.dart:257:67)
#3 DynamicParserImpl.parsePrimary (package:angular/core/parser/dynamic_parser_impl.dart:239:36)
#4 DynamicParserImpl.parseAccessOrCallMember (package:angular/core/parser/dynamic_parser_impl.dart:193:30)
#5 DynamicParserImpl.parsePrefix (package:angular/core/parser/dynamic_parser_impl.dart:188:37)
#6 DynamicParserImpl.parseMultiplicative (package:angular/core/parser/dynamic_parser_impl.dart:163:29)
#7 DynamicParserImpl.parseAdditive (package:angular/core/parser/dynamic_parser_impl.dart:149:37)
#8 DynamicParserImpl.parseRelational (package:angular/core/parser/dynamic_parser_impl.dart:131:31)
#9 DynamicParserImpl.parseEquality (package:angular/core/parser/dynamic_parser_impl.dart:117:33)
#10 DynamicParserImpl.parseLogicalAnd (package:angular/core/parser/dynamic_parser_impl.dart:108:31)
#11 DynamicParserImpl.parseLogicalOr (package:angular/core/parser/dynamic_parser_impl.dart:99:33)
#12 DynamicParserImpl.parseConditional (package:angular/core/parser/dynamic_parser_impl.dart:83:32)
#13 DynamicParserImpl.parseExpression (package:angular/core/parser/dynamic_parser_impl.dart:68:34)
#14 DynamicParserImpl.parseFormatter (package:angular/core/parser/dynamic_parser_impl.dart:53:33)
#15 DynamicParserImpl.parsePrimary (package:angular/core/parser/dynamic_parser_impl.dart:220:34)
#16 DynamicParserImpl.parseAccessOrCallMember (package:angular/core/parser/dynamic_parser_impl.dart:193:30)
#17 DynamicParserImpl.parsePrefix (package:angular/core/parser/dynamic_parser_impl.dart:188:37)
#18 DynamicParserImpl.parseMultiplicative (package:angular/core/parser/dynamic_parser_impl.dart:163:29)
#19 DynamicParserImpl.parseAdditive (package:angular/core/parser/dynamic_parser_impl.dart:149:37)
#20 DynamicParserImpl.parseRelational (package:angular/core/parser/dynamic_parser_impl.dart:131:31)
#21 DynamicParserImpl.parseEquality (package:angular/core/parser/dynamic_parser_impl.dart:117:33)
#22 DynamicParserImpl.parseLogicalAnd (package:angular/core/parser/dynamic_parser_impl.dart:108:31)
#23 DynamicParserImpl.parseLogicalOr (package:angular/core/parser/dynamic_parser_impl.dart:99:33)
#24 DynamicParserImpl.parseConditional (package:angular/core/parser/dynamic_parser_impl.dart:83:32)
#25 DynamicParserImpl.parseExpression (package:angular/core/parser/dynamic_parser_impl.dart:68:34)
#26 DynamicParserImpl.parseFormatter (package:angular/core/parser/dynamic_parser_impl.dart:53:33)
#27 DynamicParserImpl.parseChain (package:angular/core/parser/dynamic_parser_impl.dart:35:32)
#28 DynamicParser._parse (package:angular/core/parser/dynamic_parser.dart:40:46)
#29 DynamicParser.call.<anonymous closure> (package:angular/core/parser/dynamic_parser.dart:35:50)
#30 _HashMap.putIfAbsent (dart:collection-patch/collection_patch.dart:124)
#31 DynamicParser.call (package:angular/core/parser/dynamic_parser.dart:35:30)
#32 ASTParser.call (package:angular/change_detection/ast_parser.dart:33:22)
#33 DirectiveSelector.matchElement.<anonymous closure>.<anonymous closure> (package:angular/core_dom/selector.dart:109:38)
#34 List.forEach (dart:core-patch/growable_array.dart:228)
#35 DirectiveSelector.matchElement.<anonymous closure> (package:angular/core_dom/selector.dart:106:55)
#36 _AttributeMap.forEach (dart:html:33642)
#37 DirectiveSelector.matchElement (package:angular/core_dom/selector.dart:90:31)
#38 Compiler._elementBinderForNode (package:angular/core_dom/compiler.dart:39:43)
#39 Compiler._compileView (package:angular/core_dom/compiler.dart:129:32)
#40 Compiler._compileNode (package:angular/core_dom/compiler.dart:85:23)
#41 Compiler._compileView (package:angular/core_dom/compiler.dart:128:19)
#42 Compiler._compileNode (package:angular/core_dom/compiler.dart:85:23)
#43 Compiler._compileView (package:angular/core_dom/compiler.dart:128:19)
#44 Compiler.call (package:angular/core_dom/compiler.dart:16:17)
#45 Application.run.<anonymous closure>.<anonymous closure> (package:angular/application.dart:191:47)
#46 _rootRunUnary (dart:async/zone.dart:836)
#47 _ZoneDelegate.runUnary (dart:async/zone.dart:466)
#48 _onRunUnary.<anonymous closure> (package:angular/core/zone.dart:117:63)
#49 VmTurnZone._onRunBase (package:angular/core/zone.dart:99:16)
#50 _onRunUnary (package:angular/core/zone.dart:117:17)
#51 _CustomZone.runUnary (dart:async/zone.dart:748)
#52 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:488)
#53 _Future._propagateToListeners (dart:async/future_impl.dart:571)
#54 _Future._completeWithValue (dart:async/future_impl.dart:331)
#55 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:393)
#56 _rootRun (dart:async/zone.dart:829)
#57 _ZoneDelegate.run (dart:async/zone.dart:459)
#58 _onScheduleMicrotask.<anonymous closure> (package:angular/core/zone.dart:122:45)
#59 VmTurnZone._finishTurn (package:angular/core/zone.dart:152:34)
#60 VmTurnZone._onRunBase (package:angular/core/zone.dart:106:43)
#61 _onRun (package:angular/core/zone.dart:113:17)
#62 _CustomZone.run (dart:async/zone.dart:740)
#63 VmTurnZone.run (package:angular/core/zone.dart:241:40)
#64 Application.run (package:angular/application.dart:180:22)
#65 main.<anonymous closure> (http://localhost:8080/angularpaper.dart:16:190)
#66 _RootZone.run (dart:async/zone.dart:1077)
#67 main (http://localhost:8080/angularpaper.dart:15:7)
The HTML page:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Angular paper elements binding</title>
<link rel="import" href="packages/polymer/polymer.html">
<link rel="import" href="packages/paper_elements/paper_input.html">
<link rel="stylesheet" href="angularpaper.css">
</head>
<body>
<h1>Angular paper elements binding</h1>
<p>
<label>
Change the value through an ng-model bound input box:
<input type="text" ng-model="curValue">
</label>
<paper-input label="Paper element" bind-value="curValue"></paper-input>
</p>
<script async type="application/dart" src="angularpaper.dart"></script>
<script async src="packages/browser/dart.js"></script>
</body>
</html>
The Dart code:
import 'package:polymer/polymer.dart';
import 'package:angular/application_factory.dart';
// HACK until we fix code gen size. This doesn't really fix it,
// just makes it better.
#MirrorsUsed(override: '*')
import 'dart:mirrors';
void main() {
initPolymer()
.run(() {
applicationFactory().run();
})
;
}
The Yaml file:
name: angularpaper
description: A angular paper elements binding example
dependencies:
angular: 0.14.0
polymer: 0.14.0
paper_elements: 0.2.0
browser: any
dependency_overrides:
args: '>=0.11.0 <0.13.0'
code_transformers: '>=0.2.3 <0.3.0'
html5lib: '>=0.12.0 <0.13.0'
transformers:
- angular
- polymer:
entry_points: web/angularpaper.html

Related

Concurrent modification during iteration while trying to remove object from a list

Am trying to loop in multiple lists and finally comparing their names and delete it from a list if they don't match ...
but am getting this error:
Concurrent modification during iteration:
although i have took a copy of the original list just to avoid this error .. but still am getting it .. what i tried is:
globals.filteredPollsList = pollsList;
pollsList.forEach( (p) {
for (var e in entitiesList) {
print(e.name);
for (var entity in entitiesFilter) {
print(entity);
print(e.name);
if (e.name != entity && p.entityId != e.id) {
print('true');
globals.filteredPollsList.remove(p);
}
}
}
});
but am getting this error:
flutter: ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
flutter: The following ConcurrentModificationError was thrown while handling a gesture:
flutter: Concurrent modification during iteration: Instance(length:8) of '_GrowableList'.
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 List.forEach (dart:core/runtime/libgrowable_array.dart:279:36)
flutter: #1 _ShapedWidgetState.filterPoll (package:moi_polls_app/pages/home.page.dart:1484:15)
flutter: #2 _ShapedWidgetState.build.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:moi_polls_app/pages/home.page.dart:1896:45)
flutter: #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
flutter: #4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
flutter: #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
flutter: #6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
flutter: #7 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
flutter: #8 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
flutter: #9 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
flutter: #10 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
flutter: #11 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:180:19)
flutter: #12 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
flutter: #13 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
flutter: #14 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
flutter: #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
flutter: #16 _invoke1 (dart:ui/hooks.dart:168:13)
flutter: #17 _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)
flutter:
flutter: Handler: onTap
flutter: Recognizer:
flutter: TapGestureRecognizer#e99b3(debugOwner: GestureDetector, state: possible, won arena, finalPosition:
flutter: Offset(283.3, 608.7), sent tap down)
how to solve this?
If you want to copy your list use this:
globals.filteredPollsList = List.from(pollsList);

Getting a configuration engine error when trying hot restart in flutter application

I'm learning streams/bloc pattern in dart/flutter and can't pinpoint where the error is coming from when I try to run my app. I assume the stream is getting hung up somewhere judging by the async errors. I am usingdispose() and closing out the streams inside it. Any help would be appreciated.
Here is the code. I put it all in one big chunk but commented which file each of the code chunks is from:
// bloc.dart
import 'dart:async';
import 'validators.dart';
class Bloc extends Validators {
final _email = new StreamController<String>();
final _password = new StreamController<String>();
// Add data to stream
Stream<String> get email => _email.stream.transform(validateEmail);
Stream<String> get password => _password.stream.transform(validatePassword);
// Change Data
Function(String) get changeEmail => _email.sink.add;
Function(String) get changePassword => _password.sink.add;
dispose() {
_email.close();
_password.close();
}
}
final bloc = Bloc();
// login_screen.dart
import 'package:flutter/material.dart';
import '../blocs/bloc.dart';
class LoginScreen extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.all(20.0),
child: Column(
children: [
emailField(),
passwordField(),
Container(
margin: EdgeInsets.only(top: 25.0),
),
raisedButton()
],
));
}
Widget emailField() {
return StreamBuilder(
stream: bloc.email,
builder: (context, snapshot) {
return TextField(
onChanged: bloc.changeEmail,
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
hintText: 'ardon#exampl.com',
labelText: 'Enter your email!',
errorText: snapshot.error),
);
});
}
Widget passwordField() {
return TextField(
obscureText: true,
decoration: InputDecoration(hintText: 'password', labelText: 'password'),
);
}
Widget raisedButton() {
return RaisedButton(
child: Text('Login'),
color: Colors.blue,
onPressed: () {},
);
}
}
// validation.dart
import 'dart:async';
class Validators {
final validateEmail =
StreamTransformer<String, String>.fromHandlers(handleData: (email, sink) {
if (email.contains('#')) {
sink.add(email);
} else {
sink.addError('Please enter valid email');
}
});
final validatePassword = StreamTransformer<String, String>.fromHandlers(
handleData: (password, sink) {
if (password.length > 4) {
sink.add(password);
} else {
sink.addError('Please enter the right number of characters');
}
});
}
Here is the error I am getting when I try to hot restart my app:
⣯[VERBOSE-2:shell.cc(181)] Dart Error: Can't load Kernel binary: Invalid kernel binary format version.
[VERBOSE-2:engine.cc(158)] Could not prepare to run the isolate.
[VERBOSE-2:engine.cc(117)] Engine not prepare and launch isolate.
Error -32000 received from application: Could not run configuration in engine.
JSON-RPC error -32000: Could not run configuration in engine.
package:json_rpc_2/src/client.dart 110:64 Client.sendRequest
package:json_rpc_2/src/peer.dart 68:15 Peer.sendRequest
package:flutter_tools/src/vmservice.dart 293:13 VMService._sendRequest
package:flutter_tools/src/vmservice.dart 842:12 VM.invokeRpcRaw
===== asynchronous gap ===========================
package:flutter_tools/src/vmservice.dart 865:49 VM.invokeRpc
===== asynchronous gap ===========================
package:flutter_tools/src/vmservice.dart 932:12 VM.runInView
package:flutter_tools/src/vmservice.dart 1439:20 FlutterView.runFromSource
===== asynchronous gap ===========================
package:flutter_tools/src/run_hot.dart 379:18 HotRunner._launchInView
===== asynchronous gap ===========================
package:flutter_tools/src/run_hot.dart 390:13 HotRunner._launchFromDevFS
===== asynchronous gap ===========================
package:flutter_tools/src/run_hot.dart 442:11 HotRunner._restartFromSources
===== asynchronous gap ===========================
package:flutter_tools/src/run_hot.dart 505:15 HotRunner.restart
===== asynchronous gap ===========================
package:flutter_tools/src/run_hot.dart 282:44 HotRunner.handleTerminalCommand
===== asynchronous gap ===========================
package:flutter_tools/src/resident_runner.dart 754:15 ResidentRunner.processTerminalInput
===== asynchronous gap ===========================
dart:async/zone.dart 1132:38 _rootRunUnary
dart:async/zone.dart 1029:19 _CustomZone.runUnary
dart:async/zone.dart 931:7 _CustomZone.runUnaryGuarded
dart:async/stream_impl.dart 336:11 _BufferingStreamSubscription._sendData
dart:async/stream_impl.dart 263:7 _BufferingStreamSubscription._add
dart:async/broadcast_stream_controller.dart 379:20 _SyncBroadcastStreamController._sendData
dart:async/broadcast_stream_controller.dart 254:5 _BroadcastStreamController.add
dart:async/broadcast_stream_controller.dart 480:11 _AsBroadcastStreamController.add
dart:async/zone.dart 1132:38 _rootRunUnary
dart:async/zone.dart 1029:19 _CustomZone.runUnary
dart:async/zone.dart 931:7 _CustomZone.runUnaryGuarded
dart:async/stream_impl.dart 336:11 _BufferingStreamSubscription._sendData
dart:async/stream_impl.dart 263:7 _BufferingStreamSubscription._add
dart:async/stream_transformers.dart 68:11 _SinkTransformerStreamSubscription._add
dart:async/stream_transformers.dart 15:11 _EventSinkWrapper.add
dart:convert/string_conversion.dart 268:11 _StringAdapterSink.add
dart:convert/string_conversion.dart 273:7 _StringAdapterSink.addSlice
dart:convert/string_conversion.dart 348:20 _Utf8ConversionSink.addSlice
dart:convert/ascii.dart 278:17 _ErrorHandlingAsciiDecoderSink.addSlice
dart:convert/ascii.dart 264:5 _ErrorHandlingAsciiDecoderSink.add
dart:convert/chunked_conversion.dart 86:18 _ConverterStreamEventSink.add
dart:async/stream_transformers.dart 120:24 _SinkTransformerStreamSubscription._handleData
dart:async/zone.dart 1132:38 _rootRunUnary
dart:async/zone.dart 1029:19 _CustomZone.runUnary
dart:async/zone.dart 931:7 _CustomZone.runUnaryGuarded
dart:async/stream_impl.dart 336:11 _BufferingStreamSubscription._sendData
dart:async/stream_impl.dart 263:7 _BufferingStreamSubscription._add
dart:async/stream_controller.dart 763:19 _SyncStreamController._sendData
dart:async/stream_controller.dart 639:7 _StreamController._add
dart:async/stream_controller.dart 585:5 _StreamController.add
dart:io/runtime/binsocket_patch.dart 1714:41 _Socket._onData
dart:async/zone.dart 1136:13 _rootRunUnary
dart:async/zone.dart 1029:19 _CustomZone.runUnary
dart:async/zone.dart 931:7 _CustomZone.runUnaryGuarded
dart:async/stream_impl.dart 336:11 _BufferingStreamSubscription._sendData
dart:async/stream_impl.dart 263:7 _BufferingStreamSubscription._add
dart:async/stream_controller.dart 763:19 _SyncStreamController._sendData
dart:async/stream_controller.dart 639:7 _StreamController._add
dart:async/stream_controller.dart 585:5 _StreamController.add
dart:io/runtime/binsocket_patch.dart 1276:33 new _RawSocket.<fn>
dart:io/runtime/binsocket_patch.dart 819:14 _NativeSocket.issueReadEvent.issue
dart:async/schedule_microtask.dart 41:21 _microtaskLoop
dart:async/schedule_microtask.dart 50:5 _startMicrotaskLoop
dart:isolate/runtime/libisolate_patch.dart 115:13 _runPendingImmediateCallback
dart:isolate/runtime/libisolate_patch.dart 172:5 _RawReceivePortImpl._handleMessage
edit: When I do a hot reload instead of a hot restart, I get this error:
Initializing hot reload... ⣟Hot reload failed: type 'TimeoutException' is not a subtype of type 'Map<String, dynamic>'
#0 HotRunner._reloadSources.<anonymous closure> (package:flutter_tools/src/run_hot.dart:587:45)
#1 _rootRunUnary (dart:async/zone.dart:1132:38)
#2 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#3 _FutureListener.handleError (dart:async/future_impl.dart:147:20)
#4 Future._propagateToListeners.handleError (dart:async/future_impl.dart:654:47)
#5 Future._propagateToListeners (dart:async/future_impl.dart:675:24)
#6 Future._completeError (dart:async/future_impl.dart:494:5)
#7 Future.wait.handleError (dart:async/future.dart:379:18)
#8 _rootRunBinary (dart:async/zone.dart:1144:38)
#9 _CustomZone.runBinary (dart:async/zone.dart:1037:19)
#10 _FutureListener.handleError (dart:async/future_impl.dart:143:20)
#11 Future._propagateToListeners.handleError (dart:async/future_impl.dart:654:47)
#12 Future._propagateToListeners (dart:async/future_impl.dart:675:24)
#13 Future._completeError (dart:async/future_impl.dart:494:5)
#14 _SyncCompleter._completeError (dart:async/future_impl.dart:55:12)
#15 _Completer.completeError (dart:async/future_impl.dart:27:5)
#16 _AsyncAwaitCompleter.completeError (dart:async/runtime/libasync_patch.dart:40:18)
#17 Isolate.reloadSources (package:flutter_tools/src/vmservice.dart)
<asynchronous suspension>
#18 FlutterDevice.reloadSources (package:flutter_tools/src/resident_runner.dart:144:66)
#19 HotRunner._reloadSources (package:flutter_tools/src/run_hot.dart:579:67)
<asynchronous suspension>
#20 HotRunner.restart (package:flutter_tools/src/run_hot.dart:520:24)
<asynchronous suspension>
#21 HotRunner.handleTerminalCommand (package:flutter_tools/src/run_hot.dart:282:44)
<asynchronous suspension>
#22 ResidentRunner.processTerminalInput (package:flutter_tools/src/resident_runner.dart:754:15)
<asynchronous suspension>
#23 _rootRunUnary (dart:async/zone.dart:1132:38)
#24 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#25 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#26 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#27 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#28 _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:379:20)
#29 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:254:5)
#30 _AsBroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:480:11)
#31 _rootRunUnary (dart:async/zone.dart:1132:38)
#32 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#33 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#34 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#35 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#36 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
#37 _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#38 _StringAdapterSink.add (dart:convert/string_conversion.dart:268:11)
#39 _StringAdapterSink.addSlice (dart:convert/string_conversion.dart:273:7)
#40 _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:348:20)
#41 _ErrorHandlingAsciiDecoderSink.addSlice (dart:convert/ascii.dart:278:17)
#42 _ErrorHandlingAsciiDecoderSink.add (dart:convert/ascii.dart:264:5)
#43 _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:86:18)
#44 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
#45 _rootRunUnary (dart:async/zone.dart:1132:38)
#46 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#47 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#48 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#49 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#50 _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#51 _StreamController._add (dart:async/stream_controller.dart:639:7)
#52 _StreamController.add (dart:async/stream_controller.dart:585:5)
#53 _Socket._onData (dart:io/runtime/binsocket_patch.dart:1714:41)
#54 _rootRunUnary (dart:async/zone.dart:1136:13)
#55 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#56 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#57 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#58 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#59 _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
#60 _StreamController._add (dart:async/stream_controller.dart:639:7)
#61 _StreamController.add (dart:async/stream_controller.dart:585:5)
#62 new _RawSocket.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:1276:33)
#63 _NativeSocket.issueReadEvent.issue (dart:io/runtime/binsocket_patch.dart:819:14)
#64 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#65 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#66 _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#67 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)
A case where you'll frequently run into this is if you're building your own engine from source, and using it via flutter's --local-engine option.
Dart code in a Flutter app is initially compiled through the Dart kernel compiler, which emits a .dill file in an intermediate format. This intermediate format includes an identifier that the Dart VM in the Flutter engine uses to validate that it's compatible with that VM version. The root cause of an Invalid kernel binary format version error message is that the .dill file in question was generated with an incompatible version of the kernel compiler.
To resolve this, after rebuilding the engine for your device (e.g. android_debug_unopt), you'll want to ensure that you've also rebuilt the associated host toolchain (e.g. host_debug_unopt).
If you're seeing this in other cases, it's almost certainly a bug, and I'd definitely encourage you to open an issue against Flutter.
There was a bug fixed very recently that resulted in this error message https://github.com/flutter/flutter/issues/21348
I would expect this to be included in the latest Flutter dev and master channel.
To switch to the dev channel use
flutter channel dev
flutter doctor
update
(from https://github.com/flutter/flutter/issues/22964#issuecomment-429071970)
import './src/app.dart'; in lib/main.dart is the culprit.
lib/main.dart must not contain relative imports and must not be imported from other files
https://github.com/dart-lang/sdk#33076
was just fixed but it will take a while until it lands in Flutter.

json.decode throws FormatException on nested double quote in json - dart

Below code snippet throws Format Exception in Flutter json decode, Any suggestion please?
import 'dart:async' show Future;
import 'dart:convert';
Future<String> readBooks() async {
String jsonString = '{"description":"As part of the "You Don’t Know JS" series","quantity":55}';
Map<String, dynamic> books = json.decode(jsonString);
return jsonString;
}
Format Exception:
2018-10-23 20:40:30.680 18115-18142/addon.com.bookshop E/flutter:
[ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled
exception:
FormatException: Unexpected character (at character 26)
{"name":"As part of the "You Don’t Know JS" series","Age":55}
^
#0 _ChunkedJsonParser.fail (dart:convert/runtime/libconvert_patch.dart:1358:5)
#1 _ChunkedJsonParser.parse (dart:convert/runtime/libconvert_patch.dart:919:48)
#2 _parseJson (dart:convert/runtime/libconvert_patch.dart:29:10)
#3 JsonDecoder.convert (dart:convert/json.dart:540:36)
#4 JsonCodec.decode (dart:convert/json.dart:167:41)
#5 _MyHomePageState.readBooks (file:///E:/Me/TimePass/flutter/book_shop/lib/main.dart:58:39)
<asynchronous suspension>
#6 _MyHomePageState.build.<anonymous closure> (file:///E:/Me/TimePass/flutter/book_shop/lib/main.dart:48:39)
<asynchronous suspension>
#7 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:503:14)
#8 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:558:30)
#9 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
#10 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
#11 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
#12 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
#13 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
#14 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
#15 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19)
#16 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
#17 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
#18 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue
(package:flutter/src/gestures/binding.dart:64:7)
#19 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket
(package:flutter/src/gestures/binding.dart:48:7)
#20 _invoke1 (dart:ui/hooks.dart:142:13)
#21 _dispatchPointerDataPacket (dart:ui/hooks.dart:99:5)
That's just invalid JSON.
The inner quotes need to be escaped as \" to make your JSON valid.

type '(PlatformException) => void' is not a subtype of type '(Object) => FutureOr<dynamic> Flutter

I am using Event Channels in Flutter to return beacon data from Native SDK to Flutter. This was working fine until a recent Flutter upgrade.Now, I am getting the following error.
type '(PlatformException) => void' is not a subtype of type '(Object) => FutureOr<dynamic>
with the following stack trace:
#0 _registerErrorHandler (dart:async/async_error.dart:22:60)
#1 _BufferingStreamSubscription.onError (dart:async/stream_impl.dart:146:16)
#2 new _BufferingStreamSubscription (dart:async/stream_impl.dart:113:10)
#3 new _ControllerSubscription (dart:async/stream_controller.dart)
#4 new _BroadcastSubscription (dart:async/broadcast_stream_controller.dart)
#5 _BroadcastStreamController._subscribe (dart:async/broadcast_stream_controller.dart:212:46)
#6 _ControllerStream._createSubscription (dart:async/stream_controller.dart:817:19)
#7 _StreamImpl.listen (dart:async/stream_impl.dart:466:9)
#8 _MyHomePageState.initPlatformState.<anonymous closure>.<anonymous closure> (file:///Users/chaythanyanair/Documents/Qburst/Learn/flutter_poc/lib/main.dart:95:43)
#9 _RootZone.runUnary (dart:async/zone.dart:1381:54)
#10 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#11 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633:45)
#12 Future._propagateToListeners (dart:async/future_impl.dart:662:32)
#13 Future._complete (dart:async/future_impl.dart:467:7)
#14 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#15 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart)
<asynchronous suspension>
#16 _MyHomePageState.initPlatformState.<anonymous closure> (file:///Users/chaythanyanair/Documents/Qburst/Learn/flutter_poc/lib/main.dart:89:24)
<asynchronous suspension>
#17 _RootZone.runUnary (dart:async/zone.dart:1381:54)
#18 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#19 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633:45)
#20 Future._propagateToListeners (dart:async/future_impl.dart:662:32)
#21 Future._complete (dart:async/future_impl.dart:467:7)
#22 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#23 User_Profile.getUser (package:flutter_poc/Models/User.dart)
<asynchronous suspension>
#24 _MyHomePageState.initPlatformState (file:///Users/chaythanyanair/Documents/Qburst/Learn/flutter_poc/lib/main.dart:69:24)
<asynchronous suspension>
#25 _MyHomePageState.initState (file:///Users/chaythanyanair/Documents/Qburst/Learn/flutter_poc/lib/main.dart:52:5)
#26 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3734:58)
#27 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
#28 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
#29 Element.updateChild
This is my EventChannel implementation:
static const platform = const MethodChannel('samples.flutter.io/initialiseRanging');
static const stream =
const EventChannel('samples.flutter.io/ranging');
try {
await platform.invokeMethod('initialiseRanging').then((result){
print(result);
setState(() {
_currentValue = result;
});
stream.receiveBroadcastStream().listen(_onEvent, onError: _onError);
});
} on PlatformException catch (e) {
print( "{e.message}");
}
This is how the _onEvent and _onError functions are implemented.
void _onEvent(Object event) {
setState(() {
_currentValue = event.toString();
});
print(event);
}
void _onError(PlatformException error) {
print(error);
}
Any idea on why this could possible happen?
void _onError(PlatformException error) {
should be
void _onError(Object error) {
Even when you are only interested in PlatformException or even when this is the only exception that happened so far, doesn't mean there can't be others. The expected handler function needs to match the parameter type, instead of only the exceptions you expect.

dart upload file error: FormatException: Bad UTF-8 encoding 0xbf

Here is my server side dart code:
import 'dart:io';
import 'package:http_server/http_server.dart';
void main() {
HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, 8080).then((server) {
server.listen((HttpRequest request) {
if (request.method.toLowerCase() == 'post' && request.uri.path == '/upload') {
HttpBodyHandler.processRequest(request).then((body) {
HttpBodyFileUpload fileUpload = body.body['file'];
File file = new File('aaa');
file.writeAsBytes(fileUpload.content, mode: FileMode.WRITE).then((_) {
request.response.close();
});
});
}
});
});
}
and my error is:
Unhandled exception:
Uncaught Error: FormatException: Bad UTF-8 encoding 0xbf
Stack Trace:
#0 _Utf8Decoder.convert (dart:convert/utf.dart:534)
#1 _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:334)
#2 _Utf8ConversionSink.add (dart:convert/string_conversion.dart:330)
#3 _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:89)
#4 _handleData (dart:async/stream_transformers.dart:119)
#5 _RootZone.runUnaryGuarded (dart:async/zone.dart:1020)
#6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341)
#7 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:270)
#8 _StreamController&&_SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:578)
#9 _StreamController._add (dart:async/stream_controller.dart:453)
#10 _StreamController.add (dart:async/stream_controller.dart:410)
#11 BoundMultipartStream._parse.reportData (package:mime/src/bound_multipart_stream.dart:161:34)
#12 BoundMultipartStream._parse (package:mime/src/bound_multipart_stream.dart:318:28)
#13 BoundMultipartStream.BoundMultipartStream.<anonymous closure>.<anonymous closure> (package:mime/src/bound_multipart_stream.dart:111:24)
#14 _RootZone.runUnaryGuarded (dart:async/zone.dart:1020)
#15 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341)
#16 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:270)
#17 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:122)
#18 _ForwardingStream._handleData (dart:async/stream_pipe.dart:86)
#19 _handleData (dart:async/stream_pipe.dart:154)
#20 _RootZone.runUnaryGuarded (dart:async/zone.dart:1020)
#21 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341)
#22 _DelayedData.perform (dart:async/stream_impl.dart:595)
#23 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:711)
#24 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:671)
#25 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#26 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#27 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:126)
#0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:820)
#1 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#2 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#3 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:126)
Process finished with exit code 255
I used postman to make a post, I chose form-data and add a key called file, value is a txt file.
after send my post to dart server, i got this exception.
is there something wrong with the post ? or the dart code ?
I'm really new to dart, please help me out...
thank you.

Resources