index.dart 2.8KB

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