50 lines
1.5 KiB
Dart
50 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:rogapp/pages/index/index_controller.dart';
|
|
import 'package:rogapp/services/location_service.dart';
|
|
|
|
class CatWidget extends StatefulWidget {
|
|
CatWidget({ Key? key, required this.indexController, }) : super(key: key);
|
|
|
|
IndexController indexController;
|
|
|
|
@override
|
|
State<CatWidget> createState() => _CatWidgetState();
|
|
}
|
|
|
|
class _CatWidgetState extends State<CatWidget> {
|
|
String defaultValue = "---";
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return
|
|
PopupMenuButton(
|
|
onSelected: (value) {
|
|
widget.indexController.currentCat.clear();
|
|
widget.indexController.currentCat.add(value.toString());
|
|
widget.indexController.refreshLocationForCat();
|
|
setState(() {
|
|
print(value);
|
|
//widget.indexController.is_loading.value = true;
|
|
defaultValue = value.toString();
|
|
});
|
|
},
|
|
itemBuilder: (BuildContext context){
|
|
List<PopupMenuItem> itms = <PopupMenuItem>[];
|
|
for(dynamic d in widget.indexController.cats[0]){
|
|
PopupMenuItem itm = PopupMenuItem(child: Text(d['category'].toString()), value: d['category'].toString());
|
|
itms.add(itm);
|
|
}
|
|
return itms;
|
|
}
|
|
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
// widget.indexController.cats.map((e) =>
|
|
// PopupMenuItem(
|
|
// value: defaultValue,
|
|
// child: Text(e[0]['category'].toString()),
|
|
// )
|
|
// ).toList(), |