i am trying to run this example in the plugin page
and i get this error
I/flutter ( 3273): MissingPluginException(No implementation found for method getAndroidDeviceInfo on channel plugins.flutter.io/device_info)
I/flutter ( 3273): #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:153:7)
I/flutter ( 3273): <asynchronous suspension>
I/flutter ( 3273): #1 DeviceInfoPlugin.androidInfo (package:device_info/device_info.dart:25:35)
I/flutter ( 3273): <asynchronous suspension>
I/flutter ( 3273): #2 _MyAppState.initPlatformState (/data/user/0/com.yourcompany.demos/cache/demosSWKRJL/demos/lib/main.dart:37:67)
I/flutter ( 3273): <asynchronous suspension>
I/flutter ( 3273): #3 _MyAppState.initState (/data/user/0/com.yourcompany.demos/cache/demosSWKRJL/demos/lib/main.dart:29:5)
I/flutter ( 3273): #4 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3734:58)
I/flutter ( 3273): #5 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
I/flutter ( 3273): #6 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
I/flutter ( 3273): #7 Element.updateChild (package:flutter/src/widgets/framework.dart:2693:12)
I/flutter ( 3273): #8 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:852:16)
I/flutter ( 3273): #9 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:823:5)
I/flutter ( 3273): #10 RenderObje
this isn't a bug
and it isn't about platform specific coding as #challenget answered
you just need to re-build and run the app again for flutter-plugin to be added and work correctly.
hot-restart won't work
:hearts [this is a feature-request btw]
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
if (Platform.isAndroid) {
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
} else if (Platform.isIOS) {
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
}
You need to judge the device.
follow this 4 steps it will work
flutter clean
flutter pub get
flutter clean
flutter run
follow these 4 steps it will work
flutter clean
flutter pub get
flutter clean
flutter run
or
Stop the app and restart the build. This worked for me.
Stop the app and restart the build. This worked for me.
Related
I just generated 10000 files in the Flutter app project in VSC:
{placeholder0, placeholder1 ..., placeholder10000}
Each file contains simple widget returning next Placeholder, like Placeholder0 widget returns Placeholder1 widget and so on.. where Placeholder10000 returns just Text('test').
(What I also noticed VSC behaviour is getting strange once so much files is placed inside the project, like Dart Analyzer is super lagging. I could not fint any info about number of files limitations within the project). Actually is it possible to run the project with such of big number of files inside it?
Once I put Placeholder0 widget in the body of my HomePage try to run the app on simulator (iOS Simulator) i got following StackOverFlow error:
The relevant error-causing widget was
Placeholder453
lib/placeholders/placeholder452.dart:9
When the exception was thrown, this was the stack
#0 _HashBase._isDeleted (dart:collection-patch/compact_hash.dart:198:3)
#1 _LinkedHashMapMixin._init (dart:collection-patch/compact_hash.dart:429:24)
#2 _LinkedHashMapMixin._rehash (dart:collection-patch/compact_hash.dart:399:7)
#3 _LinkedHashMapMixin._insert (dart:collection-patch/compact_hash.dart:456:7)
#4 _LinkedHashMapMixin._set (dart:collection-patch/compact_hash.dart:511:7)
#5 _LinkedHashMapMixin.[]= (dart:collection-patch/compact_hash.dart:499:5)
#6 MapMixin.addAll.<anonymous closure> (dart:collection/maps.dart:129:11)
#7 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:617:13)
#8 MapMixin.addAll (dart:collection/maps.dart:128:11)
#9 _InternalLinkedHashMap.addAll (dart:collection-patch/compact_hash.dart:301:11)
#10 DiagnosticsNode.toJsonMap.<anonymous closure>
package:flutter/…/foundation/diagnostics.dart:1646
#11 DiagnosticsNode.toJsonMap
package:flutter/…/foundation/diagnostics.dart:1661
#12 DiagnosticsProperty.toJsonMap
package:flutter/…/foundation/diagnostics.dart:2666
#13 DiagnosticsNode.toJsonList.<anonymous closure>
package:flutter/…/foundation/diagnostics.dart:1686
#14 MappedListIterable.elementAt (dart:_internal/iterable.dart:413:31)
#15 ListIterator.moveNext (dart:_internal/iterable.dart:342:26)
#16 new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#17 new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#18 new List.of (dart:core-patch/array_patch.dart:51:28)
#19 ListIterable.toList (dart:_internal/iterable.dart:213:44)
#20 DiagnosticsNode.toJsonList
package:flutter/…/foundation/diagnostics.dart:1687
#21 DiagnosticsNode.toJsonMap.<anonymous closure>
package:flutter/…/foundation/diagnostics.dart:1648
#22 DiagnosticsNode.toJsonMap
package:flutter/…/foundation/diagnostics.dart:1661
#23 DiagnosticsNode.toJsonList.<anonymous closure>
package:flutter/…/foundation/diagnostics.dart:1686
#24 MappedListIterable.elementAt (dart:_internal/iterable.dart:413:31)
#25 ListIterator.moveNext (dart:_internal/iterable.dart:342:26)
#26 new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#27 new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#28 new List.of (dart:core-patch/array_patch.dart:51:28)
#29 ListIterable.toList (dart:_internal/iterable.dart:213:44)
#30 DiagnosticsNode.toJsonList
package:flutter/…/foundation/diagnostics.dart:1687
#31 DiagnosticsNode.toJsonMap.<anonymous closure>
package:flutter/…/foundation/diagnostics.dart:1648
#32 DiagnosticsNode.toJsonMap
package:flutter/…/foundation/diagnostics.dart:1661
#33 WidgetInspectorService._nodeToJson
package:flutter/…/widgets/widget_inspector.dart:1606
#34 WidgetInspectorService._reportStructuredError
package:flutter/…/widgets/widget_inspector.dart:937
#35 FlutterError.reportError
package:flutter/…/foundation/assertions.dart:1184
#36 _debugReportException
package:flutter/…/widgets/framework.dart:6493
#37 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4908
#38 Element.rebuild
package:flutter/…/widgets/framework.dart:4604
#39 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:4859
#40 ComponentElement.mount
package:flutter/…/widgets/framework.dart:4853
#41 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3863
#42 Element.updateChild
package:flutter/…/widgets/framework.dart:3592
2
...
#4116 Element.rebuild
package:flutter/…/widgets/framework.dart:4604
#4117 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:4859
#4118 StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:5041
#4119 ComponentElement.mount
package:flutter/…/widgets/framework.dart:4853
... Normal element mounting (27 frames)
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.
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.
I tried this code to load and read a txt file. But it can't read file and returns "Couldn't read file" message.
Future<String> _read() async {
String text;
try {
final directory = await getApplicationDocumentsDirectory();
final file = File('${directory.path}/table.txt');
text = await file.readAsString();
} catch (e) {
print("Couldn't read file");
}
return text;
}
I set my txt file in a folder(data) in the directory of the project.I tried it with final file = File('${directory.path}/data/table.txt'); too. This is my "pubspec.yaml" file:
flutter:
assets:
- data/table.txt
I get this error:
I/flutter ( 2067): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 2067): The following assertion was thrown building MyApp(dirty):
I/flutter ( 2067): 'package:flutter/src/widgets/text.dart': Failed assertion: line 235 pos 15: 'data != null': is not
I/flutter ( 2067): true.
I/flutter ( 2067):
I/flutter ( 2067): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter ( 2067): more information in this error message to help you determine and fix the underlying cause.
I/flutter ( 2067): In either case, please report this assertion by filing a bug on GitHub:
I/flutter ( 2067): https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter ( 2067):
I/flutter ( 2067): When the exception was thrown, this was the stack:
I/flutter ( 2067): #2 new Text
package:flutter/…/widgets/text.dart:235
I/flutter ( 2067): #3 MyApp.build
package:hello_flutter/main.dart:90
I/flutter ( 2067): #4 StatelessElement.build
package:flutter/…/widgets/framework.dart:3774
I/flutter ( 2067): #5 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3721
I/flutter ( 2067): #6 Element.rebuild
package:flutter/…/widgets/framework.dart:3547
I/flutter ( 2067): #7 BuildOwner.buildScope
package:flutter/…/widgets/framework.dart:2286
I/flutter ( 2067): #8 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame
package:flutter/…/widgets/binding.dart:676
I/flutter ( 2067): #9 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback
package:flutter/…/rendering/binding.dart:219
I/flutter ( 2067): #10 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback
package:flutter/…/scheduler/binding.dart:990
I/flutter ( 2067): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame
package:flutter/…/scheduler/binding.dart:930
I/flutter ( 2067): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure>
package:flutter/…/scheduler/binding.dart:751
I/flutter ( 2067): #14 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter ( 2067): #15 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter ( 2067): #16 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_pat
ch.dart:171:12)
I/flutter ( 2067): (elided 3 frames from class _AssertionError and package dart:async)
I/flutter ( 2067): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 2067): Couldn't read file
I/flutter ( 2067): null
Reloaded 1 of 420 libraries in ۱٬۱۰۴ms.
Add the full path in pubspec.yaml file:
flutter:
assets:
- assets/data/table.txt
you should create an assets folder inside your main project directory where folders such as : lib , build and IOS reside and put your data directory inside it, then add the aforementioned lines and run the command flutter packages get and after completion it will work fine.
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).