init method Null safety

Future<MotorFlutter> init(
  1. [ResponseCallback<InitializeResponse>? callback]
)

It initializes the motor flutter.

Args: callback (ResponseCallback): A callback function that will be called when the response is received.

Implementation

Future<MotorFlutter> init([ResponseCallback<InitializeResponse>? callback]) async {
  final peerInfo = await PeerInformation.fetch();
  final req = peerInfo.toInitializeRequest(enableLibp2p: true);
  final resp = await MotorFlutterPlatform.instance.init(req);
  if (callback != null) {
    callback(resp);
  }
  return this;
}