showDialogNormal static method

Future<int> showDialogNormal(
  1. BuildContext context, {
  2. IconData? closeIcon,
  3. String? description,
})

Implementation

static Future<int> showDialogNormal(
  BuildContext context, {
  // required String status,
  // required Widget statusIcon,
  IconData? closeIcon,
  String? description,
}) async {
  // 这是对话框内部就解决的选择性问题,有内部返回值处理,最终返回到事件。
  switch (await showDialog<int>(
      context: context,
      builder: (context) {
        ValueNotifier<int> _valueNotifier = ValueNotifier(1);
        return SimpleDialog(
          title: Text("title"),
          backgroundColor: Colors.white.withOpacity(0.8),
          shape: const RoundedRectangleBorder(borderRadius: _borderRadius),
          contentPadding: EdgeInsets.symmetric(horizontal: 20.0),
          children: [
            // 选择列表
            ValueListenableBuilder<int>(
              builder: (context, value, child) => Center(
                child: DropdownButton<int>(
                  alignment: AlignmentDirectional.centerEnd,
                  items: [
                    DropdownMenuItem(
                      alignment: Alignment.centerRight,
                      child: Text("1"),
                      value: 1,
                    ),
                    DropdownMenuItem(
                      child: Text("2"),
                      value: 2,
                    ),
                    DropdownMenuItem(
                      child: Text("3"),
                      value: 3,
                    ),
                    DropdownMenuItem(
                      child: Text("4"),
                      value: 4,
                    ),
                    DropdownMenuItem(
                      child: Text("5"),
                      value: 5,
                    ),
                  ],
                  onChanged: (value) {
                    _valueNotifier.value = value!;
                  },
                  value: value,
                ),
              ),
              valueListenable: _valueNotifier,
            ),
            SimpleDialogOption(
              onPressed: () {
                Navigator.pop(context, _valueNotifier.value);
              },
              child: const Text('Treasury department'),
            ),
            SimpleDialogOption(
              onPressed: () {
                Navigator.pop(context);
              },
              child: const Text('State department'),
            ),
          ],
        );
      })) {
    case 1:
      print("return 1");
      return 1;
    case 2:
      print("return 2");
      return 2;
    case 3:
      print("return 3");
      return 3;
  }
  return 0;
}