尝试添加isScrollControlled: true,
inside showModalBottomSheet
Your showModalBottomSheet
method:
bottomSheet(BuildContext context) {
showModalBottomSheet(
isScrollControlled: true,
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0), topRight: Radius.circular(30.0)),
),
builder: (BuildContext context) {
return Padding(
padding: MediaQuery.of(context).viewInsets,
child: Container(
padding: EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: 20,
),
Container(
margin: const EdgeInsets.all(8.0),
height: 100,
color: Colors.red,
),
TextFormField(
keyboardType: TextInputType.phone,
validator: (value) {
if (value.isEmpty) {
return 'Please Enter Mobile Number';
}
return null;
},
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Enter Number',
labelText: ' Number',
),
),
Container(
margin: const EdgeInsets.all(8.0),
height: 100,
color: Colors.red,
),
Padding(
padding: const EdgeInsets.all(16.0),
child: ElevatedButton(
onPressed: () async {},
child: Text(
'Submit',
),
),
),
],
),
),
);
},
);
}
您的小部件:
TextButton(
onPressed: () {
bottomSheet(context);
},
child: Text('data'),
),
结果屏幕: