PublishView.dart 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import 'package:autocomplete_textfield/autocomplete_textfield.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:get_it/get_it.dart';
  4. import 'package:ustest/BuildHistoryList.dart';
  5. import 'Services/BuildService.dart';
  6. import 'Services/NotificationReceivedArgs.dart';
  7. class PublishView extends StatefulWidget {
  8. @override
  9. State<StatefulWidget> createState() {
  10. // TODO: implement createState
  11. return _PublishView();
  12. }
  13. }
  14. class _PublishView extends State<PublishView> {
  15. String? selectedType = "我申请的";
  16. @override
  17. Widget build(BuildContext context) {
  18. final items = <String>["我申请的", "我组织的", "我参与的"];
  19. int selectedState = 0;
  20. if (selectedType == "我申请的") {
  21. selectedState = 0;
  22. } else if (selectedType == "我组织的") {
  23. selectedState = 1;
  24. } else {
  25. selectedState = 2;
  26. }
  27. GlobalKey<AutoCompleteTextFieldState<String>> typeKey = GlobalKey();
  28. GlobalKey listKey = GlobalKey();
  29. return Scaffold(
  30. body: Center(
  31. child: Column(
  32. children: [
  33. Row(
  34. children: [
  35. TextButton.icon(
  36. onPressed: () => onApplyConsultation(context),
  37. icon: Icon(Icons.add),
  38. label: Text("Apply")),
  39. ],
  40. ),
  41. Padding(
  42. padding: const EdgeInsets.all(8.0),
  43. child: DropdownButtonFormField<String>(
  44. key: typeKey,
  45. value: selectedType,
  46. decoration: InputDecoration(hintText: "Select one state"),
  47. items: items
  48. .map((e) => DropdownMenuItem<String>(
  49. child: Text(e),
  50. value: e,
  51. ))
  52. .toList(),
  53. onChanged: (value) {
  54. selectedType = value;
  55. },
  56. )),
  57. Row(
  58. children: [
  59. TextButton.icon(
  60. onPressed: () => setState(() {}),
  61. icon: Icon(Icons.search),
  62. label: Text("Search")),
  63. ],
  64. ),
  65. Expanded(child: Center()),
  66. ],
  67. ),
  68. ),
  69. );
  70. }
  71. void onApplyConsultation(context) {
  72. print("onApplyConsultation click");
  73. Navigator.of(context).pushNamed('/applyconsultation');
  74. }
  75. }