我正在尝试在 Flutter Web 应用程序中获取本地 IP 地址。在互联网上搜索我发现了这个包:get_ip0.4.0 - 它声明它在网络下工作。
我有这个功能:
Future<void> initPlatformState() async {
print("Test");
String ipAddress;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
ipAddress = await GetIp.ipAddress;
} on PlatformException {
ipAddress = 'Failed to get ipAddress.';
} on Exception {
print("Exception");
}
print("Ip: $ipAddress");
}
Run Code Online (Sandbox Code Playgroud)
我把它initState称为main.dart。
控制台只有输出Test,不输出IP或Exception.
有人已经用过这个包了吗?Web 应用程序是否有其他方式获取本地 IP?
(我使用的是MacOS)
我试图让 Mono 和 Gtk# 在 Windows 上工作。
当我尝试运行 mcs hello.cs -r:"C:\Program Files (x86)\Mono\lib\gtk-sharp-2.0\gtk-sharp.dll"
我收到以下错误:
hello.cs(11,9): error CS0012: The type Atk.Implementor' is defined in an assemb ly that is not referenced. Consider adding a reference to assemblyatk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f' C:\Program Files (x86)\Mono\lib\gtk-sharp- 2.0\gtk-sharp.dll(与之前错误相关的符号位置)hello.cs(11,9): error CS0012: The type GLib.IWrapper' is defined in an assembly that is not referenced. Consider adding a reference to assemblyglib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f ' C:\Program Files (x86)\Mono\lib\gtk-sharp-2.0\gtk-sharp.dll(与先前错误相关的符号位置)编译失败:2 个错误,0 个警告
这是我的 hello.cs:
using Gtk;
using System; …Run Code Online (Sandbox Code Playgroud)