Flutter : Mongo Dart Plugin is not working - dart

i want to use mongo to store my app data, but when ever i try to await db.open() this error appear on the console:
[ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (11408): type 'Future<dynamic>' is not a subtype of type 'Future<bool>' where
E/flutter (11408): Future is from dart:async
E/flutter (11408): Future is from dart:async
E/flutter (11408): bool is from dart:core
E/flutter (11408):
E/flutter (11408): #0 _Connection.connect (file:///C:/Users/Picmix/flutter/.pub-cache/hosted/pub.dartlang.org/mongo_dart-0.3.1/lib/src/network/connection.dart:73:22)
E/flutter (11408): #1 _ConnectionManager._connect (file:///C:/Users/Picmix/flutter/.pub-cache/hosted/pub.dartlang.org/mongo_dart-0.3.1/lib/src/network/connection_manager.dart:23:22)
E/flutter (11408): <asynchronous suspension>
E/flutter (11408): #2 _ConnectionManager.open.<anonymous closure> (file:///C:/Users/Picmix/flutter/.pub-cache/hosted/pub.dartlang.org/mongo_dart-0.3.1/lib/src/network/connection_manager.dart:58:14)
E/flutter (11408): #3 Future.forEach.<anonymous closure> (dart:async/future.dart:484:26)
E/flutter (11408): #4 Future.doWhile.<anonymous closure> (dart:async/future.dart:526:26)
E/flutter (11408): #5 _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
E/flutter (11408): #6 _RootZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1355:26)
E/flutter (11408): #7 Future.doWhile (dart:async/future.dart:541:18)
E/flutter (11408): #8 Future.forEach (dart:async/future.dart:482:12)
E/flutter (11408): #9 _ConnectionManager.open (file:///C:/Users/Picmix/flutter/.pub-cache/hosted/pub.dartlang.org/mongo_dart-0.3.1/lib/src/network/connection_manager.dart:56:19)
E/flutter (11408): #10 Db.open.<anonymous closure> (file:///C:/Users/Picmix/flutter/.pub-cache/hosted/pub.dartlang.org/mongo_dart-0.3.1/lib/src/database/db.dart:252:33)
E/flutter (11408): #11 new Future.sync (dart:async/future.dart:222:31)
E/flutter (11408): #12 Db.open (file:///C:/Users/Picmix/flutter/.pub-cache/hosted/pub.dartlang.org/mongo_dart-0.3.1/lib/src/database/db.dart:239:16)
E/flutter (11408): #13 main (file:///F:/Jamil/WORKSHOP/MY-PRACTICE/FLUTTER/FLUTTERMONGO/simplecrud/lib/main.dart:6:6)
E/flutter (11408): <asynchronous suspension>
E/flutter (11408): #14 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:279:19)
E/flutter (11408): #15 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
E/flutter (11408): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (11408): type '(MongoReplyMessage) => void' is not a subtype of type '(dynamic) => void'
E/flutter (11408): #0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1114:29)
E/flutter (11408): #1 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (11408): #2 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
and this is the simple code that i write to open connection between mlab and the app:
import 'package:mongo_dart/mongo_dart.dart';
void main() async {
print('hello');
Db db = new Db('mongodb://<myusername><mypassword>#ds147659.mlab.com:47659/simple-crud');
db.open().then((success) {
if (success) print('connected');
});
}
any idea sir?

This is due to the latest flutter update beta2.
Please check this blog by flutter
Seems like there is a flutter version mismatch of your project and Mongo plugin.
Mongo's latest plugin was updated on Oct 24, 2017.
There is already an issue on their git. You can keep track of it.
Meanwhile, according to this issue:
you can try changing the plugin code from
Future<bool> get isOn => _channel.invokeMethod('isOn');
to
Future<bool> get isOn async {
final bool isOn = await _channel.invokeMethod('isOn');
return isOn;
}
NOTE: Above is just an example, please check the plugin dart file for the correct function to change.

Related

Not able to add audio_service package. Need guidance

I just want to add audio_service https://pub.dartlang.org/packages/audio_service#-readme-tab- to my App.
For play audio. But didn't get success.
Basically, I'm iOS developer so don't know much about android setup.
Where I have to create, MainApplication and If I try to change AndroidManifest.xml It give error message because android:name=".MainApplication". How it possible to change android:name. Flutter won't allow.
Please help me for android setup.
EDITED:
odChannel#ryanheise.com/audioService( 8223): Failed to handle method call
E/MethodChannel#ryanheise.com/audioService( 8223): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v4.media.session.MediaControllerCompat.addQueueItem(android.support.v4.media.MediaDescriptionCompat, int)' on a null object reference
E/MethodChannel#ryanheise.com/audioService( 8223): at com.ryanheise.audioservice.AudioServicePlugin$ClientHandler.onMethodCall(AudioServicePlugin.java:392)
E/MethodChannel#ryanheise.com/audioService( 8223): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:201)
E/MethodChannel#ryanheise.com/audioService( 8223): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:88)
E/MethodChannel#ryanheise.com/audioService( 8223): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:202)
E/MethodChannel#ryanheise.com/audioService( 8223): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#ryanheise.com/audioService( 8223): at android.os.MessageQueue.next(MessageQueue.java:329)
E/MethodChannel#ryanheise.com/audioService( 8223): at android.os.Looper.loop(Looper.java:142)
E/MethodChannel#ryanheise.com/audioService( 8223): at android.app.ActivityThread.main(ActivityThread.java:6375)
E/MethodChannel#ryanheise.com/audioService( 8223): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#ryanheise.com/audioService( 8223): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
E/MethodChannel#ryanheise.com/audioService( 8223): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
E/flutter ( 8223): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'void android.support.v4.media.session.MediaControllerCompat.addQueueItem(android.support.v4.media.MediaDescriptionCompat, int)' on a null object reference, null)
E/flutter ( 8223): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
E/flutter ( 8223): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:302:33)
E/flutter ( 8223): <asynchronous suspension>
E/flutter ( 8223): #2 AudioService.addQueueItemAt (package:audio_service/audio_service.dart:481:10)
E/flutter ( 8223): <asynchronous suspension>
E/flutter ( 8223): #3 _MyAppState.initializeAndroidPlayer (package:audio_player_service_example/main.dart:159:18)
E/flutter ( 8223): <asynchronous suspension>
E/flutter ( 8223): #4 _MyAppState.initState (package:audio_player_service_example/main.dart:124:5)
E/flutter ( 8223): #5 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3851:58)
E/flutter ( 8223): #6 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3716:5)
E/flutter ( 8223): #7 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #8 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #9 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4881:14)
E/flutter ( 8223): #10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #11 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #12 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3752:16)
E/flutter ( 8223): #13 Element.rebuild (package:flutter/src/widgets/framework.dart:3564:5)
E/flutter ( 8223): #14 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3721:5)
E/flutter ( 8223): #15 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3716:5)
E/flutter ( 8223): #16 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #17 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #18 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4881:14)
E/flutter ( 8223): #19 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #20 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #21 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4881:14)
E/flutter ( 8223): #22 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #23 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #24 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4881:14)
E/flutter ( 8223): #25 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #26 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #27 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4881:14)
E/flutter ( 8223): #28 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #29 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #30 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3752:16)
E/flutter ( 8223): #31 Element.rebuild (package:flutter/src/widgets/framework.dart:3564:5)
E/flutter ( 8223): #32 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3721:5)
E/flutter ( 8223): #33 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3869:11)
E/flutter ( 8223): #34 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3716:5)
E/flutter ( 8223): #35 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #36 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #37 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3752:16)
E/flutter ( 8223): #38 Element.rebuild (package:flutter/src/widgets/framework.dart:3564:5)
E/flutter ( 8223): #39 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3721:5)
E/flutter ( 8223): #40 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3716:5)
E/flutter ( 8223): #41 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #42 Element.updateChild (package:flutter/src/widgets/f
E/flutter ( 8223): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method initPlayerQueue on channel audio_player_service)
E/flutter ( 8223): #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:300:7)
E/flutter ( 8223): <asynchronous suspension>
E/flutter ( 8223): #1 AudioPlayer.initPlayerQueue (package:audio_player_service/audio_player.dart:250:19)
E/flutter ( 8223): <asynchronous suspension>
E/flutter ( 8223): #2 _MyAppState.initPlayer (package:audio_player_service_example/main.dart:148:23)
E/flutter ( 8223): <asynchronous suspension>
E/flutter ( 8223): #3 _MyAppState.initState (package:audio_player_service_example/main.dart:126:5)
E/flutter ( 8223): #4 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3851:58)
E/flutter ( 8223): #5 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3716:5)
E/flutter ( 8223): #6 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #7 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #8 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4881:14)
E/flutter ( 8223): #9 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #10 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #11 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3752:16)
E/flutter ( 8223): #12 Element.rebuild (package:flutter/src/widgets/framework.dart:3564:5)
E/flutter ( 8223): #13 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3721:5)
E/flutter ( 8223): #14 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3716:5)
E/flutter ( 8223): #15 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #16 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #17 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4881:14)
E/flutter ( 8223): #18 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #19 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #20 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4881:14)
E/flutter ( 8223): #21 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #22 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #23 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4881:14)
E/flutter ( 8223): #24 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #25 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #26 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4881:14)
E/flutter ( 8223): #27 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #28 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #29 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3752:16)
E/flutter ( 8223): #30 Element.rebuild (package:flutter/src/widgets/framework.dart:3564:5)
E/flutter ( 8223): #31 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3721:5)
E/flutter ( 8223): #32 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3869:11)
E/flutter ( 8223): #33 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3716:5)
E/flutter ( 8223): #34 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #35 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #36 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3752:16)
E/flutter ( 8223): #37 Element.rebuild (package:flutter/src/widgets/framework.dart:3564:5)
E/flutter ( 8223): #38 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3721:5)
E/flutter ( 8223): #39 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3716:5)
E/flutter ( 8223): #40 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2960:14)
E/flutter ( 8223): #41 Element.updateChild (package:flutter/src/widgets/framework.dart:2763:12)
E/flutter ( 8223): #42 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3752:16)
E/flutter ( 8223): #43 Element.rebuild (package:flutter/src/widgets/framework.dart:3564:5)
E/flutter ( 8223): #44 ComponentElement._firs
You can create MainApplication class in Android studio. Take a look at these screenshots.
Just add this right before the </application> in the AndroidManifest.xml file.
<service android:name="com.ryanheise.audioservice.AudioService">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>
<receiver android:name="android.support.v4.media.session.MediaButtonReceiver" >
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
I am attempting the same thing, and when I add the service and receiver tags to AndroidManifest.xml, I am getting an error, which might be the same problem you are having:
Class referenced in the manifest, com.ryanheise.audioservice.AudioService, was not found in the project or the libraries / Unresolved package 'audioservice'
And yes, I have audio_service as a dependency in my pubspec.yaml, and yes I did Pub Get.
I don't know why this error is happening, but I can't imagine that audio_service could run without this.

