Last active
July 19, 2024 21:25
-
-
Save diegonc/bee0b0318d47e9c1f8d249fa30d15aa7 to your computer and use it in GitHub Desktop.
Testcase for enableFilter bug in Flutter's DropdownMenu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2019 the Dart project authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style license | |
// that can be found in the LICENSE file. | |
import 'package:flutter/material.dart'; | |
void main() => runApp(const MyApp()); | |
class Entry { | |
final String label; | |
const Entry(this.label); | |
} | |
final List<Entry> entries = [Entry("A"), Entry("B"), Entry("C")]; | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
colorSchemeSeed: Colors.blue, | |
), | |
home: const MyHomePage(title: 'Flutter Demo Home Page'), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
final String title; | |
const MyHomePage({ | |
super.key, | |
required this.title, | |
}); | |
@override | |
State<MyHomePage> createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: [ | |
Text('DropdownMenu test'), | |
DropdownMenu<Entry>( | |
label: Text('Test Label'), | |
dropdownMenuEntries: entries | |
.map( | |
(e) => DropdownMenuEntry<Entry>(value: e, label: e.label)) | |
.toList(), | |
enableFilter: true, | |
initialSelection: entries[0], | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment