Amit Madgi
Amit Madgi

Reputation: 51

How to get host name in flutter for windows?

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.

Upvotes: 5

Views: 3629

Answers (1)

André Gomes
André Gomes

Reputation: 71

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;
  
}

Upvotes: 7

Related Questions