惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Cloudflare Blog
U
Unit 42
D
Docker
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
Recent Announcements
Recent Announcements
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
V
Visual Studio Blog
I
InfoQ
Google DeepMind News
Google DeepMind News
小众软件
小众软件
L
LangChain Blog
C
Check Point Blog
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
J
Java Code Geeks
罗磊的独立博客

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Platform Identification in Dart
Mathieu Kerjouan · 2026-06-16 · via DEV Community
Cover image for Platform Identification in Dart

Mathieu Kerjouan

During the last weeks, I tried to learn a lot from Dart and Flutter, but even after a bit less than 1 month, I still don't know some basic stuff. When I was dealing with command line arguments parsing, I was thinking "how to get the goddamn program name". You know, the string you can simply have with argv[0] 1 in C or with the functions exported by the init module in Erlang. In Dart, you will require dart:io package and the Platform class.

Let write a small program to print out what kind of information this class store.

import 'dart:io' show Platform;

void main(List<String> arguments) {
  final info = systemInfo();
  for (final key in info.keys) {
    print("Platform.${key}: ${info[key]}");
  }
}

Map<String, dynamic> systemInfo() {
  return {
    "environment": Platform.environment,
    "executable": Platform.executable,
    "executableArguments": Platform.executableArguments,
    "isAndroid": Platform.isAndroid,
    "isFuchsia": Platform.isFuchsia,
    "isIOS": Platform.isIOS,
    "isLinux": Platform.isLinux,
    "isWindows": Platform.isWindows,
    "lineTerminator": Platform.lineTerminator,
    "localeName": Platform.localeName,
    "localHostname": Platform.localHostname,
    "numberOfProcessors": Platform.numberOfProcessors,
    "operatingSystem": Platform.operatingSystem,
    "operatingSystemVersion": Platform.operatingSystemVersion,
    "packageConfig": Platform.packageConfig,
    "pathSeparator": Platform.pathSeparator,
    "resolvedExecutable": Platform.resolvedExecutable,
    "script": Platform.script,
    "version": Platform.version
  };
}

The function systemInfo() returns a Map<String, dynamic> where the keys of the maps are simply a reference to the name of the Platform class attributes. Nothing complex there. When executed it will print the content of all attributes line by line.

Platform.environment: {
  SHELL: /bin/bash,
  ...
}

  • Platform.executable returns the name of the executable used to execute the application as a String, in our case, I am using dart run command (and then use the Dart VM);
Platform.executable: /.asdf/installs/flutter/3.41.7-stable/bin/cache/dart-sdk/bin/dart

  • Platform.executableArguments returns the arguments passed to the application as a List<String>, again, in our case, we are using the Dart VM, most of the arguments directly related to it;
Platform.executableArguments: [
  --resolved_executable_name=/.asdf/installs/flutter/3.41.7-stable/bin/cache/dart-sdk/bin/dart, 
  --executable_name=/.asdf/installs/flutter/3.41.7-stable/bin/cache/dart-sdk/bin/dart,
  --packages=.dart_tool/package_config.json
]

  • Platform.isLinux returns a Bool, it's true if it's a Linux system, else it's false. Other attributes like that are exposed to check easily what kind of systems is being used;
Platform.isLinux: true

Platform.localeName: en_US.UTF-8

Platform.localHostname: localhost

Platform.numberOfProcessors: 16

Platform.operatingSystem: linux

  • Platform.operatingSystemVersion returns the version of the system used as String, for Linux, it will be the version of the kernel, the same kind of string that could be returned by uname;
Platform.operatingSystemVersion: Linux 6.19.13+parrot7-amd64 #1 SMP PREEMPT_DYNAMIC Parrot 6.19.13-1parrot1 (2026-04-30)

Platform.resolvedExecutable: /.asdf/installs/flutter/3.41.7-stable/bin/cache/dart-sdk/bin/dart

  • Platform.script returns the script (Dart application) running in the current isolate (in our the default one) as String;
Platform.script: file:///tmp/dart/system_info/.dart_tool/pub/bin/system_info/system_info.dart-3.11.5.snapshot

Platform.version: 3.11.5 (stable) (Wed Apr 15 00:36:32 2026 -0700) on "linux_x64"

Sadly, one will not find a lot of resources about platform detection, at least, directly on Dart. Some posts can be found on the web regarding Flutter integration on different platform, but not so much when it comes to create a command line interface tool. Here a list containing other resources.

Happy hack and have fun!


Cover Image by GoRaivis Photography on Unsplash


  1. The function called at program startup is named main. The implementation declares no prototype for this function. It can be defined with no parameters or with two parameters (referred to here as argc and argv, though any names may be used, as they are local to the function in which they are declared). [...] The value of argc shall be nonnegative. argv[argc] shall be a null pointer. From ANSI-C Specification ↩