투케이2K

237. (Flutter/플러터) [Mac] : [skill] : [device_info_plus] 안드로이드 디바이스 빌드 정보 확인 - Android Build Info 본문

Flutter

237. (Flutter/플러터) [Mac] : [skill] : [device_info_plus] 안드로이드 디바이스 빌드 정보 확인 - Android Build Info

투케이2K 2024. 7. 1. 21:06

[개발 환경 설정]

개발 툴 : AndroidStudio

개발 언어 : Dart

 
 

[소스 코드]

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:permission_handler/permission_handler.dart';
import 'dart:developer';
import 'dart:core';
import 'dart:io';
import 'dart:convert';
import 'dart:typed_data';
import 'package:url_launcher/url_launcher.dart';
// --------------------------------------
import 'package:device_info_plus/device_info_plus.dart';
// --------------------------------------



// -----------------------------------------------------------------------------------------
// TODO [main] : [application 의 진입점 역할]
// -----------------------------------------------------------------------------------------
void main() async {
  print("");
  print("-------------------------------------------------------");
  print("Application :: Start");
  print("-------------------------------------------------------");
  print("");

  // [WidgetsFlutterBinding 초기화]
  WidgetsFlutterBinding.ensureInitialized();

  // [안드로이드 플랫폼]
  if (Platform.isAndroid){

    // [DeviceInfoPlugin 객체 생성]
    DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();

    // [리턴 값을 받을 변수 선언]
    var deviceData = <String, dynamic>{};

    // [디바이스 정보 확인]
    deviceData = _readAndroidBuildData(await deviceInfoPlugin.androidInfo);

    // [로그 출력 수행]
    print("");
    print("-------------------------------------------------------");
    print("deviceData :: ${deviceData}");
    print("-------------------------------------------------------");
    print("");

  }
}





// -----------------------------------------------------------------------------------------
// TODO [디바이스 정보 불러오기]
// -----------------------------------------------------------------------------------------
Map<String, dynamic> _readAndroidBuildData(AndroidDeviceInfo build) {
  return <String, dynamic>{
    'version.securityPatch': build.version.securityPatch,
    'version.sdkInt': build.version.sdkInt,
    'version.release': build.version.release,
    'version.previewSdkInt': build.version.previewSdkInt,
    'version.incremental': build.version.incremental,
    'version.codename': build.version.codename,
    'version.baseOS': build.version.baseOS,
    'board': build.board,
    'bootloader': build.bootloader,
    'brand': build.brand,
    'device': build.device,
    'display': build.display,
    'fingerprint': build.fingerprint,
    'hardware': build.hardware,
    'host': build.host,
    'id': build.id,
    'manufacturer': build.manufacturer,
    'model': build.model,
    'product': build.product,
    'supported32BitAbis': build.supported32BitAbis,
    'supported64BitAbis': build.supported64BitAbis,
    'supportedAbis': build.supportedAbis,
    'tags': build.tags,
    'type': build.type,
    'isPhysicalDevice': build.isPhysicalDevice,
    'systemFeatures': build.systemFeatures,
    'serialNumber': build.serialNumber,
    'isLowRamDevice': build.isLowRamDevice,
  };
}
 

[결과 출력]

 

 

반응형
Comments