Skip to content
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

Unit testing with ext storage not feasible with Platform.isAndroid #16

Open
tonywu1999 opened this issue Jul 9, 2021 · 1 comment
Open

Comments

@tonywu1999
Copy link

https://github.com/yasukotelin/ext_storage/blob/master/lib/ext_storage.dart#L33-L46

Instead of using Platform.isAndroid to check if the current Platform is Android, I'm proposing the following solution:

import 'package:flutter/foundation.dart' show defaultTargetPlatform, TargetPlatform;

if (defaultTargetPlatform != TargetPlatform.android) {
    throw UnsupportedError("Only android supported");
}

This will making widget testing with ext_storage easier because in tests, Platform.isAndroid always returns false. Whereas with defaultTargetPlatform != TargetPlatform.android, a tester could use debugDefaultTargetPlatformOverride to determine if the test environment is Android vs iOS:

testWidgets('test Android', (WidgetTester tester) async {
    debugDefaultTargetPlatformOverride = TargetPlatform.android;
    // Insert Test Code Here
    debugDefaultTargetPlatformOverride = null;

I can submit a PR for this if you would like.

@shatanikmahanty
Copy link

This package has not been updated for a long time, I was hoping the author will atleast update the flutter embedding to v2 but no commits on this repo since Apr 6,2020. If you could fork the code and upload it with improved code the community as well as me would find it very helpful. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants