Closed Zigotote closed 1 month ago
Thank you for PR. Could you past a simple reproducible test exmaple that throws exception ?
For example this test works with my commit, but fails on master
import 'package:dropdown_search/dropdown_search.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
main() {
testWidgets("should search item", (tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: DropdownSearch(
items: (_, __) => ["apple", "banana", "pineapple"],
compareFn: (item, selectedItem) => item == selectedItem,
popupProps:
const PopupPropsMultiSelection.menu(showSearchBox: true),
),
),
),
);
await tester.pumpAndSettle();
// Open dropdown
await tester.tap(find.byType(FormField));
await tester.pump();
// Search value
await tester.enterText(find.byType(TextField), "ap");
await tester.pumpAndSettle();
expect(find.text("apple"), findsOneWidget);
expect(find.text("pineapple"), findsOneWidget);
expect(find.text("banana"), findsNothing);
});
}
1 - There is no problem with the package. you have just to correct your test. 2- by adding your correction, you are making a huge regressions, i will just list some:
barrierDismissible
to false will no more workbarrierDismissible
to false will no more work...
check DropdownButtonFormField
a widget developped by Flutter team, you will notice the same logic as we do
Using the dropdownMenu inside tests makes the test fail because closePopup is called during test tearDown, making Navigor.of(context).pop() throwing an error.
Full stack trace is here :
- [x] This PR fixes the issue thrown during my tests.
- [x] It doesn't seems to break anything
- [x] I saw closePopup was added in dispose method because of this issue : Menu does not close when switching between pages #554. The issue is still fixed in this PR
@Zigotote This is a problem. When you click popup frequently and quickly, and then click external outside close, you will find that the page will exit abnormally.
Navigator.pop(context)
may be called abnormally.
Thank you for all your returns. I didn't thought about checking how the Flutter team handled the tests of this component. I added your code and it fixed my tests. Thanks for your time
Using the dropdownMenu inside tests makes the test fail because closePopup is called during test tearDown, making Navigor.of(context).pop() throwing an error.
Full stack trace is here :