[Unhandled exception:
type 'Null' is not a subtype of type 'int' in type cast
#0 Session._refreshSessionData.parseContents (package:unified_analytics/src/session.dart:85:43)
#1 Session._refreshSessionData (package:unified_analytics/src/session.dart:89:7)
#2 new Session (package:unified_analytics/src/session.dart:28:5)
#3 new AnalyticsImpl (package:unified_analytics/src/analytics.dart:427:23)
#4 new Analytics (package:unified_analytics/src/analytics.dart:83:12)
#5 getAnalytics (package:flutter_tools/src/reporting/unified_analytics.dart:51:10)
#6 runInContext.<anonymous closure> (package:flutter_tools/src/context_runner.dart:92:24)
#7 AppContext._generateIfNecessary.<anonymous closure> (package:flutter_tools/src/base/context.dart:107:42)
#8 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:543:23)
#9 AppContext._generateIfNecessary (package:flutter_tools/src/base/context.dart:95:20)
#10 AppContext.get (package:flutter_tools/src/base/context.dart:124:32)
#11 analytics (package:flutter_tools/src/globals.dart:96:36)
#12 _handleToolError (package:flutter_tools/runner.dart:190:13)
#13 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:142:13)
#14 _rootRunBinary (dart:async/zone.dart:1423:47)
#15 _CustomZone.runBinary (dart:async/zone.dart:1315:19)
#16 runZonedGuarded.<anonymous closure> (dart:async/zone.dart:1776:18)
#17 _Zone._processUncaughtError (dart:async/zone.dart:1081:14)
#18 _CustomZone.handleUncaughtError (dart:async/zone.dart:1285:5)
#19 Future._propagateToListeners (dart:async/future_impl.dart:788:16)
#20 Future._completeError (dart:async/future_impl.dart:651:5)
#21 Future._asyncCompleteError.<anonymous closure> (dart:async/future_impl.dart:737:7)
#22 _rootRun (dart:async/zone.dart:1399:13)
#23 _CustomZone.run (dart:async/zone.dart:1301:19)
#24 _CustomZone.runGuarded (dart:async/zone.dart:1209:7)
#25 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1249:23)
#26 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#27 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#28 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#29 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)]
When I initially debugged my project, there were no errors. However, after a few debugging sessions, an error suddenly occurred. Despite restarting Visual Studio and attempting to create a new project, the same error persisted. Additionally, reinstalling Flutter and Dart did not resolve the issue.
Please help. Thank you
2
Answers
install flutter master
steps to resolved
Disable flutter and Dart extension in visual studio code
Open Git Bash in Directory c:/ and run this
git clone -b master https://github.com/flutter/flutter.git ./flutter/bin/flutter --version
then do flutter doctor
Doneenter image description here
In the session.dart file see line 85. It is mainly due to passing a value that is null or that could be null to an int type one. so see if that value could be null or if you haven’t given it a value or it is nullable