Steps to Reproduce
When trying to generate a TypeAdapter with a Uint8list inside it throws the following error.
$ flutter packages pub run build_runner build --delete-conflicting-outputs -v
Error running TypeAdapterGenerator
RangeError (index): Invalid value: Valid value range is empty: 0
dart:core List.[]
package:hive_generator/src/class_builder.dart 86:38 ClassBuilder._castIterable
package:hive_generator/src/class_builder.dart 69:36 ClassBuilder._cast
package:hive_generator/src/class_builder.dart 59:34 ClassBuilder.buildRead
package:hive_generator/src/type_adapter_generator.dart 24:19 TypeAdapterGenerator.generateForAnnotatedElement
package:source_gen/src/generator_for_annotation.dart 47:30 GeneratorForAnnotation.generate
package:source_gen/src/builder.dart 280:35 _generate
package:source_gen/src/builder.dart 73:15 _Builder._generateForLibrary
package:source_gen/src/builder.dart 67:11 _Builder.build
package:build runBuilder
package:build_runner_core/src/generate/build_impl.dart 477:19 _SingleBuild._runForInput.<fn>.<fn>.<fn>
package:build_runner_core/src/generate/performance_tracker.dart 300:15 _NoOpBuilderActionTracker.trackStage
package:build_runner_core/src/generate/build_impl.dart 475:23 _SingleBuild._runForInput.<fn>.<fn>
package:timing/src/timing.dart 222:44 NoOpTimeTracker.track
package:build_runner_core/src/generate/build_impl.dart 434:22 _SingleBuild._runForInput.<fn>
package:pool/pool.dart 127:28 Pool.withResource
package:build_runner_core/src/generate/build_impl.dart 430:17 _SingleBuild._runForInput
package:build_runner_core/src/generate/build_impl.dart 378:38 _SingleBuild._runBuilder.<fn>
dart:async Future.wait
package:build_runner_core/src/generate/build_impl.dart 377:36 _SingleBuild._runBuilder
dart:async _AsyncAwaitCompleter.start
package:build_runner_core/src/generate/build_impl.dart 375:40 _SingleBuild._runBuilder
package:build_runner_core/src/generate/build_impl.dart 323:20 _SingleBuild._runPhases.<fn>.<fn>
dart:async _completeOnAsyncReturn
package:build_runner_core/src/generate/build_impl.dart _SingleBuild._matchingPrimaryInputs
[SEVERE] Build:
Failed after 604ms
pub finished with exit code 1
#0 throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
#1 pubInteractively (package:flutter_tools/src/dart/pub.dart:191:5)
<asynchronous suspension>
#2 PackagesPassthroughCommand.runCommand (package:flutter_tools/src/commands/packages.dart:227:11)
<asynchronous suspension>
#3 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:490:18)
#4 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#5 _rootRunUnary (dart:async/zone.dart:1132:38)
#6 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#7 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#8 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#9 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#10 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#11 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:552:7)
#12 _rootRun (dart:async/zone.dart:1124:13)
#13 _CustomZone.run (dart:async/zone.dart:1021:19)
#14 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#15 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#16 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#17 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#18 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:116:13)
#19 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:173:5)
Code sample
part 'ThumbnailPicture.g.dart';
class ThumbnailPicture extends StatefulWidget {
@HiveField(0)
Uint8List byteData;
@override
_ThumbnailPictureState createState() => _ThumbnailPictureState();
}
Version
Thanks for reporting this. The bug is fixed with the newest version of hive_generator.
Thanks Leism for the fast response! :)
Most helpful comment
Thanks for reporting this. The bug is fixed with the newest version of
hive_generator.