show method
void
show()
Displays the month picker dialog.
Implementation
void show() {
_temporarySelectedMonth = initialDate;
showGeneralDialog(
barrierLabel: "MonthPicker",
context: context,
pageBuilder: (_, __, ___) {
return Align(
alignment: Alignment.topCenter,
child: SingleChildScrollView(
child: Column(
children: [
Container(
color: secondaryColor,
height: 86.h,
child: Column(
children: [
SizedBox(height: 40.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
onPressed: () {
Navigator.of(context).pop();
},
icon: Icon(Icons.arrow_back, color: primaryColor),
),
Text(
'Month Picker',
style: TextStyle(
fontSize: 18.sp,
color: primaryColor,
decoration: TextDecoration.none,
fontWeight: FontWeight.normal,
),
),
IconButton(
onPressed: () {
onConfirm(_temporarySelectedMonth);
Navigator.of(context).pop();
},
icon: Icon(Icons.check, color: primaryColor),
),
],
),
],
),
),
Container(
height: 1.h,
decoration: BoxDecoration(
color: primaryColor,
),
),
SizedBox(
height: 150.h, // 增加這裡的高度以確保所有元素都能顯示
child: Material(
color: secondaryColor,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(10.sp),
bottomRight: Radius.circular(10.sp),
),
child: StatefulBuilder(
builder:
(BuildContext context, StateSetter dialogSetState) {
return Column(
children: [
_navigationRow(dialogSetState),
Expanded(
// 使用 Expanded 包裹月份生成部分
child: Column(
children: _generateMonths(dialogSetState),
),
),
SizedBox(height: 10.h),
],
);
},
),
),
),
],
),
),
);
},
);
}