YSChooseLocation.dart 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:ysairplane/base/YSBase.dart';
  4. import 'package:ysairplane/tools/YSTools.dart';
  5. class YSChooseLocation extends StatefulWidget {
  6. @override
  7. _YSChooseLocationState createState() => _YSChooseLocationState();
  8. }
  9. class _YSChooseLocationState extends State<YSChooseLocation> {
  10. int _index = 9999;
  11. bool _isChoose = false;
  12. @override
  13. Widget build(BuildContext context) {
  14. return YSBase(
  15. ystitle: '选择登机地址',
  16. yschild: Stack(
  17. children: [
  18. GestureDetector(
  19. onTap: (){
  20. setState(() {
  21. _isChoose = true;
  22. });
  23. },
  24. child: Container(
  25. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44,
  26. width: MediaQuery.of(context).size.width,
  27. color: Colors.lightGreen,
  28. ),
  29. ),
  30. if(_isChoose==true)Container(
  31. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height*0.4),
  32. height: MediaQuery.of(context).size.height*0.6-MediaQuery.of(context).padding.top-44,
  33. decoration: BoxDecoration(
  34. color: Colors.white,
  35. borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10))
  36. ),
  37. child: ListView.separated(
  38. itemBuilder: (context,index){
  39. return GestureDetector(
  40. onTap: (){
  41. setState(() {
  42. _index = index;
  43. });
  44. Navigator.of(context).pop({'display':'西安市长安区','location':'34,108'});
  45. },
  46. behavior: HitTestBehavior.opaque,
  47. child: Container(
  48. padding: EdgeInsets.all(hsp(30)),
  49. child: Row(
  50. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  51. children: [
  52. Column(
  53. crossAxisAlignment: CrossAxisAlignment.start,
  54. children: [
  55. Text('西安市长安区',style: TextStyle(fontSize: zsp(30),color: Colors.black,fontWeight: FontWeight.bold),),
  56. Text('樱花广场',style: TextStyle(fontSize: zsp(24),color: Color(0xFF999999)),)
  57. ],
  58. ),
  59. Icon(Icons.check,color: _index==index?Color(0xFF007EFF):Colors.transparent,size: hsp(50),)
  60. ],
  61. ),
  62. ),
  63. );
  64. },
  65. separatorBuilder: (context,index){
  66. return Divider(height: 0.5,thickness: 0.5,color: Color(0xFFF1F2F4),);
  67. },
  68. itemCount: 10,
  69. padding: EdgeInsets.all(0),
  70. ),
  71. ),
  72. ],
  73. ),
  74. );
  75. }
  76. }