check device in flutter

To check the device in Flutter, you can use the DeviceInfoPlugin package. Here's an example of how to use it:

  1. First, add the device_info_plus package to your pubspec.yaml file:
dependencies:
  device_info_plus: ^2.1.0
  1. Run flutter pub get to fetch the package.

  2. Import the package in your Dart file:

import 'package:device_info_plus/device_info_plus.dart';
  1. Use the DeviceInfoPlugin to get the device information:
void getDevice() async {
  DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
  if (Platform.isAndroid) {
    AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
    print('Device: ${androidInfo.model}');
    print('Android version: ${androidInfo.version.release}');
  } else if (Platform.isIOS) {
    IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
    print('Device: ${iosInfo.utsname.machine}');
    print('iOS version: ${iosInfo.systemVersion}');
  }
}
  1. Call the getDevice function to retrieve the device information.

Please note that the device_info_plus package provides device information for both Android and iOS platforms. You can access properties like the device model and the operating system version using the androidInfo and iosInfo objects, respectively.