Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchMethodError: The getter 'index' was called on null. Receiver: null #2860

Closed
Eric-Dev-Live opened this issue Oct 14, 2020 · 7 comments
Closed

Comments

@Eric-Dev-Live
Copy link

After Running

flutter pub run build_runner build --delete-conflicting-outputs

am getting

[SEVERE] sqfentity_gen:property_sqfentity on lib/models/kikao.dart:
NoSuchMethodError: The getter 'index' was called on null.
Receiver: null

  • Dart SDK Version (dart --version).

Dart SDK version: 2.10.1 (stable) (Tue Oct 6 10:54:20 2020 +0200) on "macos_x64"

build_runner: ^1.10.3
build_runner_core: ^6.0.3
build_verify: ^1.1.1

Am using sqfEntity_gen to generate sqflite models and helper methods

import 'dart:convert';
import 'dart:typed_data';

import 'package:http/http.dart' as http;
import 'package:flutter/material.dart';
import 'package:sqfentity/sqfentity.dart';
import 'package:sqfentity_gen/sqfentity_gen.dart';

part 'kikao.g.dart';

// Define the 'tableDummy' constant as SqfEntityTable for the dummy table.
const tableDummy = SqfEntityTable(
    tableName: 'dummy',
    primaryKeyName: 'id',
    primaryKeyType: PrimaryKeyType.integer_auto_incremental,
    useSoftDeleting: true,
    modelName: null,
    fields: [
      SqfEntityField('name', DbType.text),
      SqfEntityField('isActive', DbType.bool, defaultValue: true),
    ]);

const seqIdentity = SqfEntitySequence(
  sequenceName: 'identity',
  // maxValue:  10000, /* optional. default is max int (9.223.372.036.854.775.807) */
  // modelName: 'SQEidentity',
  /* optional. SqfEntity will set it to sequenceName automatically when the modelName is null*/
  // cycle : false,   /* optional. default is false; */
  // minValue = 0;    /* optional. default is 0 */
  // incrementBy = 1; /* optional. default is 1 */
  // startWith = 0;   /* optional. default is 0 */
);

@SqfEntityBuilder(myDbModel)
const myDbModel = SqfEntityModel(
  modelName: 'MyDbModel',
  databaseName: 'sampleORM.db',
  password: null,
  databaseTables: [
    tableDummy,
  ],
  sequences: [seqIdentity],
  bundledDatabasePath: null,
);

sqfentity: ^1.4.0+1
sqfentity_gen: ^1.4.0

@jakemac53
Copy link
Contributor

Can you post a stack trace? You may need to run with --verbose enabled.

@colinmcintyre
Copy link

I too am receiving the same error. It has only started since upgrading flutter to
flutter --version Flutter 1.24.0-2.0.pre.92 • channel master • https://github.com/flutter/flutter.git Framework • revision 8a25557619 (32 hours ago) • 2020-10-20 11:58:49 -0700 Engine • revision ea2aea1c61 Tools • Dart 2.11.0 (build 2.11.0-234.0.dev)

[INFO] Generating build script...
[INFO] Generating build script completed, took 300ms

