地图组件和ECS框架完成
This commit is contained in:
35
lib/utils/style_dropdown.dart
Normal file
35
lib/utils/style_dropdown.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '/utils/map_styles.dart';
|
||||
|
||||
class StyleDropdown extends StatefulWidget {
|
||||
const StyleDropdown({required this.onChanged, super.key});
|
||||
|
||||
final void Function(MapStyles style) onChanged;
|
||||
|
||||
static MapStyles get initStyle => MapStyles.openMapTilesLiberty;
|
||||
|
||||
@override
|
||||
State<StyleDropdown> createState() => _StyleDropdownState();
|
||||
}
|
||||
|
||||
class _StyleDropdownState extends State<StyleDropdown> {
|
||||
late MapStyles _selectedStyle = StyleDropdown.initStyle;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: DropdownButton<MapStyles>(
|
||||
value: _selectedStyle,
|
||||
items: MapStyles.values
|
||||
.map((e) => DropdownMenuItem(value: e, child: Text(e.name)))
|
||||
.toList(growable: false),
|
||||
onChanged: (value) {
|
||||
if (value == null) return;
|
||||
setState(() => _selectedStyle = value);
|
||||
widget.onChanged(value);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user