Flutter Platform Check

Flutter ‘Dart:io’ 기본으로 제공되는 라이브러리으로 현재 기기에 OS를 구별할 수 있다.

총 6개 Linux, MacOS, Windows, Fuchsia, IOS, Android를 구별할 수 있으며 이것을 통해 OS마다 각 디자인을 다르게 할 수 도 있다는 Flutter 장점이 있다.

코드

import 'dart:io';

main(){
  if(Platform.isAndroid){ # 변환 Type Bool
    print("android");
  }else if(Platform.isWindows){
    print("Windows");
  }else if(Platform.isIOS){
    print("IOS");
  }else if(Platform.isFuchsia){
    print("Fuchsia");
  }else if(Platform.isLinux){
    print("Linux");
  }else if(Platform.isMacOS){
    print("MacOS");
  }
}

답글 남기기

이메일 주소는 공개되지 않습니다.