Passing data/message from flutter apps to other apps

i am trying to pass data from my flutter app to other apps. The purpose is to send the download link for my app to another app(say watsapp,facebook,twitter etc.).
I am using flutter plugin share 0.6.0+1. i added the package as instructed. But when i ran the program, the following error was displayed:
[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method share on channel plugins.flutter.io/share)
E/flutter ( 8153): #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:300:7)
E/flutter ( 8153): <asynchronous suspension>
E/flutter ( 8153): #1 Share.share (package:share/share.dart:44:20)
E/flutter ( 8153): #2 _MyHomePageState.build.<anonymous closure> (package:unit_converter/main.dart:409:34)
E/flutter ( 8153): #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:513:14)
E/flutter ( 8153): #4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:568:30)
E/flutter ( 8153): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:120:24)
E/flutter ( 8153): #6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter ( 8153): #7 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:204:7)
E/flutter ( 8153): #8 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter ( 8153): #9 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:20)
E/flutter ( 8153): #10 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:192:22)
E/flutter ( 8153): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:149:7)
E/flutter ( 8153): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
E/flutter ( 8153): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
E/flutter ( 8153): #14 _rootRunUnary (dart:async/zone.dart:1136:13)
E/flutter ( 8153): #15 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter ( 8153): #16 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter ( 8153): #17 _invoke1 (dart:ui/hooks.dart:223:10)
E/flutter ( 8153): #18 _dispatchPointerDataPacket (dart:ui/hooks.dart:144:5)
The following is the content of my pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dart2_constant: ^1.0.2+dart2
math_expressions: ^1.0.0
shared_preferences: ^0.4.3
#loader_search_bar: ^1.0.3+1
material_search: ^0.2.8
path_provider: '>=0.3.0'
sqflite: any
flutter_colorpicker: ^0.2.1
intl: ^0.15.7
auto_size_text: ^0.3.0
cloud_firestore: ^0.9.0
animated_text_kit: ^1.3.0
share: ^0.6.0+1
The following is my implementation:
Share.share('Hi, take a time to click and download this app: market://search?q=pname:com.myappbase.appname');
Please can anyone point me to what i am doing wrong. i seem to have tried ieverything but these same errors have been coming up.Or is there a more elegant way this can be done? Thanks
You must terminate the app and rerun it from scratch as share dependency required platform channel methods to be called. the app has to terminate and rerun from scratch.

