So I created a custom class and I'm trying to build it with data from Firebase.
I get a Map<dynamic> from firebase and tease it apart with .map() and returning Lists instances of class SocialLink (working merely as a struct).
here's the code
void onProjectValue(void callback(List<Project> projects)){
this.dbRef.child('threads').limitToLast(40).onValue.listen((Event event){
List<Project> projects = [];
Map result = event.snapshot.value;
result.forEach((id, projectData){
projects.add(
new Project(
id: int.parse(id),
title: projectData['thread-scrape']['subject'],
iconUrl: 'http://192.168.1.120:8080/services/twitter.png',
tags: projectData['thread-scrape']['tags'].values.map<String>( (value){
return '$value';
}).toList(), // does this work? yes
links: projectData['links-scrape'].entries.map<SocialLink>( (entry)=>
SocialLink(
iconUrl: this.socialUrls[entry.key],
linkUrl: entry.value
)).toList(), // does this work? no!
views: projectData['thread-scrape']['views']
)
);
});
return callback(projects);
});
}
Problem is I get this error (stack trace)
Launching lib/main.dart on iPhone X in debug mode...
Xcode build done.
CADisplay.name = LCD;
CADisplay.deviceName = PurpleMain;
CADisplay.seed = 1;
tags = 0;
currentMode = <FBSDisplayMode: 0x60c000097700; 375x812@3x (1125x2436/3) 60Hz p3 SDR>;
safeOverscanRatio = {0.89999997615814209, 0.89999997615814209};
nativeCenter = {562.5, 1218};
pixelSize = {1125, 2436};
bounds = {{0, 0}, {375, 812}};
CADisplay = <CADisplay:LCD PurpleMain>;
}
5.4.0 - [Firebase/Analytics][I-ACS023007] Firebase Analytics v.50001000 started
5.4.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
[1.1 69498871-3F7C-4F0A-AFCD-4581EDF0C1ED 192.168.1.120.58897<->172.217.3.106:443]
Connected Path: satisfied (Path is satisfied), interface: en1
Duration: 0.281s, DNS @0.001s took 0.040s, TCP @0.043s took 0.044s, TLS took 0.114s
bytes in/out: 3579/1061, packets in/out: 9/10, rtt: 0.043s, retransmitted packets: 0, out-of-order packets: 0
5.4.0 - [Firebase/Core][I-COR000004] App with name when-coin-test does not exist.
[2.1 32DB1D89-B138-4B98-A6D9-B68CC8652D59 192.168.1.120.58905<->172.217.12.138:443]
Connected Path: satisfied (Path is satisfied), interface: en1
Duration: 0.270s, DNS @0.000s took 0.018s, TCP @0.024s took 0.049s, TLS took 0.129s
bytes in/out: 3337/1061, packets in/out: 9/10, rtt: 0.046s, retransmitted packets: 0, out-of-order packets: 0
flutter: connected!
flutter: {Telegram: https://firebasestorage.googleapis.com/v0/b/when-coin-test.appspot.com/o/img%2Ftelegram.png?alt=media&token=dbbd043f-05db-45ca-b00d-50edfe763f95, Medium: https://firebasestorage.googleapis.com/v0/b/when-coin-test.appspot.com/o/img%2Fmedium.png?alt=media&token=15267fc3-f112-4fa1-9e6c-facbe787e68d, YouTube: https://firebasestorage.googleapis.com/v0/b/when-coin-test.appspot.com/o/img%2Fyoutube.png?alt=media&token=4de33db4-ec85-47d0-9a9e-952479bdb761, GitHub: https://firebasestorage.googleapis.com/v0/b/when-coin-test.appspot.com/o/img%2Fgithub.png?alt=media&token=403440df-65e3-4c1b-8ac8-a8bed7ea2f4c, Steemit: https://firebasestorage.googleapis.com/v0/b/when-coin-test.appspot.com/o/img%2Fsteemit.png?alt=media&token=308f7f2d-0120-454d-b2f7-415d13f57106, Slack: https://firebasestorage.googleapis.com/v0/b/when-coin-test.appspot.com/o/img%2Fslack.png?alt=media&token=6dfa1b2b-33a5-4820-a167-05d25e9c743a, Facebook: https://firebasestorage.googleapis.com/v0/b/when-coin-test.appspot.com/<…>
compiler message: Unhandled exception:
compiler message: NoSuchMethodError: The getter 'className' was called on null.
compiler message: Receiver: null
compiler message: Tried calling: className
compiler message: #0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:46:5)
compiler message: #1 serializeProcedure (package:front_end/src/fasta/kernel/utils.dart:82:29)
compiler message: #2 FrontendCompiler.compileExpression (package:vm/frontend_server.dart:452:16)
compiler message: <asynchronous suspension>
compiler message: #3 _FlutterFrontendCompiler.compileExpression (package:frontend_server/server.dart:55:22)
compiler message: #4 listenAndCompile.<anonymous closure> (package:vm/frontend_server.dart:650:20)
compiler message: <asynchronous suspension>
compiler message: #5 _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
compiler message: #6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
compiler message: #7 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
compiler message: #8 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
compiler message: #9 _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
compiler message: #10 _StringAdapterSink.add (dart:convert/string_conversion.dart:268:11)
compiler message: #11 _LineSplitterSink._addLines (dart:convert/line_splitter.dart:154:13)
compiler message: #12 _LineSplitterSink.addSlice (dart:convert/line_splitter.dart:129:5)
compiler message: #13 StringConversionSinkMixin.add (dart:convert/string_conversion.dart:189:5)
compiler message: #14 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
compiler message: #15 _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
compiler message: #16 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
compiler message: #17 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
compiler message: #18 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
compiler message: #19 _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
compiler message: #20 _StringAdapterSink.add (dart:convert/string_conversion.dart:268:11)
compiler message: #21 _StringAdapterSink.addSlice (dart:convert/string_conversion.dart:273:7)
compiler message: #22 _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:348:20)
compiler message: #23 _Utf8ConversionSink.add (dart:convert/string_conversion.dart:341:5)
compiler message: #24 _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:86:18)
compiler message: #25 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
compiler message: #26 _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
compiler message: #27 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
compiler message: #28 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
compiler message: #29 _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
compiler message: #30 _StreamController._add (dart:async/stream_controller.dart:639:7)
compiler message: #31 _StreamController.add (dart:async/stream_controller.dart:585:5)
compiler message: #32 _Socket._onData (dart:io/runtime/binsocket_patch.dart:1714:41)
compiler message: #33 _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
compiler message: #34 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
compiler message: #35 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
compiler message: #36 _SyncStreamController._sendData (dart:async/stream_controller.dart:763:19)
compiler message: #37 _StreamController._add (dart:async/stream_controller.dart:639:7)
compiler message: #38 _StreamController.add (dart:async/stream_controller.dart:585:5)
compiler message: #39 new _RawSocket.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:1276:33)
compiler message: #40 _NativeSocket.issueReadEvent.issue (dart:io/runtime/binsocket_patch.dart:819:14)
compiler message: #41 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
compiler message: #42 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
compiler message: #43 _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:113:13)
compiler message: #44 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:166:5)
Unhandled exception:
SocketException: Write failed (OS Error: Broken pipe, errno = 32), port = 0
#0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1114:29)
#1 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#2 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#3 _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:113:13)
#4 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:166:5)
Exited (255)
@l-k22 please post the output of
flutter doctor -v
If it's helpful the app was working before but recently I needed to setup OneSignal background notifications, I updated my compileSDKversion to 28, would this be related to AndroidX?
Here is the output
flutter doctor -v
[✓] Flutter (Channel dev, v1.2.0, on Mac OS X 10.14.2 18C54, locale en-GB)
• Flutter version 1.2.0 at /Users/xxxx/Documents/Programming/flutter
• Framework revision 06b979c4d5 (3 weeks ago), 2019-01-25 14:27:35 -0500
• Engine revision 36acd02c94
• Dart version 2.1.1 (build 2.1.1-dev.3.2 f4afaee422)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/xxxx/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.1, Build version 10B61
• ios-deploy 1.9.4
• CocoaPods version 1.6.0.rc.1
[✓] Android Studio (version 3.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 32.0.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[✓] VS Code (version 1.31.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.22.3
[✓] Connected device (2 available)
• ASUS X00TD • xxxxxxxxxxxx • android-arm64 • Android 8.1.0 (API 27)
• Developer’s iPhone • xxxxxxxxxxxxxxxxxxxxxxxx • ios • iOS 12.1.4
• No issues found!