使用 raw.githubusercontent.com 复制源代码

Copying source code using raw.githubusercontent.com

比如我要复制这个link中的用户代码。我必须使用颤动来做到这一点。 https://raw.githubusercontent.com/iampawan/FlutterExampleApps/master/main.dart

也许我需要将其复制到 txt 文件中。 我不知道该用什么。我搜索了但不够了解。如果有任何其他选项可以复制原始代码,我也想知道。

谢谢。

您可以为此使用 HTTP Package or the DIO Package。我推荐你使用 DIO。

您可以向您需要的 URL 发送 GET 请求,它将 return 您请求的文件内容。

DIO 示例:

Response response;
var dio = Dio();
response = await dio.get('https://raw.githubusercontent.com/iampawan/FlutterExampleApps/master/main.dart');
print(response.data.toString());

有关更多信息和用法,请参阅已发布的插件链接。