get static method

Future<CpuType?> get()

Determines CPU type of the current process.

In browsers, attempts to determine the CPU using browser APIs.

Returns null if the type is unknown.

You should use CpuType.getSync if you need the result synchronously.

Example

import 'package:os/os_cpu.dart';

Future<void> main() async {
  final cpuType = await CpuType.get();
  print('CPU type: $cpuType');
}

Implementation

static Future<CpuType?> get() {
  final oldFuture = _cpuTypeFuture;
  if (oldFuture != null) {
    return oldFuture;
  }
  final newFuture = getCpuType();
  _cpuTypeFuture = newFuture;
  newFuture.then((value) {
    _cpuType ??= value;
  });
  return newFuture;
}