- 将 AddItemScreen 中的各个字段提取为独立的 Widget - 新增 CategoryDropdown、DatePickerField、DescriptionField 等组件 - 优化 Item 模型,使用 ItemIsUse 枚举替代字符串表示是否使用 - 在数据库中添加 price 字段- 重构表单提交逻辑,使用新的组件进行数据采集
		
			
				
	
	
		
			22 lines
		
	
	
		
			500 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			500 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:flutter/material.dart';
 | |
| 
 | |
| class DescriptionField extends StatelessWidget {
 | |
|   final ValueChanged<String> onChanged;
 | |
| 
 | |
|   const DescriptionField({required this.onChanged});
 | |
| 
 | |
|   @override
 | |
|   Widget build(BuildContext context) {
 | |
|     return TextField(
 | |
|       decoration: InputDecoration(
 | |
|         labelText: "物品描述",
 | |
|         hintText: "请输入物品描述",
 | |
|         border: OutlineInputBorder(),
 | |
|       ),
 | |
|       maxLines: 4,
 | |
|       maxLength: 200,
 | |
|       onChanged: onChanged,
 | |
|     );
 | |
|   }
 | |
| }
 |