# fromBuffer static method

Portrait fromBuffer(

1. Uint8List? data

)

Imports the portrait object from a buffer.

param data Buffer to import the portrait object from. return The newly created portrait. throws FaceException An error has occurred during Face Library execution.

## Implementation

    static Portrait fromBuffer(Uint8List? data) {
      Portrait portrait = Portrait();
      Pointer<UnsignedChar>? pData;
      if (data != null) {
      	pData = calloc.allocate<UnsignedChar>(data.length);
      	pData.cast<Uint8>().asTypedList(data.length).setAll(0, data);
      }
      try {
        var err = faceSDK.id3FacePortrait_FromBuffer(portrait.handle, pData ?? nullptr, data?.length ?? 0);
        if (err != FaceError.success.value) {
          portrait.dispose();
          throw FaceException(err);
        }
        return portrait;
      } finally {
        if (pData != null) {
          calloc.free(pData);
        }
      }
    }