webdev error when ran without pub on windows

I do AngularDart development on Windows 10. I'm getting strange behavior with webdev recently. I have to run webdev like this:
C:\Users\galankus>C:\tools\dart-sdk\bin\pub.bat global run webdev
A tool to develop Dart web projects.
Usage: webdev <command> [arguments]
Global options:
-h, --help Print this usage information.
Available commands:
build Run builders to build a package.
help Display help information for webdev.
serve Run a local web development server and a file system watcher that re-builds on changes.
Run "webdev help <command>" for more information about a command.
If I try to run it directly, the below is what I get. Any ideas on how I can debug/fix this?
C:\Users\galankus>webdev
Crash when formatting: [Encoding] Unable to decode bytes as UTF-8.
RangeError (index): Invalid value: Not in range 0..271500, inclusive: 271792
#0 _StringBase.[] (dart:core/runtime/libstring_patch.dart:233:55)
#1 Source.getTextLine (package:kernel/ast.dart:5772:42)
#2 getSourceLine (package:front_end/src/fasta/messages.dart:27:9)
#3 format (package:front_end/src/fasta/command_line_reporting.dart:80:27)
#4 ProcessedOptions.format (package:front_end/src/base/processed_options.dart:206:32)
#5 ProcessedOptions.report (package:front_end/src/base/processed_options.dart:215:22)
#6 CompilerContext.report (package:front_end/src/fasta/compiler_context.dart:67:13)
#7 Loader.addMessage (package:front_end/src/fasta/loader.dart:258:20)
#8 Loader.addCompileTimeError (package:front_end/src/fasta/loader.dart:207:5)
#9 LibraryBuilder.addCompileTimeError (package:front_end/src/fasta/builder/library_builder.dart:89:12)
#10 SourceLoader.tokenize (package:front_end/src/fasta/source/source_loader.dart:174:17)
<asynchronous suspension>
#11 SourceLoader.buildOutline (package:front_end/src/fasta/source/source_loader.dart:192:26)
<asynchronous suspension>
#12 Loader.buildOutlines (package:front_end/src/fasta/loader.dart:176:13)
<asynchronous suspension>
#13 KernelTarget.buildOutlines (package:front_end/src/fasta/kernel/kernel_target.dart:237:20)
<asynchronous suspension>
#14 IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/fasta/incremental_compiler.dart:232:24)
<asynchronous suspension>
#15 CompilerContext.runInContext.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:118:46)
#16 new Future.sync (dart:async/future.dart:222:31)
#17 CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:118:19)
#18 _rootRun (dart:async/zone.dart:1126:13)
#19 _CustomZone.run (dart:async/zone.dart:1023:19)
#20 _runZoned (dart:async/zone.dart:1518:10)
#21 runZoned (dart:async/zone.dart:1465:12)
#22 CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:117:12)
#23 IncrementalCompiler.computeDelta (package:front_end/src/fasta/incremental_compiler.dart:102:20)
<asynchronous suspension>
#24 IncrementalCompiler.compile (package:vm/incremental_compiler.dart:38:44)
<asynchronous suspension>
#25 IncrementalCompilerWrapper.compileInternal (file:///E:/b/build/slave/dart-sdk-windows-dev/build/sdk/pkg/vm/bin/kernel_service.dart:158:28)
<asynchronous suspension>
#26 Compiler.compile.<anonymous closure> (file:///E:/b/build/slave/dart-sdk-windows-dev/build/sdk/pkg/vm/bin/kernel_service.dart:132:39)
#27 new Future.<anonymous closure> (dart:async/future.dart:174:37)
#28 _rootRun (dart:async/zone.dart:1122:38)
#29 _CustomZone.run (dart:async/zone.dart:1023:19)
#30 _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#31 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
#32 _rootRun (dart:async/zone.dart:1126:13)
#33 _CustomZone.run (dart:async/zone.dart:1023:19)
#34 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949:23)
#35 Timer._createTimer.<anonymous closure> (dart:async/runtime/libtimer_patch.dart:21:15)
#36 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
#37 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
#38 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
Crash when compiling file:///C:/Users/galankus/AppData/Roaming/Pub/Cache/global_packages/webdev/bin/webdev.dart.snapshot,
at character offset 264110:
RangeError (index): Invalid value: Not in range 0..271500, inclusive: 271792
#0 _StringBase.[] (dart:core/runtime/libstring_patch.dart:233:55)
#1 Source.getTextLine (package:kernel/ast.dart:5772:42)
#2 getSourceLine (package:front_end/src/fasta/messages.dart:27:9)
#3 format (package:front_end/src/fasta/command_line_reporting.dart:80:27)
#4 ProcessedOptions.format (package:front_end/src/base/processed_options.dart:206:32)
#5 ProcessedOptions.report (package:front_end/src/base/processed_options.dart:215:22)
#6 CompilerContext.report (package:front_end/src/fasta/compiler_context.dart:67:13)
#7 Loader.addMessage (package:front_end/src/fasta/loader.dart:258:20)
#8 Loader.addCompileTimeError (package:front_end/src/fasta/loader.dart:207:5)
#9 LibraryBuilder.addCompileTimeError (package:front_end/src/fasta/builder/library_builder.dart:89:12)
#10 SourceLoader.tokenize (package:front_end/src/fasta/source/source_loader.dart:174:17)
<asynchronous suspension>
#11 SourceLoader.buildOutline (package:front_end/src/fasta/source/source_loader.dart:192:26)
<asynchronous suspension>
#12 Loader.buildOutlines (package:front_end/src/fasta/loader.dart:176:13)
<asynchronous suspension>
#13 KernelTarget.buildOutlines (package:front_end/src/fasta/kernel/kernel_target.dart:237:20)
<asynchronous suspension>
#14 IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/fasta/incremental_compiler.dart:232:24)
<asynchronous suspension>
#15 CompilerContext.runInContext.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:118:46)
#16 new Future.sync (dart:async/future.dart:222:31)
#17 CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:118:19)
#18 _rootRun (dart:async/zone.dart:1126:13)
#19 _CustomZone.run (dart:async/zone.dart:1023:19)
#20 _runZoned (dart:async/zone.dart:1518:10)
#21 runZoned (dart:async/zone.dart:1465:12)
#22 CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:117:12)
#23 IncrementalCompiler.computeDelta (package:front_end/src/fasta/incremental_compiler.dart:102:20)
<asynchronous suspension>
#24 IncrementalCompiler.compile (package:vm/incremental_compiler.dart:38:44)
<asynchronous suspension>
#25 IncrementalCompilerWrapper.compileInternal (file:///E:/b/build/slave/dart-sdk-windows-dev/build/sdk/pkg/vm/bin/kernel_service.dart:158:28)
<asynchronous suspension>
#26 Compiler.compile.<anonymous closure> (file:///E:/b/build/slave/dart-sdk-windows-dev/build/sdk/pkg/vm/bin/kernel_service.dart:132:39)
#27 new Future.<anonymous closure> (dart:async/future.dart:174:37)
#28 _rootRun (dart:async/zone.dart:1122:38)
#29 _CustomZone.run (dart:async/zone.dart:1023:19)
#30 _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#31 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
#32 _rootRun (dart:async/zone.dart:1126:13)
#33 _CustomZone.run (dart:async/zone.dart:1023:19)
#34 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949:23)
#35 Timer._createTimer.<anonymous closure> (dart:async/runtime/libtimer_patch.dart:21:15)
#36 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
#37 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
#38 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
#0 _StringBase.[] (dart:core/runtime/libstring_patch.dart:233:55)
#1 Source.getTextLine (package:kernel/ast.dart:5772:42)
#2 getSourceLine (package:front_end/src/fasta/messages.dart:27:9)
#3 format (package:front_end/src/fasta/command_line_reporting.dart:80:27)
#4 ProcessedOptions.format (package:front_end/src/base/processed_options.dart:206:32)
#5 ProcessedOptions.report (package:front_end/src/base/processed_options.dart:215:22)
#6 CompilerContext.report (package:front_end/src/fasta/compiler_context.dart:67:13)
#7 Loader.addMessage (package:front_end/src/fasta/loader.dart:258:20)
#8 Loader.addCompileTimeError (package:front_end/src/fasta/loader.dart:207:5)
#9 LibraryBuilder.addCompileTimeError (package:front_end/src/fasta/builder/library_builder.dart:89:12)
#10 SourceLoader.tokenize (package:front_end/src/fasta/source/source_loader.dart:174:17)
<asynchronous suspension>
#11 SourceLoader.buildOutline (package:front_end/src/fasta/source/source_loader.dart:192:26)
<asynchronous suspension>
#12 Loader.buildOutlines (package:front_end/src/fasta/loader.dart:176:13)
<asynchronous suspension>
#13 KernelTarget.buildOutlines (package:front_end/src/fasta/kernel/kernel_target.dart:237:20)
<asynchronous suspension>
#14 IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/fasta/incremental_compiler.dart:232:24)
<asynchronous suspension>
#15 CompilerContext.runInContext.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:118:46)
#16 new Future.sync (dart:async/future.dart:222:31)
#17 CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:118:19)
#18 _rootRun (dart:async/zone.dart:1126:13)
#19 _CustomZone.run (dart:async/zone.dart:1023:19)
#20 _runZoned (dart:async/zone.dart:1518:10)
#21 runZoned (dart:async/zone.dart:1465:12)
#22 CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:117:12)
#23 IncrementalCompiler.computeDelta (package:front_end/src/fasta/incremental_compiler.dart:102:20)
<asynchronous suspension>
#24 IncrementalCompiler.compile (package:vm/incremental_compiler.dart:38:44)
<asynchronous suspension>
#25 IncrementalCompilerWrapper.compileInternal (file:///E:/b/build/slave/dart-sdk-windows-dev/build/sdk/pkg/vm/bin/kernel_service.dart:158:28)
<asynchronous suspension>
#26 Compiler.compile.<anonymous closure> (file:///E:/b/build/slave/dart-sdk-windows-dev/build/sdk/pkg/vm/bin/kernel_service.dart:132:39)
#27 new Future.<anonymous closure> (dart:async/future.dart:174:37)
#28 _rootRun (dart:async/zone.dart:1122:38)
#29 _CustomZone.run (dart:async/zone.dart:1023:19)
#30 _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#31 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
#32 _rootRun (dart:async/zone.dart:1126:13)
#33 _CustomZone.run (dart:async/zone.dart:1023:19)
#34 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949:23)
#35 Timer._createTimer.<anonymous closure> (dart:async/runtime/libtimer_patch.dart:21:15)
#36 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
#37 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
#38 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
Edit: the below did not change anything, I still get the error above.
C:\Users\galankus>pub global activate webdev
Package webdev is currently active at version 0.2.3.
Resolving dependencies...
+ args 1.4.3
+ charcode 1.1.1
+ collection 1.14.10
+ io 0.3.2+1
+ meta 1.1.5
+ path 1.6.1
+ pub_semver 1.4.1
+ source_span 1.4.0
+ stack_trace 1.9.2
+ string_scanner 1.0.2
+ webdev 0.2.3
+ yaml 2.1.14
Precompiling executables...
Precompiled webdev:bin\webdev.
Installed executable webdev.
Activated webdev 0.2.3.
This was a bug in recent Dart versions that was fixed already.
Updating Dart and the global activated webdev package should fix it
To update a globally activated package, just activate it again:
pub global activate webdev
Use this Command to activate WebDev
dart pub global activate webdev

