Skip to content

Commit c2d8fe6

Browse files
authored
Added selected map border (#98)
1 parent c23ea23 commit c2d8fe6

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed
60.4 KB
Loading

lib/samples/set_basemap/set_basemap_sample.dart

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ class _SetBasemapSampleState extends State<SetBasemapSample>
3838
// Create a dictionary to store basemaps.
3939
final _basemaps = <Basemap, Image>{};
4040
// Create a default image.
41-
final _defaultImage = Image.asset('assets/basemap_default.png');
41+
final _defaultImage = Image.asset('assets/basemap_default.png');
42+
// Create a future to load basemaps.
4243
late Future _loadBasemapsFuture;
44+
// Create a variable to store the selected basemap.
45+
Basemap? _selectedBasemap;
4346

4447
@override
4548
void initState() {
@@ -55,7 +58,7 @@ class _SetBasemapSampleState extends State<SetBasemapSample>
5558
key: _scaffoldStateKey,
5659
// Create an end drawer to display basemaps.
5760
endDrawer: Drawer(
58-
child: SafeArea(
61+
child: SafeArea(
5962
// Create a future builder to load basemaps.
6063
child: FutureBuilder(
6164
future: _loadBasemapsFuture,
@@ -71,7 +74,19 @@ class _SetBasemapSampleState extends State<SetBasemapSample>
7174
(basemap) => ListTile(
7275
title: Column(
7376
children: [
74-
_basemaps[basemap] ?? _defaultImage,
77+
Container(
78+
// Add a border to the selected basemap.
79+
decoration: _selectedBasemap == basemap
80+
? BoxDecoration(
81+
border: Border.all(
82+
color: Colors.blue,
83+
width: 4,
84+
),
85+
)
86+
: null,
87+
// Display the basemap image.
88+
child: _basemaps[basemap] ?? _defaultImage,
89+
),
7590
Text(
7691
basemap.name,
7792
textAlign: TextAlign.center,
@@ -80,6 +95,7 @@ class _SetBasemapSampleState extends State<SetBasemapSample>
8095
),
8196
// Update the map with the selected basemap.
8297
onTap: () {
98+
_selectedBasemap = basemap;
8399
updateMap(basemap);
84100
_scaffoldStateKey.currentState!.closeEndDrawer();
85101
},
@@ -122,12 +138,12 @@ class _SetBasemapSampleState extends State<SetBasemapSample>
122138

123139
void onMapViewReady() {
124140
// Set the map view controller's map to the ArcGIS map.
125-
_mapViewController.arcGISMap = _arcGISMap;
141+
_mapViewController.arcGISMap = _arcGISMap;
126142
}
127143

128144
void updateMap(Basemap basemap) {
129145
// Update the map view with the selected basemap.
130-
_arcGISMap.basemap = basemap;
146+
_arcGISMap.basemap = basemap;
131147
}
132148

133149
Future loadBasemaps() async {

0 commit comments

Comments
 (0)