Skip to content

device_info null error on Android #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lff5 opened this issue Mar 24, 2021 · 2 comments
Closed

device_info null error on Android #188

lff5 opened this issue Mar 24, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@lff5
Copy link

lff5 commented Mar 24, 2021

Hi
This code throws. See exception details here: flutter/flutter#78580.

Restarted application in 1,870ms.
I/flutter ( 5940): Instance of 'Future<AndroidDeviceInfo>'
E/flutter ( 5940): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: type 'Null' is not a subtype of type 'String'
E/flutter ( 5940): #0      new List.from (dart:core-patch/array_patch.dart:40:5)
E/flutter ( 5940): #1      AndroidDeviceInfo._fromList
package:device_info_plus_platform_interface/model/android_device_info.dart:144
E/flutter ( 5940): #2      AndroidDeviceInfo.fromMap
package:device_info_plus_platform_interface/model/android_device_info.dart:137
E/flutter ( 5940): #3      MethodChannelDeviceInfo.androidInfo
package:device_info_plus_platform_interface/method_channel/method_channel_device_info.dart:19
E/flutter ( 5940): <asynchronous suspension>
E/flutter ( 5940): #4      DeviceInfoPlugin.androidInfo
package:device_info_plus/device_info_plus.dart:65
E/flutter ( 5940): <asynchronous suspension>
E/flutter ( 5940):

Minimal reproducible code:
Define sdk: '>=2.12.0 <3.0.0' in pubspec.yaml, otherwise the issue will not occur.
Running on Android Emulator qemu-system-x86_64

import 'package:flutter/material.dart';
import 'package:device_info_plus/device_info_plus.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  final info = DeviceInfoPlugin().androidInfo;
  print(info);
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: Center(
          child: Text('Flutter Demo Home Page'),
        ),
      ),
    );
  }
}

Doctor:
[✓] Flutter (Channel stable, 2.0.3, on Mac OS X 10.14.6 18G6032 darwin-x64, locale en-EE)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[!] Xcode - develop for iOS and macOS
! Xcode 11.3.0 out of date (12.0.1 is recommended).
Download the latest version or update via the Mac App Store.
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.54.3)
[✓] Connected device (2 available)

@lff5 lff5 added the bug Something isn't working label Mar 24, 2021
@iqfareez
Copy link

Duplicate of #184 ?

@lff5
Copy link
Author

lff5 commented Mar 26, 2021

Yes. its a duplicate. Closing

@lff5 lff5 closed this as completed Mar 26, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants