appwrite/sdk-for-dart

๐Ÿ› Bug Report: createFloatAttribute() 'toDouble' was called on null.

stonith404 opened this issue ยท 3 comments

๐Ÿ‘Ÿ Reproduction steps

Execute the following function:

database.createFloatAttribute(
          collectionId: "collection",
          key: "someKey",
          xrequired: true)

๐Ÿ‘ Expected behavior

The function should be executed without an error.

๐Ÿ‘Ž Actual Behavior

The function returns:

NoSuchMethodError: The method 'toDouble' was called on null.
Receiver: null
Tried calling: toDouble()
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:68:5)
#1      new AttributeFloat.fromMap (package:dart_appwrite/src/models/attribute_float.dart:49:32)
#2      Database.createFloatAttribute (package:dart_appwrite/services/database.dart:279:34)
<asynchronous suspension>

As I can see the method toDouble is called on parameter that is not required. The problem is the min,max or xdefault parameter.

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

V0.12

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

@wess Moved.

Can confirm this behaviour

factory AttributeFloat.fromMap(Map<String, dynamic> map) {
    return AttributeFloat(
      key: map['key'].toString(),
      type: map['type'].toString(),
      status: map['status'].toString(),
      xrequired: map['required'],
      array: map['array'],
      min: map['min'].toDouble(),
      max: map['max'].toDouble(),
      xdefault: map['default'].toDouble(),
    );
  }

xdefault isn't required, therefore it can be null

Should be fixed on dart_appwrite: 4.0.2