Cannot open file, path = 'file:///path' (OS Error: No such file or directory, errno = 2)

Hi I am trying reduce image size picked from gallery using image library
while trying that I am facing error like this
E/flutter (13796): [ERROR:lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (13796): FileSystemException: Cannot open file, path = 'file:///storage/emulated/0/WhatsApp/Media/WhatsApp%20Images/IMG-20171016-WA0020.jpg' (OS Error: No such file or directory, errno = 2)
E/flutter (13796): #0 _File.throwIfError (file_impl.dart:618)
E/flutter (13796): #1 _File.openSync (file_impl.dart:473)
E/flutter (13796): #2 _File.readAsBytesSync (file_impl.dart:533)
E/flutter (13796): #3 _AddNewUserState.qqq (/data/data/com.prayuta.chitfunds/cache/chitfundsUNFPRG/chitfunds/lib/users.dart:420:97)
E/flutter (13796): <asynchronous suspension>
E/flutter (13796): #4 _AddNewUserState.build.<anonymous closure> (/data/data/com.prayuta.chitfunds/cache/chitfundsUNFPRG/chitfunds/lib/users.dart:686:19)
E/flutter (13796): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (13796): #6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:149:9)
E/flutter (13796): #7 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:119:7)
E/flutter (13796): #8 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (13796): #9 BindingBase&SchedulerBinding&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:147:20)
E/flutter (13796): #10 BindingBase&SchedulerBinding&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
E/flutter (13796): #11 BindingBase&SchedulerBinding&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (13796): #12 BindingBase&SchedulerBinding&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
E/flutter (13796): #13 BindingBase&SchedulerBinding&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
E/flutter (13796): #14 _invoke1 (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:100)
E/flutter (13796): #15 _dispatchPointerDataPacket (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:58)
can any one help and my code look like this
import 'package:image/image.dart' as convertinglib;
File imageFile = await ImagePicker.pickImage();
convertinglib.Image image = convertinglib.decodeImage(new Io.File(imageFile.uri.toString()).readAsBytesSync());
convertinglib.Image thumbnail = convertinglib.copyResize(image, 120);
I suppose the issue is passing the Image URI as a String.
There is a fromUri constructor where you can pass the file URI.
Try using
new Io.File.fromUri(imageFile.uri)
instead of
new Io.File(imageFile.uri.toString())
The problem is not in reading the file with the image picker or with the conversion to a smaller size but with the writing of the file to the file system. I take it, you took the example code of the dart image package
which writes the file to the file system after resizing it. This is in this form not possible on smartphones.
The code you posted didn't actually cause the error but this line did:
new Io.File(imageFile.uri.toString())
..writeAsBytesSync(convertingLib.encodePng(thumbnail))
The problem with this is that the imagePicker hides the real uri of the image. It gives you a path that looks something like this: .../tmp/image_picker_1547A964-791E-426F-A682-33D3AFA995BA-18295-0003861F9255294A.jpg which can't be used to save your new thumbnail.
You can either try to avoid saving the file in the first place or save it to a location that actually exists (you could use for example the path_provider plugin for that purpose).

reflectable 0.3.4 - new version throwing exception

I just updated my dart application and did a pub cache repair afterwards.
The application does not run and debug throws the following exception
Uncaught Unhandled exception:
Unsupported operation: Cannot provide `reflectedType` of instance of generic type 'List'.
#0 InstantiatedGenericClassMirrorImpl.reflectedType (package:reflectable/src/reflectable_transformer_based.dart:713:5)
#1 _getPropertyInfoForType (package:polymer/src/common/polymer_descriptor.dart:210:46)
#2 _buildPropertiesObject.<anonymous closure> (package:polymer/src/common/polymer_descriptor.dart:58:24)
#3 _HashVMBase&MapMixin&&_LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:340)
#4 _buildPropertiesObject (package:polymer/src/common/polymer_descriptor.dart:56:16)
#5 createPolymerDescriptor (package:polymer/src/common/polymer_descriptor.dart:26:19)
#6 PolymerRegister.initialize (package:polymer/src/common/polymer_register.dart:19:36)
#7 loadInitializers.<anonymous closure>.<anonymous closure> (package:initialize/src/static_loader.dart:46:32)
#8 _runInitQueue (package:initialize/initialize.dart:35:24)
#9 _runInitQueue.<anonymous closure> (package:initialize/initialize.dart:38:26)
#10 _RootZone.runUnary (dart:async/zone.dart:1149)
#11 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:502)
#12 _Future._propagateToListeners (dart:async/future_impl.dart:585)
#13 _Future._completeWithValue (dart:async/future_impl.dart:376)
#14 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:430)
#15 _microtaskLoop (dart:async/schedule_microtask.dart:43)
#16 _microtaskLoopEntry (dart:async/schedule_microtask.dart:52)
#17 _ScheduleImmediateHelper._handleMutation (dart:html:49254)
#18 MutationObserver._create.<anonymous closure> (dart:html:27526)
(anonymous function)
The application was running quite well before.
Possible bug?
Thanks
Teddy
Rather long story, please check https://github.com/dart-lang/polymer-dart/issues/651 for some details, and for the resolution of this issue as it unfolds.

Resources