[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 95ms

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 622ms

[INFO] Running build...
[INFO] 1.1s elapsed, 0/16 actions completed.
[INFO] 2.1s elapsed, 0/16 actions completed.
[INFO] 3.1s elapsed, 0/16 actions completed.
[INFO] 6.2s elapsed, 0/16 actions completed.
[INFO] 11.7s elapsed, 1/16 actions completed.
[INFO] 12.8s elapsed, 16/23 actions completed.
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
SQFENTITY GENERATOR STARTED... instance Of:* database
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
SQFENTITY GENERATOR: builder initialized (* database)...
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
SQFENTITY_GEN.DART: recognizing Tables (* database)
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
-------------------------------------------------------TABLE RECOGNIZING: registrants
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
init() -> modelname: registrant,tableName:registrants
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
-------------------------------------------------------TABLE RECOGNIZING: payload_grouping
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
init() -> modelname: payloadGroup,tableName:payload_grouping
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
-------------------------------------------------------TABLE RECOGNIZING: save_state
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
init() -> modelname: saveState,tableName:save_state
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
-------------------------------------------------------TABLE RECOGNIZING: waypoints
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
-------------------------------------------------------TABLE RECOGNIZING: geolocations
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
init() -> modelname: geoLocation,tableName:geolocations
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
init() -> modelname: wayPoint,tableName:waypoints
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
-------------------------------------------------------TABLE RECOGNIZING: payload
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
init() -> modelname: payloadItem,tableName:payload
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
-------------------------------------------------------TABLE RECOGNIZING: polylines
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
init() -> modelname: line,tableName:polylines
[WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:

  • database Model recognized succesfuly
    [WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
    7 tables found in * database
    [WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
  • database converted to SqfEntityModelBase successfully
    [WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:
    createEntites() started
    [WARNING] sqfentity_gen:property_sqfentity on lib/database/database.dart:

OBJECTTYPE.TABLE registrants(expiry,name,code,company,signaturePrompt,country,voice,) converting to entity
[SEVERE] sqfentity_gen:property_sqfentity on lib/database/database.dart:

NoSuchMethodError: The getter 'index' was called on null.
Receiver: null
Tried calling: index
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
-------------------------------------------------------FormBuilder: SqfEntityTable
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
SQFENTITY_GEN.DART: recognizing Tables (SqfEntityTable)
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
-------------------------------------------------------TABLE RECOGNIZING: registrants
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
init() -> modelname: registrant,tableName:registrants
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
-------------------------------------------------------TABLE RECOGNIZING: payload_grouping
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
init() -> modelname: payloadGroup,tableName:payload_grouping
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
-------------------------------------------------------TABLE RECOGNIZING: save_state
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
init() -> modelname: saveState,tableName:save_state
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
-------------------------------------------------------TABLE RECOGNIZING: waypoints
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
-------------------------------------------------------TABLE RECOGNIZING: geolocations
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
init() -> modelname: geoLocation,tableName:geolocations
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
init() -> modelname: wayPoint,tableName:waypoints
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
-------------------------------------------------------TABLE RECOGNIZING: payload
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
init() -> modelname: payloadItem,tableName:payload
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
-------------------------------------------------------TABLE RECOGNIZING: polylines
[WARNING] sqfentity_gen:property_sqfentity_forms on lib/database/database.dart:
init() -> modelname: line,tableName:polylines
[INFO] Running build completed, took 14.7s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 47ms

[SEVERE] Failed after 14.7s
pub finished with exit code 1

@jakemac53
Copy link
Contributor

@colinmcintyre can you run with --verbose? We should see a stack trace then for the SEVERE log with the error.

@colinmcintyre
Copy link

@jakemac53 Hi. Please find below the full output with --verbose. And thank you for looking into this, much appreciated.

flutter pub run build_runner build --delete-conflicting-outputs --verbose

[ +97 ms] executing: [D:\Program Files\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +33 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[ ] fdac8a9d1f321388d71e35f825b40c05901e74f0
[ ] executing: [D:\Program Files\flutter/] git tag --points-at HEAD
[ +22 ms] Exit code 0 from: git tag --points-at HEAD
[ +1 ms] executing: [D:\Program Files\flutter/] git describe --match ..* --first-parent --long --tags
[ +39 ms] Exit code 0 from: git describe --match ..* --first-parent --long --tags
[ ] 1.24.0-3.0.pre-57-gfdac8a9d1f
[ +6 ms] executing: [D:\Program Files\flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[ +15 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[ ] origin/master
[ ] executing: [D:\Program Files\flutter/] git ls-remote --get-url origin
[ +10 ms] Exit code 0 from: git ls-remote --get-url origin
[ ] https://github.com/flutter/flutter.git
[ +38 ms] executing: [D:\Program Files\flutter/] git rev-parse --abbrev-ref HEAD
[ +12 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[ ] master
[ +38 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ +2 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +53 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[ ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[ ] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[ ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ +2 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ +17 ms] executing: D:\Program Files\flutter\bin\cache\dart-sdk\bin\pub.bat run build_runner build --delete-conflicting-outputs --verbose
[INFO] Generating build script...
[INFO] Generating build script completed, took 292ms

[INFO] BuildDefinition:Initializing inputs
[INFO] BuildDefinition:Reading cached asset graph...
[INFO] BuildDefinition:Reading cached asset graph completed, took 107ms

[INFO] BuildDefinition:Checking for updates since last build...
[INFO] BuildDefinition:Checking for updates since last build completed, took 636ms

[INFO] Build:Running build...
[INFO] Build:Running build completed, took 18ms

[INFO] Build:Caching finalized dependency graph...
[INFO] Build:Caching finalized dependency graph completed, took 50ms

[SEVERE] sqfentity_gen:property_sqfentity on lib/database/database.dart (cached):

NoSuchMethodError: The getter 'index' was called on null.
Receiver: null
Tried calling: index
dart:core Object.noSuchMethod
package:sqfentity_gen/sqfentity_base.dart 3400:100 SqfEntityFieldBase.toFromMapString
package:sqfentity_gen/sqfentity_base.dart 983:36 SqfEntityObjectBuilder.__toFromMapString
package:sqfentity_gen/sqfentity_base.dart 595:34 SqfEntityObjectBuilder._toFromMapString
package:sqfentity_gen/sqfentity_base.dart 627:8 SqfEntityObjectBuilder.toString
package:sqfentity_gen/sqfentity_gen.dart 687:51 SqfEntityConverter.createEntites
package:sqfentity_gen/src/sqfentity_generator.dart 40:49 SqfEntityGenerator.generateForAnnotatedElement
package:source_gen/src/generator_for_annotation.dart 53:30 GeneratorForAnnotation.generate
package:source_gen/src/builder.dart 303:33 _generate
package:source_gen/src/builder.dart 79:15 _Builder._generateForLibrary
package:source_gen/src/builder.dart 71:11 _Builder.build
package:build runBuilder
package:build_runner_core/src/generate/build_impl.dart 485:19 _SingleBuild._runForInput...
package:build_runner_core/src/generate/performance_tracker.dart 302:15 _NoOpBuilderActionTracker.trackStage
package:build_runner_core/src/generate/build_impl.dart 483:23 _SingleBuild._runForInput..
package:build_runner_core/src/generate/build_impl.dart _SingleBuild._runForInput..
package:timing/src/timing.dart 222:44 NoOpTimeTracker.track
package:build_runner_core/src/generate/build_impl.dart 440:22 _SingleBuild._runForInput.
package:pool/pool.dart 127:28 Pool.withResource
package:build_runner_core/src/generate/build_impl.dart 436:17 _SingleBuild._runForInput
package:build_runner_core/src/generate/build_impl.dart 374:38 _SingleBuild._runBuilder.
dart:async Future.wait
package:build_runner_core/src/generate/build_impl.dart 373:36 _SingleBuild._runBuilder
package:build_runner_core/src/generate/build_impl.dart 319:20 _SingleBuild._runPhases..
dart:async _completeOnAsyncReturn
package:build_runner_core/src/generate/build_impl.dart _SingleBuild._matchingPrimaryInputs

#2 PackagesForwardCommand.runCommand (package:flutter_tools/src/commands/packages.dart:257:15)
#3 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1029:18)
#4 _rootRunUnary (dart:async/zone.dart:1198:47)
#5 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#6 _FutureListener.handleValue (dart:async/future_impl.dart:143:18) :7)
#7 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45) packages.dart:257:15)
#8 Future._propagateToListeners (dart:async/future_impl.dart:725:32) flutter_command.dart:1029:18)
#9 Future._completeWithValue (dart:async/future_impl.dart:529:5)
#10 Future._asyncCompleteWithValue. (dart:async/future_impl.dart:567:7)
#11 _rootRun (dart:async/zone.dart:1190:13) pl.dart:696:45)
#12 _CustomZone.run (dart:async/zone.dart:1093:19)
#13 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
#14 _CustomZone.bindCallbackGuarded. (dart:async/zone.dimpl.dart:567:7)art:1037:23)
#15 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#16 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#17 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:11art:1037:23)8:13)
#18 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5) 8:13)
art:169:5)

[ +262 ms] ensureAnalyticsSent: 256ms
[ +2 ms] Running shutdown hooks
[ +12 ms] Shutdown hooks complete
[ +1 ms] exiting with code 1

@jakemac53
Copy link
Contributor

This looks like an issue with the sqfentity_gen package, specifically that package is trying to use the index operator ([) on a null object. I would refile this issue on them https://github.com/hhtokpinar/sqfEntity/issues/new and attach the same stack trace.

It is possibly this line here https://github.com/hhtokpinar/sqfEntity/blob/master/sqfentity_gen/lib/sqfentity_base.dart#L3403, dartType[dbType.index].toString() (dartType may be null there?). Can't tell for sure as I don't see tags on the repo to put me at the exact state you are in so I can't match up the stack trace exactly.

@colinmcintyre
Copy link

@jakemac53 Thank you for looking into this. I have filed the issue with sqfentity and will see how we go. If you dont mind i will also grab your bottom paragraph to add to issue report.

Thanks

@jakemac53
Copy link
Contributor

Yep of course! We can also leave this open for now but if you can close it if/when the issue is resolved that would be appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants