I am making a Date Time App on Flutter that I saw on YouTube. Whenever I try to run the program, it always says "E/flutter (31302): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception:" on the console with a bunch of other packages. I don't know what to do and what solution I can do. BTW I disabled some plugin on my flutter to speed up my Android Studio. Do you think it is one of the reasons for my error? I want to show the datetime and offset to the console first like in the video. I tried opening my net in hopes of maybe not connecting to the internet might help but I still got the same error. Thank you and God Bless. Here my code.
'''
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'dart:convert';
class loading extends StatefulWidget {
#override
_loadingState createState() => _loadingState();
}
class _loadingState extends State<loading> {
void getTime() async{
Response response = await get('http://worldtimeapi.org/api/timezone/Europe/London');
Map data = jsonDecode(response.body);
//print(data);
String datetime = data['datetime'];
String offset = data['utc_offset'];
print (datetime);
print(offset);
}
#override
void initState() {
super.initState();
getTime();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Text('Loading'),
);
}
}
'''
here is the error message:
'''
Launching lib\main.dart on CPH1803 in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Waiting for CPH1803 to report its views...
Debug service listening on ws://127.0.0.1:63067/xeetvh83VWI=/ws
Syncing files to device CPH1803...
D/libc-netbsd(12939): [getaddrinfo]: hostname=worldtimeapi.org; servname=(null); app_pid=12939; app_uid=10145; ai_flags=1024; ai_family=0; ai_socktype=1 from prox result 0
E/flutter (12939): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception:
E/flutter (12939): #0 IOClient.send (package:http/src/io_client.dart:62:7)
E/flutter (12939): <asynchronous suspension>
E/flutter (12939): #1 BaseClient._sendUnstreamed (package:http/src/base_client.dart:91:38)
E/flutter (12939): #2 BaseClient.get (package:http/src/base_client.dart:27:7)
E/flutter (12939): #3 get.<anonymous closure> (package:http/http.dart:46:36)
E/flutter (12939): #4 _withClient (package:http/http.dart:166:20)
E/flutter (12939): #5 get (package:http/http.dart:46:5)
E/flutter (12939): #6 _loadingState.getTime (package:world_time/pages/loading.dart:12:31)
E/flutter (12939): #7 _loadingState.initState (package:world_time/pages/loading.dart:27:5)
E/flutter (12939): #8 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4765:58)
E/flutter (12939): #9 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (12939): #10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (12939): #11 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (12939): #12 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter (12939): #13 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (12939): #14 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (12939): #15 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter (12939): #16 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter (12939): #17 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter (12939): #18 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (12939): #19 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (12939): #20 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (12939): #21 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter (12939): #22 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (12939): #23 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (12939): #24 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter (12939): #25 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (12939): #26 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (12939): #27 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter (12939): #28 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
E/flutter (12939): #29 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter (12939): #30 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter (12939): #31 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4791:11)
E/flutter (12939): #32 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (12939): #33 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (12939): #34 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (12939): #35 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter (12939): #36 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (12939): #37 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (12939): #38 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter (12939): #39 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (12939): #40 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (12939): #41 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter (12939): #42 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
E/flutter (12939): #43 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter (12939): #44 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter (12939): #45 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4791:11)
E/flutter (12939): #46 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (12939): #47 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (12939): #48 Ele
'''
If my question is still confusing please let me know so that I can give the problem. Please help me Thank you.
Related
E/flutter (17310): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: DioError [DioErrorType.other]: HandshakeException: Handshake error in client (OS Error: E/flutter (17310): CERTIFICATE_VERIFY_FAILED: certificate has expired(handshake.cc:393)) E/flutter (17310): Source stack: E/flutter (17310): #0 DioMixin.fetch (package:dio/src/dio_mixin.dart:488:35) E/flutter (17310): #1 DioMixin.request (package:dio/src/dio_mixin.dart:483:12) E/flutter (17310): #2 DioMixin.get (package:dio/src/dio_mixin.dart:61:12) E/flutter (17310): #3 getState (package:land_resource_inventory/modules/home/view/home_page.dart:355:28) E/flutter (17310): #4 _onTileClicked (package:land_resource_inventory/modules/home/view/home_page.dart:345:7) E/flutter (17310): #5 _MyHomePageState.build.<anonymous closure>.<anonymous closure> (package:land_resource_inventory/modules/home/view/home_page.dart:232:40) E/flutter (17310): #6 _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1072:21) E/flutter (17310): #7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:253:24) E/flutter (17310): #8 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:627:11) E/flutter (17310): #9 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:306:5) E/flutter (17310): #10 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:276:7) E/flutter (17310): #11 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:163:27) E/flutter (17310): #12 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:464:20) E/flutter (17310): #13 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:440:22) E/flutter (17310): #14 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:337:11) E/flutter (17310): #15 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:395:7) E/flutter (17310): #16 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:357:5) E/flutter (17310): #17 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:314:7) E/flutter (17310): #18 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:295:7) E/flutter (17310): #19 _invoke1 (dart:ui/hooks.dart:167:13) E/flutter (17310): #20 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:341:7) E/flutter (17310): #21 _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31) E/flutter (17310): E/flutter (17310): #0 DioMixin.fetch.<anonymous closure> (package:dio/src/dio_mixin.dart:643:7) E/flutter (17310): #1 _RootZone.runBinary (dart:async/zone.dart:1658:54) E/flutter (17310): #2 _FutureListener.handleError (dart:async/future_impl.dart:162:22) E/flutter (17310): #3 Future._propagateToListeners.handleError (dart:async/future_impl.dart:778:47) E/flutter (17310): #4 Future._propagateToListeners (dart:async/future_impl.dart:799:13) E/flutter (17310): #5 Future._completeError (dart:async/future_impl.dart:574:5) E/flutter (17310): #6 _SyncCompleter._completeError (dart:async/future_impl.dart:51:12) E/flutter (17310): #7 _Completer.completeError (dart:async/future_impl.dart:23:5) E/flutter (17310): #8 Future.any.onError (dart:async/future.dart:617:45) E/flutter (17310): #9 _RootZone.runBinary (dart:async/zone.dart:1658:54) E/flutter (17310): #10 _FutureListener.handleError (dart:async/future_impl.dart:162:22) E/flutter (17310): #11 Future._propagateToListeners.handleError (dart:async/future_impl.dart:778:47) E/flutter (17310): #12 Future._propagateToListeners (dart:async/future_impl.dart:799:13) E/flutter (17310): #13 Future._completeError (dart:async/future_impl.dart:574:5) E/flutter (17310): #14 Future._asyncCompleteError.<anonymous closure> (dart:async/future_impl.dart:665:7) E/flutter (17310): #15 _microtaskLoop (dart:async/schedule_microtask.dart:40:21) E/flutter (17310): #16 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
I have already tried:
https://stackoverflow.com/a/61312927/1776243
Although this is not recommended in production scenarios, you can accept any certificates by overriding the HttpClient that dio uses by providing a onHttpClientCreate, like the following :
(dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) {
client.badCertificateCallback=(X509Certificate cert, String host, int port){
return true;
};
};
Again, only use this for debugging and development purposes. In production, you should use a valid SSL certificate.
Documentation for onHttpClientCreate
Unhandled Exception: MissingPluginException(No implementation found
for method initConnection on channel flutter_inapp).When I use
flutter in-app purchase plugin for the android,
MissingPluginExceptionexception occurs. On iOS, it works nicely
When I run or debug app it gives the error that :
E/flutter ( 7718): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method initConnection on channel flutter_inapp)
E/flutter ( 7718): #0 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:157
E/flutter ( 7718): <asynchronous suspension>
E/flutter ( 7718): #1 MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:332
E/flutter ( 7718): #2 FlutterInappPurchase.initConnection
package:flutter_inapp_purchase/flutter_inapp_purchase.dart:85
E/flutter ( 7718): <asynchronous suspension>
E/flutter ( 7718): #3 PaymentService.initConnection
package:social_app/services/payment_service.dart:98
E/flutter ( 7718): #4 _CourseTabState.fetchCarevanAcademy
package:social_app/…/course_tab/course_tab.dart:96
E/flutter ( 7718): <asynchronous suspension>
E/flutter ( 7718): #5 _CourseTabState.initState
package:social_app/…/course_tab/course_tab.dart:38
E/flutter ( 7718): #6 StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:4765
E/flutter ( 7718): #7 ComponentElement.mount
package:flutter/…/widgets/framework.dart:4601
E/flutter ( 7718): #8 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3569
E/flutter ( 7718): #9 MultiChildRenderObjectElement.mount
package:flutter/…/widgets/framework.dart:6236
E/flutter ( 7718): #10 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3569
E/flutter ( 7718): #11 Element.updateChild
package:flutter/…/widgets/framework.dart:3327
E/flutter ( 7718): #12 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4652
E/flutter ( 7718): #13 Element.rebuild
package:flutter/…/widgets/framework.dart:4343
E/flutter ( 7718): #14 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:4606
E/flutter ( 7718): #15 ComponentElement.mount
package:flutter/…/widgets/framework.dart:4601
E/flutter ( 7718): #16 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3569
E/flutter ( 7718): #17 Element.updateChild
package:flutter/…/widgets/framework.dart:3327
E/flutter ( 7718): #18 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4652
E/flutter ( 7718): #19 Element.rebuild
package:flutter/…/widgets/framework.dart:4343
E/flutter ( 7718): #20 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:4606
E/flutter ( 7718): #21 ComponentElement.mount
package:flutter/…/widgets/framework.dart:4601
E/flutter ( 7718): #22 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3569
E/flutter ( 7718): #23 Element.updateChild
package:flutter/…/widgets/framework.dart:3327
E/flutter ( 7718): #24 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4652
E/flutter ( 7718): #25 Element.rebuild
package:flutter/…/widgets/framework.dart:4343
E/flutter ( 7718): #26 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:4606
E/flutter ( 7718): #27 ComponentElement.mount
package:flutter/…/widgets/framework.dart:4601
E/flutter ( 7718): #28 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3569
E/flutter ( 7718): #29 MultiChildRenderObjectElement.mount
package:flutter/…/widgets/framework.dart:6236
E/flutter ( 7718): #30 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3569
Close the app and execute flutter run command.
I am having a hard time with tflite in flutter
well the problem is the app cannot load the model but I did mention the asset in pubspec.yaml file and also I did spell the model name and the label text correctly still I am getting the error
Pubspeck.yaml
assets:
- asset/fruit.txt
- asset/model.tflite
- asset/model_unquant.tflite
- asset/labels2.txt
Loading model
loadModel() async {
String res = await Tflite.loadModel(
labels: "asset/labels2.txt",
model: "asset/model_unquant.tflite",
);
print(res);
}
Predicting
predict(String path) async {
var recognitions = await Tflite.runModelOnImage(
path: path,
threshold: 0.3,
imageMean: 0.0,
imageStd: 255.0,
numResults: 292
);
setState(() {
_recognitions = recognitions;
char = _recognitions[0]["labels"];
item = _recognitions[0];
});
}
Traceback
*E/flutter (18543): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(Failed to load model, flutter_assets/asset/model_unquant.tflite, java.io.FileNotFoundException: flutter_assets/asset/model_unquant.tflite*
E/flutter (18543): at android.content.res.AssetManager.nativeOpenAssetFd(Native Method)
E/flutter (18543): at android.content.res.AssetManager.openFd(AssetManager.java:899)
E/flutter (18543): at sq.flutter.tflite.TflitePlugin.loadModel(TflitePlugin.java:207)
E/flutter (18543): at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:95)
E/flutter (18543): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter (18543): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter (18543): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/flutter (18543): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (18543): at android.os.MessageQueue.next(MessageQueue.java:336)
E/flutter (18543): at android.os.Looper.loop(Looper.java:197)
E/flutter (18543): at android.app.ActivityThread.main(ActivityThread.java:8107)
E/flutter (18543): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (18543): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
E/flutter (18543): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
E/flutter (18543): , null)
E/flutter (18543): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582:7)
E/flutter (18543): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:18)
E/flutter (18543): <asynchronous suspension>
E/flutter (18543): #2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
E/flutter (18543): #3 Tflite.loadModel (package:tflite/tflite.dart:16:27)
E/flutter (18543): #4 ResPicState.loadModel (package:respic/main.dart:53:31)
E/flutter (18543): #5 ResPicState.initState (package:respic/main.dart:48:5)
E/flutter (18543): #6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4765:58)
E/flutter (18543): #7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (18543): #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (18543): #9 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (18543): #10 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter (18543): #11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (18543): #12 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (18543): #13 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter (18543): #14 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter (18543): #15 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter (18543): #16 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (18543): #17 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (18543): #18 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (18543): #19 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter (18543): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (18543): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (18543): #22 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter (18543): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (18543): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (18543): #25 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter (18543): #26 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
E/flutter (18543): #27 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter (18543): #28 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter (18543): #29 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4791:11)
E/flutter (18543): #30 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (18543): #31 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (18543): #32 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (18543): #33 SingleChildRenderObjec
D/ViewRootImpl#6337ccf[MainActivity](18543): ViewPostIme pointer 0
D/ViewRootImpl#6337ccf[MainActivity](18543): ViewPostIme pointer 1
I don't know what causes this error I have also tried using different version of tflite and different types of models and cleaned as well but the problem still persists.
Thanks for reading,
regards,
Roshan
remove asset in pubspec.yaml
It should be:
assets:
fruit.txt
model.tflite
model_unquant.tflite
labels2.txt
I am attempting to play a simple sound using flutter's audioplayers library. When I attempt to, I get an Unable to load asset error. I've gone through several related questions on this site, and all of them seem to only suggest checking the indentation on the pubspec.yaml file and running flutter clean. I have done this several times and have had no results. Flutter Doctor finds no issues.
When I click the button that should cause the sound to play, I receive this:
E/flutter (22727): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Unable to load asset: assets/sounds/start.mp3
E/flutter (22727): #0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:221:7)
E/flutter (22727): <asynchronous suspension>
E/flutter (22727): #1 AudioCache._fetchAsset (package:audioplayers/audio_cache.dart:60:29)
E/flutter (22727): #2 AudioCache.fetchToMemory (package:audioplayers/audio_cache.dart:67:30)
E/flutter (22727): <asynchronous suspension>
E/flutter (22727): #3 AudioCache.load (package:audioplayers/audio_cache.dart:82:37)
E/flutter (22727): #4 AudioCache.getAbsoluteUrl (package:audioplayers/audio_cache.dart:140:23)
E/flutter (22727): #5 AudioCache.play (package:audioplayers/audio_cache.dart:103:24)
E/flutter (22727): #6 playSound (package:tick_tok_bio/player.dart:14:20)
E/flutter (22727): #7 MapsState.startNewRoute (package:tick_tok_bio/gps_tracking.dart:122:13)
E/flutter (22727): #8 MapsState.startStop.<anonymous closure> (package:tick_tok_bio/gps_tracking.dart:240:13)
E/flutter (22727): #9 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19)
E/flutter (22727): #10 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:862:36)
E/flutter (22727): #11 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (22727): #12 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
E/flutter (22727): #13 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5)
E/flutter (22727): #14 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:217:7)
E/flutter (22727): #15 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:475:9)
E/flutter (22727): #16 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
E/flutter (22727): #17 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
E/flutter (22727): #18 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
E/flutter (22727): #19 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
E/flutter (22727): #20 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
E/flutter (22727): #21 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter (22727): #22 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (22727): #23 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (22727): #24 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (22727): #25 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (22727): #26 _rootRunUnary (dart:async/zone.dart:1196:13)
E/flutter (22727): #27 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (22727): #28 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (22727): #29 _invoke1 (dart:ui/hooks.dart:275:10)
E/flutter (22727): #30 _dispatchPointerDataPacket (dart:ui/hooks.dart:184:5)
Here is the code that should play the audio file:
import 'package:audioplayers/audio_cache.dart';
import 'dart:async';
import 'package:audioplayers/audioplayers.dart';
AudioPlayer advancedPlayer;
AudioCache audioCache;
void initPlayer() {
advancedPlayer = AudioPlayer();
audioCache = AudioCache(fixedPlayer: advancedPlayer, prefix: 'sounds/');
}
Future<void> playSound(String path) async {
await audioCache.play(path);
return;
}
Here is where the methods are called:
void initState() {
super.initState();
initPlayer();
}
void startNewRoute() async {
await playSound('start.mp3');
// more code here
}
Here is the assets section of pubspec.yaml
flutter:
uses-material-design: true
assets:
- images/
- sounds/start.mp3
fonts:
- family: RobotoMono
fonts:
- asset: fonts/RobotoMono-Regular.ttf
- asset: fonts/RobotoMono-Bold.ttf
And the files are structured like this:
root
lib
[dart files]
images
[some images]
sounds
start.mp3
I can't find any discrepancies between what I've done here and the way the documentation of the library explains it should be used. Any help is appreciated, thanks.
As per by design, you should be adding "assets/" setting your pubspec.yaml like this:
assets:
- images/
- assets/sounds/start.mp3
Audio Cache official doc here
Don't forget to add these files to your pubspec.yaml file:
flutter: assets:
assets/explosion.mp3
someone had similar issue here
I'm trying o create a flutter application. and I have success working with login with Facebook and Twitter. there is a problem while I'm trying to login with Twitter. My device has not been installed on the twitter application and I'm facing the problem for null value assign. Have anyone maid a solution for the issue.
E/flutter (20681): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The getter 'token' was called on null.
E/flutter (20681): Receiver: null
E/flutter (20681): Tried calling: token
E/flutter (20681): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
E/flutter (20681): #1 _LoginScreenState._loginWithTwitter (package:c2c_app/src/screens/Account/Login/login_page.dart:104:39)
E/flutter (20681): <asynchronous suspension>
E/flutter (20681): #2 _LoginScreenState._buildLoginWidget.<anonymous closure> (package:c2c_app/src/screens/Account/Login/login_page.dart:581:40)
E/flutter (20681): #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
E/flutter (20681): #4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789:36)
E/flutter (20681): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (20681): #6 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
E/flutter (20681): #7 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
E/flutter (20681): #8 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236:7)
E/flutter (20681): #9 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (20681): #10 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
E/flutter (20681): #11 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (20681): #12 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (20681): #13 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (20681): #14 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (20681): #15 _rootRunUnary (dart:async/zone.dart:1138:13)
E/flutter (20681): #16 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (20681): #17 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter (20681): #18 _invoke1 (dart:ui/hooks.dart:273:10)
E/flutter (20681): #19 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
E/flutter (20681):
you need to just put try and catch block inside twitter login code