import 'package:flutter/material.dart'; class locationManager extends StatefulWidget { const locationManager({Key? key}) : super(key: key); @override State createState() => _locationManagerState(); } class _locationManagerState extends State { bool _autoUpdate = false; Widget _locationIcon = Icon(Icons.home, size: 100.0); String updateStatusValue = 'off'; void _handleSwitchChanged(bool newValue) { setState(() { _autoUpdate = newValue; if (_autoUpdate) { updateStatusValue = 'on'; } else { updateStatusValue = 'off'; } }); } void _handleLocationChanged(String newValue) { setState(() { switch (newValue) { case ('home'): _locationIcon = const Icon(Icons.home, size: 100.0); break; case ('office'): _locationIcon = const Icon(Icons.business_center, size: 100.0); break; case ('none'): _locationIcon = const Icon(Icons.visibility_off, size: 100.0); } }); } @override Widget build(BuildContext context) { return Container( color: Colors.blueGrey, child: SizedBox( height: 300.0, child: Row(mainAxisSize: MainAxisSize.max, children: [ Padding( padding: const EdgeInsets.only(left: 100.0, right: 50.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Transform.scale( scale: 3, child: Switch( onChanged: _handleSwitchChanged, value: _autoUpdate, ), ), Padding( padding: const EdgeInsets.only(top: 20.0), child: SizedBox( width: 150.0, child: Text('Auto update status: $updateStatusValue')), ), ], ), ), Expanded( child: PopupMenuButton( padding: const EdgeInsets.only(bottom: 75.0), icon: _locationIcon, onSelected: _handleLocationChanged, itemBuilder: (context) => [ PopupMenuItem( value: 'home', child: Icon(Icons.home)), PopupMenuItem( value: 'office', child: Icon(Icons.business_center)), PopupMenuItem( value: 'none', child: Icon(Icons.visibility_off)), ]), ) ]), ), ); } }