flutter-test

Flutter Driver: Test BottomNavigationBarItem

那年仲夏 提交于 2019-12-11 17:45:53
问题 how do I test BottomNavigationBarItems via FlutterDriver ? FlutterDriver allows accessing Widgets via text , byValueKey , byTooltip and byType . But none of these methods work out for my App because of following reasons: text : The App is localized and I need to test the App in multiple languages. byValueKey : BottomNavigationBarItems do not have key properties. byTooltip : BottomNavigationBarItems do not have toolTip properties. byType : byType only returns the first match of the type and no

How do I test an assertion?

你离开我真会死。 提交于 2019-12-11 15:33:31
问题 I found out how you can test an exception or error: https://stackoverflow.com/a/54241438/6509751 But how do I test that the following assert works correctly? void cannotBeNull(dynamic param) { assert(param != null); } I tried the following, but it does not work. The assertion is simply printed out and the test fails: void main() { test('cannoBeNull assertion', () { expect(cannotBeNull(null), throwsA(const TypeMatcher<AssertionError>())); }); } 回答1: There are two key aspects to this: Pass a

How to optimize the Flutter App size?

非 Y 不嫁゛ 提交于 2019-12-11 08:44:48
问题 I am a native Android developer and I started using flutter SDK. I developed a simple app by following official flutter doc. But I found that the debug app size is 46 MB which is too large for this simple app. Is there any way to optimize the app size? because Flutter app size is larger than the native Android App. 回答1: Flutter debug app is very big, to optimize the app you should build it as release version by using flutter build apk (flutter build defaults to --release). Preparing an

how specify Window for tests?

可紊 提交于 2019-12-11 04:09:09
问题 I need the screen in the test to look the same as on the physical device(or simulator). How can I do it? In my case device id Iphone SE. I wrote a test that saves a screenshot to disk: testWidgets('test', (WidgetTester tester) async { final AutomatedTestWidgetsFlutterBinding binding = tester.binding; binding.renderView.configuration = TestViewConfiguration(size: Size(640, 1136)); var widget = Scaffold( appBar: AppBar(title: Text('title'),), body: Column(children: <Widget>[ RaisedButton( child

How to mimic a pressing ENTER on a TextField in Flutter Tests

感情迁移 提交于 2019-12-10 15:59:05
问题 Given that tester.enterText will allow me to enter the text on a TextField in a flutter test, how would I mock pressing the DONE key on the android keyboard or pressing ENTER on my keyboard inside the textfield? This would also be equivalent to checking for the pressing of the DONE button on the IOS/android keyboard 回答1: I found the implementation in the flutter repo tests @ https://github.com/flutter/flutter/blob/7e445a17324ee7e615ef2c886d0cb9407853f338/packages/flutter/test/widgets/editable

Alert Dialog with Rounded corners in flutter

不羁岁月 提交于 2019-12-08 23:16:35
问题 I am trying to create an alert dialog with rounded corners in Flutter same as below screenshot. also add my code here, but my output is exactly different from the expected one. anyone, please help me. Expected Alert Dialog my code is here. void _showAlert() { AlertDialog dialog = new AlertDialog( content: new Container( width: 260.0, height: 230.0, decoration: new BoxDecoration( shape: BoxShape.rectangle, color: const Color(0xFFFFFF), borderRadius: new BorderRadius.all(new Radius.circular(32

Flutter: Timer Issue During Testing

橙三吉。 提交于 2019-12-06 03:39:03
I have a periodic timer in one of my StatelessWidget 's. Without going too much into detail, here is a snippet of code producing a timer: class AnniversaryHomePage extends StatelessWidget { . . . void _updateDisplayTime(StoreInheritedWidget inheritedWidget) { String anniversaryString = inheritedWidget.prefs.getString('anniversaryDate'); inheritedWidget.store.dispatch(DateTime.parse(anniversaryString)); } /// Widget Methods @override Widget build(BuildContext context) { final inheritedWidget = StoreInheritedWidget.of(context); new Timer.periodic(this.refreshRate, (Timer timer) =>

How to wait for a future to complete in Flutter widget test?

本秂侑毒 提交于 2019-12-04 05:40:22
I am trying to perform a widget test, specifically navigation test. I am using bloc architecture, setting a stream on the bloc triggers a series of events inside the bloc, gets session info from the server call (which returns a future of session info object), on successful server call a login stream is set and the widget has a stream subscription to this stream and navigates to the next screen. I am using mockito to mock the server call and stubbing the server call to return a future of success response. The problem is the when I am calling pumpAndSettle() it is getting timed out as it is not

Device list doesn't shows in Android Studio using Flutter

喜夏-厌秋 提交于 2019-12-03 08:46:28
问题 I tried to develop app using Flutter(using Android studio IDE).Add flutter plugin & flutter SDK in studio and Everything is configured but emulator / real time device are not listed. Its shows error like "Unable to list devices: Unable to discover Android devices. Please run "flutter doctor" to diagnose potential issues" Ref link : https://flutter.io/setup-windows/#android-setup https://flutter.io/get-started/test-drive/#androidsstudio 回答1: configure flutter in terminal to detect Android SDK

Device list doesn't shows in Android Studio using Flutter

这一生的挚爱 提交于 2019-12-03 00:17:13
I tried to develop app using Flutter(using Android studio IDE).Add flutter plugin & flutter SDK in studio and Everything is configured but emulator / real time device are not listed. Its shows error like "Unable to list devices: Unable to discover Android devices. Please run "flutter doctor" to diagnose potential issues" Ref link : https://flutter.io/setup-windows/#android-setup https://flutter.io/get-started/test-drive/#androidsstudio configure flutter in terminal to detect Android SDK and Android Studio: $ flutter config --android-sdk /path/to/android/sdk $ flutter config --android-studio