Еще один обходной путь - сделать текст кликабельным, который будет отображать опции раскрывающегося списка в виде диалога. Вот пример:
Предварительный просмотр Gif
import 'package:flutter/material.dart';
class CustomDialogTest extends StatefulWidget {
@override
_CustomDialogTestState createState() => _CustomDialogTestState();
}
class _CustomDialogTestState extends State<CustomDialogTest> {
String _onDropDownItemSelected = '(Choose Option ▼)';
var textList = [
'Cat',
'Dog',
'Colorfull Unicorn',
];
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
title: Text(
'Dropdown spacing',
),
),
body: Padding(
padding: EdgeInsets.only(top: 8.0),
child: Container(
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'I am a ',
style: TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
InkWell(
onTap: () {
showDialog(
context: context,
child: Dialog(
backgroundColor: Colors.blue[100],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
child: ListView.builder(
shrinkWrap: true,
itemCount: textList.length,
itemBuilder: (context, index) {
return GestureDetector(
child: Row(
children: <Widget>[
Icon(
Icons.arrow_right,
color: Colors.black,
),
Text(
textList[index],
style: TextStyle(
color: Colors.black,
fontSize: 20.0,
),
),
],
),
onTap: () {
Navigator.pop(context);
setState(() {
_onDropDownItemSelected = textList[index];
});
},
);
}),
),
);
},
child: Text(
_onDropDownItemSelected,
style: TextStyle(
color: Colors.blue[900],
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
),
Text(
' Person',
style: TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
],
),
),
),
);
}
}