flutter-test

How to Unit Test code that is dependent on 3rd-Party-Package in Flutter?

不羁的心 提交于 2020-05-16 01:57:31
问题 How can I test code in flutter, that is dependent on the path_provider plugin? When executing tests for code that is dependent on the path_provider plugin, I get the following error: MissingPluginException(No implementation found for method getStorageDirectory on channel plugins.flutter.io/path_provider) package:flutter/src/services/platform_channel.dart 319:7 MethodChannel.invokeMethod ===== asynchronous gap =========================== dart:async _asyncErrorWrapperHelper package: mypackage

How do I stub a function that does not belong to a class, during a widget test?

…衆ロ難τιáo~ 提交于 2020-05-15 05:43:12
问题 I am creating a flutter app that uses the native camera to take a photo, using the official flutter camera package (https://pub.dev/packages/camera). The app opens up a modal that loads a CameraPreview based on the the result of the availableCameras function from the package and a FloatingActionButton which takes a photo when pressed. While creating a widget test for this modal, I can not figure out how to stub the availableCameras function to return what I want during tests. I tried using

How to close Dialog using FlutterDriver

折月煮酒 提交于 2020-05-08 08:17:59
问题 Is there any way to close a dialog by " tapping it away ", i.e. tapping outside of the content to close it with Flutter Driver? My problem is that the dialog does not have any buttons that would close it. Instead the user is expected to either tap outside of it or use the back button. However, FlutterDriver does not have a "back" option. Hence, I am wondering how I would tap outside of the dialog in order to close it. 回答1: You would want to set the barrierDismissible property of the dialog to

How to close Dialog using FlutterDriver

笑着哭i 提交于 2020-05-08 08:14:18
问题 Is there any way to close a dialog by " tapping it away ", i.e. tapping outside of the content to close it with Flutter Driver? My problem is that the dialog does not have any buttons that would close it. Instead the user is expected to either tap outside of it or use the back button. However, FlutterDriver does not have a "back" option. Hence, I am wondering how I would tap outside of the dialog in order to close it. 回答1: You would want to set the barrierDismissible property of the dialog to

Unable to locate Android SDK

一世执手 提交于 2020-04-29 10:11:08
问题 I already had android studio and the android sdk installed,I later added flutter and flutter sdk. Here is my problem: When I run > flutter doctor It show's that I do not have Android SDK installed. 回答1: You can configure the Android SDK for your project using flutter config --android-sdk /path/to/android/sdk The PATH variable also should contain the SDK like export PATH=$PATH:/usr/local/opt/android-sdk/emulator:/usr/local/opt/android-sdk/build-tools/26.0.1:/usr/local/opt/android-sdk/platform

Unable to locate Android SDK

回眸只為那壹抹淺笑 提交于 2020-04-29 10:10:21
问题 I already had android studio and the android sdk installed,I later added flutter and flutter sdk. Here is my problem: When I run > flutter doctor It show's that I do not have Android SDK installed. 回答1: You can configure the Android SDK for your project using flutter config --android-sdk /path/to/android/sdk The PATH variable also should contain the SDK like export PATH=$PATH:/usr/local/opt/android-sdk/emulator:/usr/local/opt/android-sdk/build-tools/26.0.1:/usr/local/opt/android-sdk/platform

Images are not visible during flutter_driver tests

自作多情 提交于 2020-01-24 10:23:15
问题 When running UI tests with flutter driver the assets are not displayed on iPhone simulator. They are displayed when app is run in debug mode from VS Code. I tried to reproduce it on the example project generated by flutter create -i swift -a kotlin --androidx --org com.example example but without success. I followed exactly the same process of introducing flutter_driver tests in both apps according to this article. Unfortunately, in my app the images are not shown, and in example app they

How to make a task run in the background in Flutter

可紊 提交于 2020-01-24 05:49:04
问题 I have a music app that streams audio online. The only problem is it gets killed every time I exit the app which is not good for the user. They need it to keep running in the background even after exiting. How can I achieve this? 回答1: Can I run Dart code in the background of an Flutter app? Yes, you can run Dart code in a background process on both iOS and Android. For more information, see the Medium article Executing Dart in the Background with Flutter Plugins and Geofencing. 来源: https:/

how to refresh state on Navigator.Pop or Push in flutter

雨燕双飞 提交于 2020-01-16 05:24:05
问题 Here I have two pages first is called BSP_signup_terms page and the second is Bsp_Service_page . when I am on BSP_signup_terms on that page I have to select some checkbox based on the selected checkbox it will show me some data. but problem is that it will show me the complete data but when I get back to the BSP_signup_terms from Bsp_signup_page and I am changing the checkbox and then again when I am pressing next button it will not change the result it same as the previous result. Here is

Is it possible to access children/parent widgets from a given widget, in a Flutter test?

[亡魂溺海] 提交于 2020-01-14 07:03:37
问题 I'm writing unit and integration tests for Flutter. Is it possible to access children/parent widgets from a given widget? 回答1: Yes, you can use find.descendant and Element.ancestorWidgetOfExactType. Examples: // Finds a RichText widget that a descendant (child/grand-child/etc) of a // tab widget with text "Tab 1" find.descendant(of: find.text('Tab 1'), matching: find.byType(RichText)); // Finds a parent widget of type MyParentWidget. tester.element(find.byType(MyChildWidget))