init method Null safety

Future<void> init(
  1. {bool enableStorage = true,
  2. bool autoInject = true}
)

This static method initializes a MotorFlutter instance and Injects it into Get state management.

Parameters

  • autoInject : Automatically injects the MotorFlutter instance into Get state management. Defaults to true.
  • enableStorage : Initializes GetStorage for MotorFlutter to use. Defaults to true.

Example

import 'package:motor_flutter/motor_flutter.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized(); // This is required for Flutter apps.
  await MotorFlutter.init(); // This initializes the MotorFlutter instance.
  runApp(MyApp()); // This is the entry point of the application.
}

Next Steps:

Implementation

static Future<void> init({bool enableStorage = true, bool autoInject = true}) async {
  if (autoInject) {
    await Get.putAsync(
      () => MotorFlutter()._init(enableStorage),
      permanent: true,
    );
  }
}