init static method

Future<Nylo> init({
  1. Function? setup,
  2. dynamic setupFinished(
    1. Nylo nylo
    )?,
})

Initialize Nylo

Implementation

static Future<Nylo> init(
    {Function? setup, Function(Nylo nylo)? setupFinished}) async {
  const String ENV_FILE = String.fromEnvironment(
    'ENV_FILE',
    defaultValue: '.env',
  );
  await dotenv.load(fileName: ENV_FILE);

  Nylo _nylo = Nylo();

  if (setup == null) {
    if (setupFinished != null) {
      await setupFinished(_nylo);
    }
    return _nylo;
  }

  _nylo = await setup();

  if (setupFinished != null) {
    await setupFinished(_nylo);
  }
  return _nylo;
}