setup method
Implementation
Future<MApplicationChecker> setup() async {
// checker
MApplicationChecker checker = MApplicationChecker();
// config
final config = await widget.configLoader(option: widget.option);
// language
appContext.set(contextLanguage, widget.option.language);
// grpc client
if (config.plugin.grpcClient != null) {
log("grpc client ...");
final grpcClient = MGrpcClient.load(config: config.plugin.grpcClient!);
appContext.set(contextGrpcClient, grpcClient);
}
// gps
if (config.plugin.gps != null) {
log("gps ...");
final gps = await MGps.load(config: config.plugin.gps!);
if (gps != null) {
appContext.set(contextGps, gps);
}
}
// sound
if (config.plugin.sound != null) {
log("sound ...");
final sound = await MSound.load(config: config.plugin.sound!);
appContext.set(contextSound, sound);
}
// rest
if (config.plugin.rest != null) {
log("rest ...");
final rest = MRest.load(config: config.plugin.rest!);
appContext.set(contextRest, rest);
}
// internet check
checker.internet = await InternetConnectionChecker().hasConnection;
// setup
if (widget.setup != null) {
await widget.setup!(appContext);
}
// initial route
checker.initialRoute = await widget.initialRoute(appContext);
// return
return checker;
}