import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:flutter/material.dart'; import 'package:get_it/get_it.dart'; import 'package:ustest/BuildHistoryList.dart'; import 'Services/BuildService.dart'; import 'Services/NotificationReceivedArgs.dart'; class PackageView extends StatefulWidget { @override State<StatefulWidget> createState() { // TODO: implement createState return _PackageView(); } } class _PackageView extends State<PackageView> { String? selectedType = "我申请的"; @override Widget build(BuildContext context) { final items = <String>["我申请的", "我组织的", "我参与的"]; int selectedState = 0; if (selectedType == "我申请的") { selectedState = 0; } else if (selectedType == "我组织的") { selectedState = 1; } else { selectedState = 2; } GlobalKey<AutoCompleteTextFieldState<String>> typeKey = GlobalKey(); GlobalKey listKey = GlobalKey(); return Scaffold( body: Center( child: Column( children: [ Row( children: [ TextButton.icon( onPressed: () => onApplyConsultation(context), icon: Icon(Icons.add), label: Text("Apply")), ], ), Padding( padding: const EdgeInsets.all(8.0), child: DropdownButtonFormField<String>( key: typeKey, value: selectedType, decoration: InputDecoration(hintText: "Select one state"), items: items .map((e) => DropdownMenuItem<String>( child: Text(e), value: e, )) .toList(), onChanged: (value) { selectedType = value; }, )), Row( children: [ TextButton.icon( onPressed: () => setState(() {}), icon: Icon(Icons.search), label: Text("Search")), ], ), Expanded(child: Center()), ], ), ), ); } void onApplyConsultation(context) { print("onApplyConsultation click"); Navigator.of(context).pushNamed('/applyconsultation'); } }