create method
创建平台实例
Implementation
Platform create() {
final platformNode = settings.platformNode;
final name = switch (platformNode) {
final String e => e,
{'name': final String e} => e,
_ => throw const PlatformSettingsError(),
};
try {
switch (name) {
case 'feishu':
return Feishu(
appId: platformNode['app_id'] as String,
appSecret: platformNode['app_secret'] as String,
spreadsheetToken: platformNode['spreadsheet_token'] as String,
dio: _dio ?? Dio(),
);
}
} catch (e) {
if (e is PlatformSettingsError) rethrow;
throw PlatformSettingsError(name, e.toString());
}
throw UnsupportedPlatformError(name);
}