diff --git a/floor/pubspec.yaml b/floor/pubspec.yaml index 6d59905a..9f04c86d 100644 --- a/floor/pubspec.yaml +++ b/floor/pubspec.yaml @@ -29,4 +29,4 @@ dev_dependencies: git: url: git://github.com/tekartik/sqflite_more ref: dart2 - path: sqflite_ffi_test \ No newline at end of file + path: sqflite_ffi_test diff --git a/floor_generator/lib/misc/type_utils.dart b/floor_generator/lib/misc/type_utils.dart index 17616ec5..fff8e967 100644 --- a/floor_generator/lib/misc/type_utils.dart +++ b/floor_generator/lib/misc/type_utils.dart @@ -16,6 +16,11 @@ extension SupportedTypeChecker on DartType { } } +extension Uint8ListTypeChecker on DartType { + @nonNull + bool get isUint8List => getDisplayString() == 'Uint8List'; +} + extension StreamTypeChecker on DartType { @nonNull bool get isStream => _streamTypeChecker.isExactlyType(this); diff --git a/floor_generator/lib/processor/entity_processor.dart b/floor_generator/lib/processor/entity_processor.dart index 6bf74d2f..6e632cbc 100644 --- a/floor_generator/lib/processor/entity_processor.dart +++ b/floor_generator/lib/processor/entity_processor.dart @@ -266,7 +266,7 @@ class EntityProcessor extends Processor { return '$parameterValue as String'; } else if (parameterType.isDartCoreInt) { return '$parameterValue as int'; - } else if (parameterType.getDisplayString() == 'Uint8List') { + } else if (parameterType.isUint8List) { return '$parameterValue'; } else { return '$parameterValue as double'; // must be double diff --git a/floor_generator/lib/processor/field_processor.dart b/floor_generator/lib/processor/field_processor.dart index 29687b3c..5ec9a04c 100644 --- a/floor_generator/lib/processor/field_processor.dart +++ b/floor_generator/lib/processor/field_processor.dart @@ -66,7 +66,7 @@ class FieldProcessor extends Processor { return SqlType.INTEGER; } else if (type.isDartCoreDouble) { return SqlType.REAL; - } else if (type.getDisplayString() == 'Uint8List') { + } else if (type.isUint8List) { return SqlType.BLOB; } throw InvalidGenerationSourceError( diff --git a/floor_generator/test/processor/field_processor_test.dart b/floor_generator/test/processor/field_processor_test.dart index 48f8d1e8..ea7343cb 100644 --- a/floor_generator/test/processor/field_processor_test.dart +++ b/floor_generator/test/processor/field_processor_test.dart @@ -30,7 +30,7 @@ void main() { test('Process Uint8List field', () async { final fieldElement = await _generateFieldElement(''' - @ColumnInfo(name : 'data', nullable:false) + @ColumnInfo(name: 'data', nullable: false) final Uint8List bytes; ''');