-1
votes

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget { static const String _title = 'Flutter Code Sample';

@override Widget build(BuildContext context) { return MaterialApp( title: _title, home: Scaffold( appBar: AppBar(title: const Text(_title)), body: Center( child: MyStatefulWidget(), ), ), ); } }

class MyStatefulWidget extends StatefulWidget { MyStatefulWidget({Key key}) : super(key: key);

@override _MyStatefulWidgetState createState() => _MyStatefulWidgetState(); }

class _MyStatefulWidgetState extends State { String dropdownValue = 'One';

@override Widget build(BuildContext context) { return DropdownButton( value: dropdownValue, icon: Icon(Icons.arrow_downward), iconSize: 15, elevation: 16, style: TextStyle(color: Colors.deepPurple), underline: Container( height: 2, color: Colors.deepPurpleAccent, ), onChanged: (String newValue) { setState(() { dropdownValue = newValue; }); }, items: ['One', 'Two', 'Free', 'Four'] .map<DropdownMenuItem>((String value) { return DropdownMenuItem( value: value, child: Text(value), ); }).toList(), ); } }

2
It would be helpful if you reviewed the posting guide and presented your code as a formatted block. One easy way to do that is to put four reverse apostrophes (````) above and below the code.Curt Eckhart

2 Answers

1
votes

You can add width: (specification) and height: (specification) in your dropdown list. Specification -> number.

Please, use the Code Sample formatting option.

0
votes

you can do it like this :

return Container(
  child: DropdownButton(
    value: dropdownValue,
    icon: Icon(Icons.arrow_downward), 
    iconSize: 15, 
    elevation: 16, 
    style: TextStyle(color: Colors.deepPurple), 
    underline: Container( 
      height: 2, 
      color: Colors.deepPurpleAccent, 
    ), 
    onChanged: (newValue) {
      setState(() { 
        dropdownValue = newValue; 
      });
    }, 
    items: ['One', 'Two', 'Free', 'Four'] .map<DropdownMenuItem>((String value) { 
      return DropdownMenuItem(
        value: value,
        child: Container(
          height: 100,
          width: 200,
          alignment: Alignment.centerLeft,
          child: Text(value)
        )
      ); 
    }).toList(),
  )
); 

Btw, please use the Code Sample formatting option.