LondonX / clash_flt

Flutter Clash plugin
Other
41 stars 23 forks source link

I/flutter (11904): [ClashFlt]applyConfig failed!!! profilePath is null. #2

Closed kwucheuwkzbAks closed 1 year ago

kwucheuwkzbAks commented 1 year ago

i alredy downloaded yaml files I/flutter (11904): [ClashFlt]applyConfig failed!!! profilePath is null.

LondonX commented 1 year ago

Did you called ClashFlt.downloadProfile to download yaml? if you did you should check the return value, return false means download failed. if you didn't call, you can set the profilePath by setting ClashFlt.instance.profileFile.value

Here is the code of applyConfig

Future<bool> _applyConfig() async {
  final clashHome = homeDir.path;
  final profilePath = profile.value?.filePath;
  final countryDBPath = countryDBFile.value?.path;
  final groupName = selectedProxyGroupName.value;
  final proxyName = selectedProxyName.value;
  if (profilePath == null) {
    _debugPrint("[ClashFlt]applyConfig failed!!! profilePath is null.");
    return false;
  }
  if (countryDBPath == null) {
    _debugPrint("[ClashFlt]applyConfig failed!!! countryDBPath is null.");
    return false;
  }
  if (groupName == null) {
    _debugPrint("[ClashFlt]applyConfig failed!!! groupName is null.");
    return false;
  }
  if (proxyName == null) {
    _debugPrint("[ClashFlt]applyConfig failed!!! proxyName is null.");
    return false;
  }
  final map = {
    "clashHome": clashHome,
    "profilePath": profilePath,
    "countryDBPath": countryDBPath,
    "groupName": groupName,
    "proxyName": proxyName,
    "allowStartFromIOSSettings": allowStartFromIOSSettings,
  };
  final cfgJson = json.encode(map);
  _debugPrint("[ClashFlt]applyConfig: $cfgJson");
  _channel.applyConfig(map);
  return true;
}
kwucheuwkzbAks commented 1 year ago

clash for windows worked! ProfileURL