0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

FlutterWebのUnsupported Platform系エラーの解決

Posted at

環境

Flutter 3.3.1
Dart 2.18.0

エラー内容

The following UnsupportedError was thrown building Builder:
Unsupported operation: Platform._operatingSystem

image.png

原因

iOSでもAndroidでもなく、Webで起動した場合、Platformオブジェクトを使うことができなくなるらしい。下記の部分をtry catchで囲んでしまえばよい。

import 'dart:io';
・・・
    // OS名を取得
    String os = Platform.operatingSystem;
    print("OS = $os");

    // OS判定
    bool isAndroid = Platform.isAndroid;
    print("isAndroid = $isAndroid");
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?