easy_mock_device_info 0.1.0 copy "easy_mock_device_info: ^0.1.0" to clipboard
easy_mock_device_info: ^0.1.0 copied to clipboard

Readable test mock for device_info_plus, built on easy_mock_channel. Set the device info the channel returns, with no dependency on device_info_plus — it speaks the channel's raw map.

easy_mock_device_info #

A readable test mock for device_info_plus, built on easy_mock_channel. It scripts the single getDeviceInfo channel call, so it has no dependency on device_info_plus.

Usage #

import 'package:easy_mock_device_info/easy_mock_device_info.dart';

mockDeviceInfo.init();                                   // harness usually does this
mockDeviceInfo.set(name: 'Pixel 7', manufacturer: 'Google', model: 'Pixel 7', id: 'd1');

set({name, manufacturer, model, id, extra}) — the named fields are the ones the app reads; extra adds any other key. device_info_plus decodes the same map differently per platform (Android/iOS/macOS …).

Heads-up: if your code branches on dart:io Platform.isAndroid/isIOS, that is fixed to the host OS in VM tests and isn't overridable — so the Android/iOS-specific paths may not run, and only the generic DeviceInfoPlugin().deviceInfo call reaches this mock.

Needs the Flutter test binding (inside testWidgets, or TestWidgetsFlutterBinding.ensureInitialized() in a plain test).

0
likes
140
points
120
downloads

Documentation

API reference

Publisher

verified publisherahmedomar.com.ly

Weekly Downloads

Readable test mock for device_info_plus, built on easy_mock_channel. Set the device info the channel returns, with no dependency on device_info_plus — it speaks the channel's raw map.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

easy_mock_channel, flutter, flutter_test

More

Packages that depend on easy_mock_device_info