123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import 'package:farmer_client/models/entities/Address.dart';
  2. import 'package:farmer_client/widgets/DefaultButton.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_screenutil/flutter_screenutil.dart';
  5. import 'package:fluttertoast/fluttertoast.dart';
  6. import 'package:get/get.dart';
  7. class AddAddress extends StatefulWidget {
  8. const AddAddress({Key? key}) : super(key: key);
  9. @override
  10. _AddAddress createState() => _AddAddress();
  11. }
  12. class _AddAddress extends State<AddAddress> {
  13. late Address address=Address();
  14. late String text = '';
  15. @override
  16. void initState() {
  17. super.initState();
  18. if (Get.arguments != null) {
  19. address = Get.arguments['item'];
  20. text = address.address.toString();
  21. }
  22. }
  23. @override
  24. Widget build(BuildContext context) {
  25. return Scaffold(
  26. appBar: AppBar(
  27. elevation: 0,
  28. centerTitle: true,
  29. backgroundColor: Colors.white,
  30. title: Text(
  31. '添加地址',
  32. style: TextStyle(
  33. color: Colors.black,
  34. fontSize: 17.sp,
  35. letterSpacing: 2,
  36. fontWeight: FontWeight.bold),
  37. ),
  38. ),
  39. body: Container(
  40. padding: EdgeInsets.all(15.w),
  41. child: Column(
  42. crossAxisAlignment: CrossAxisAlignment.start,
  43. children: [
  44. Text(
  45. '详细地址:',
  46. style: TextStyle(
  47. fontWeight: FontWeight.bold,
  48. fontSize: 17.sp,
  49. color: const Color(0xFF333333)),
  50. ),
  51. Container(
  52. margin: EdgeInsets.fromLTRB(0, 0, 0, 50.h),
  53. padding: EdgeInsets.symmetric(vertical: 5.w, horizontal: 18.5.w),
  54. decoration: BoxDecoration(
  55. color: const Color(0xFFfefefe),
  56. borderRadius: BorderRadius.all(Radius.circular(10.w)),
  57. border: Border.all(
  58. color: const Color(0xcc000000),
  59. width: 1.h,
  60. style: BorderStyle.solid)),
  61. child: TextFormField(
  62. initialValue: text,
  63. minLines: 6,
  64. maxLines: 6,
  65. style: TextStyle(fontSize: 17.sp, height: 1.5),
  66. decoration: const InputDecoration(
  67. isCollapsed: true,
  68. hintText: '请输入地址信息',
  69. border: InputBorder.none,
  70. counterText: '', //去掉计数
  71. floatingLabelBehavior: FloatingLabelBehavior.never,
  72. ),
  73. onChanged: (e) {
  74. setState(() {
  75. address.address = e;
  76. });
  77. },
  78. ),
  79. ),
  80. DefaultButton(
  81. color: const Color(0xffffffff),
  82. backColor: const Color(0xFFFF703B),
  83. width: 345.w,
  84. height: 49.h,
  85. text: '保存',
  86. onPressed: () {
  87. if(address.address==null){
  88. Fluttertoast.showToast(
  89. msg: '请输入地址!');
  90. } else{
  91. Fluttertoast.showToast(
  92. msg: '保存成功!');
  93. Get.back();
  94. }
  95. },
  96. margin: const EdgeInsets.all(0),
  97. fontSize: 20.sp,
  98. radius: 24.5.w,
  99. ),
  100. ],
  101. ),
  102. ),
  103. );
  104. }
  105. }