How to get host name in flutter for windows?
Asked Answered
D

1

5

I am working on a flutter application that connects to the MQTT client on the desktop it is opened on. I want to dynamically get the host name of the desktop and connect to it instead of the user having to enter it manually. Thanks in advance.

Dustheap answered 10/11, 2020 at 16:45 Comment(0)
E
7

https://api.flutter.dev/flutter/dart-io/Platform-class.html

import 'dart:io' show Platform, stdout;

void main() {
  // Get the hostname as a string.
  String hostname = Platform.localHostname;
  
}
Editheditha answered 6/7, 2021 at 20:14 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.