Skip to content

Instantly share code, notes, and snippets.

@k3ntar0
Last active August 17, 2020 09:04
Show Gist options
  • Save k3ntar0/b5507ecdbbe4647d5b5b685744a8b37f to your computer and use it in GitHub Desktop.
Save k3ntar0/b5507ecdbbe4647d5b5b685744a8b37f to your computer and use it in GitHub Desktop.
Customized dropdown_button widget
// ![](https://flutter.github.io/assets-for-api-docs/assets/material/dropdown_button.png)
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
/// This Widget is the main application widget.
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<MyStatefulWidget> {
@override
Widget build(BuildContext context) {
return Container(
width: 326.0,
padding: EdgeInsets.only(top: 0.0, right: 12.0, bottom: 0.0, left: 12.0),
child: DropdownButton<String>(
hint: Text('どの段階で中止しますか? *'),
icon: Icon(
Icons.arrow_drop_down,
color: Colors.grey[400],
),
isExpanded: true,
iconSize: 24,
style: TextStyle(color: Colors.grey[900]),
underline: Container(
height: 0,
),
onChanged: (String value) {},
items: <String>['出発前', 'お店に向かう途中', 'お会計前', 'お届け先に向かう途中', 'お届け時']
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(
value,
),
);
}).toList(),
),
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(
side: BorderSide(
width: 2.0,
style: BorderStyle.solid,
color: Colors.green[500],
),
borderRadius: BorderRadius.all(Radius.circular(4.0)),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment