Questions tagged [flutter-test]

Flutter-Test contains tests related to Flutter app including Unit tests, Widget test and end-to-end integration tests using Flutter-Driver.

Flutter officially highlights 3 different types of testing as mentioned here: https://flutter.dev/docs/testing

Unit tests: A unit test tests a single function, method, or class.

Widget tests: A widget test (in other UI frameworks referred to as component test) tests a single widget.

Integration tests: An integration test tests a complete app or a large part of an app.

1961 questions
28
votes
6 answers

Error: RenderBox was not laid out, Failed assertion: line 1940 pos 12: 'hasSize'

I can't fix this error RenderBox was not laid out: RenderPointerListener#2b92a relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 'package:flutter/src/rendering/box.dart': Failed assertion: line 1940 pos 12: 'hasSize'. The relevant…
25
votes
1 answer

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

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…
xpeldev
  • 1,812
  • 2
  • 12
  • 23
25
votes
3 answers

Flutter - Load assets for tests

Not sure if it's a limitation or something, but below code does not load anything. I have some data driven behaviour that I'd like to test isolated. class Loader import 'dart:async'; import 'package:flutter/services.dart' show rootBundle; class…
Victor Hugo Montes
  • 1,270
  • 1
  • 17
  • 28
24
votes
2 answers

Can anyone tell the difference of "flutter_bloc" and "bloc" packages in Flutter

I am getting started with Bloc in Flutter. Can anyone tell what is really "flutter_bloc" and "bloc" packages I have these questions. are they same. when/how to use this. Thank you
24
votes
4 answers

Is there an easy way to find particular text built from RichText in a Flutter test?

For example, I may have one RichText in current widget tree, that looks like RichText( text: TextSpan( text: 'Hello ', style: DefaultTextStyle.of(context).style, children: [ TextSpan(text: 'bold', style:…
Wei Song
  • 1,517
  • 3
  • 11
  • 9
23
votes
2 answers

error: Target of URI doesn't exist: 'package:test/test.dart'

Since the latest flutter update my tests are broken. It looks like the Dart test framework isn't available anymore: error: Target of URI doesn't exist: 'package:test/test.dart'.
Soundbytes
  • 1,149
  • 9
  • 17
22
votes
5 answers

Running all unit tests in Dart

I'm working on a Flutter project and trying to find the best way to structure my tests. Typically I structure tests to mirror the directory structure of the main project which is being tested. lib |models |providers |userprovider.dart test …
stimms
  • 42,945
  • 30
  • 96
  • 149
22
votes
3 answers

How to catch an error coming from a Future in flutter widget test?

I'm facing an issue while doing widget testing on a widget that throws an exception during a Future. Code to reproduce the problem Here's a simple testwidget that reproduces the problem in a very simple way (thanks to Remi Rousselet for the…
Muldec
  • 4,641
  • 1
  • 25
  • 44
21
votes
4 answers

The method 'IOSInitializationSettings' isn't defined using local notification plugin

flutter_local_notifications: ^11.0.0 I used this library but I can find IOSInitializationSettings please help me. I m trying to integrate push notifications into my flutter app.
20
votes
5 answers

Flutter DatePicker without day. Using Future showDatePicker. PLUGIN RESTRICTED

Is it possible have a YEAR-MONTH picker with only the month and the year with the current showDatePicker without using third-party PLUGINS!! Note: As a result the day selection layout should not be visible.
Jorge Vieira
  • 2,784
  • 3
  • 24
  • 34
20
votes
4 answers

How to exclude file in flutter test coverage?

I am trying to exclude few config files from the test coverage results in the flutter test results. When I run flutter test --coverage, the output file icov.info is having information about the config files as well, which is affecting overall…
Jak
  • 2,893
  • 3
  • 19
  • 33
20
votes
5 answers

Device list doesn't shows in Android Studio using Flutter

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…
Vadivel
  • 780
  • 1
  • 6
  • 21
19
votes
5 answers

FirebaseAppPlatform.verifyExtends error while running flutter test

When I run my bitbucket pipeline for my project im getting an error during flutter test: /root/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.24.0/lib/src/firebase_app.dart:18:25: Error: Member not found: 'FirebaseAppPlatform.verifyExtends'. …
19
votes
7 answers

[Firebase Messaging]: Background Message Handler method not called when the app in background?

I-am developing an app for pushing notifications using FCM, when the app in background or terminated and receiving new notification i need to save the data of this notification local in (SQLITE), without click on the notification or re-open the app…
Mahmoud AbdelAziz
  • 291
  • 1
  • 2
  • 8
18
votes
3 answers

Flutter widget test tap - would not hit test on the specified widget

My widget test is failing after the following warning is outputted: flutter: Warning: A call to tap() with finder "exactly one widget with text "Tab 2" (ignoring offstage widgets): Text("Tab 2", softWrap: no wrapping except at line break…
Lee Mordell
  • 473
  • 5
  • 16