SHARE
TWEET

Untitled

a guest Sep 11th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'package:flutter/material.dart';
  2.  
  3. class SettingsWidget extends StatefulWidget {
  4.   SettingsWidget({Key key}) : super(key: key);
  5.  
  6.   @override
  7.   _SettingsWidgetState createState() => new _SettingsWidgetState();
  8. }
  9.  
  10. class _SettingsWidgetState extends State<SettingsWidget> {
  11.  
  12.   List _centroCusto =
  13.   ["Alimentoção","Educaoção","Lazer"];
  14.  
  15.   List<DropdownMenuItem<String>> _dropDownMenuItems;
  16.   String _currentCentroCusto;
  17.  
  18.   @override
  19.   void initState() {
  20.     _dropDownMenuItems = getDropDownMenuItems();
  21.     _currentCentroCusto = _dropDownMenuItems[0].value;
  22.     super.initState();
  23.   }
  24.  
  25.   List<DropdownMenuItem<String>> getDropDownMenuItems() {
  26.     List<DropdownMenuItem<String>> items = new List();
  27.     for (String cc in _centroCusto) {
  28.       items.add(new DropdownMenuItem(
  29.           value: cc,
  30.           child: new Text(cc)
  31.       ));
  32.     }
  33.     return items;
  34.   }
  35.  
  36.   @override
  37.   Widget build(BuildContext context) {
  38.     return new Container(
  39.       color: Colors.white,
  40.       child: new Center(
  41.           child: new Column(
  42.             crossAxisAlignment: CrossAxisAlignment.center,
  43.             mainAxisAlignment: MainAxisAlignment.center,
  44.             children: <Widget>[
  45.               new Text("Centro de Custo: "),
  46.               new Container(
  47.                 padding: new EdgeInsets.all(16.0),
  48.               ),
  49.               new DropdownButton(
  50.                 value: _currentCentroCusto,
  51.                 items: _dropDownMenuItems,
  52.                 onChanged: changedDropDownItem,
  53.               )
  54.             ],
  55.           )
  56.       ),
  57.     );
  58.   }
  59.  
  60.   void changedDropDownItem(String selectedCentroCusto) {
  61.     setState(() {
  62.       _currentCentroCusto = selectedCentroCusto;
  63.     });
  64.   }
  65.  
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top