34 lines
1.1 KiB
Dart
34 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
/// 选择器页
|
|
/// 点击选项后 pop 带回结果(返回值的经典用法)
|
|
class PickerPage extends StatelessWidget {
|
|
const PickerPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('选择性别')),
|
|
body: Column(
|
|
children: [
|
|
ListTile(
|
|
leading: const Icon(Icons.male, color: Color(0xFF3B82F6)),
|
|
title: const Text('男'),
|
|
trailing: const Icon(Icons.chevron_right),
|
|
// pop 带结果:第二个参数就是要返回的值
|
|
onTap: () => Navigator.pop(context, '男'),
|
|
),
|
|
Divider(height: 1.h, indent: 16, endIndent: 16),
|
|
ListTile(
|
|
leading: const Icon(Icons.female, color: Color(0xFFF06292)),
|
|
title: const Text('女'),
|
|
trailing: const Icon(Icons.chevron_right),
|
|
onTap: () => Navigator.pop(context, '女'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|