home.dart 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:hengyi/home/about_us.dart';
  4. import 'package:hengyi/home/contact_us.dart';
  5. import 'package:hengyi/home/country_list.dart';
  6. import 'package:hengyi/widget/common_footer.dart';
  7. import 'package:hengyi/widget/common_title.dart';
  8. import '../utils/common_util.dart';
  9. class HomePage extends StatefulWidget {
  10. HomePage({super.key});
  11. @override
  12. State<HomePage> createState() => _HomePageState();
  13. }
  14. class _HomePageState extends State<HomePage>
  15. with SingleTickerProviderStateMixin {
  16. late TabController _tabController;
  17. List tabs = ["了解目的地", "联系我们", "关于我们"];
  18. var tabBarTextSize = 0.0;
  19. @override
  20. void initState() {
  21. super.initState();
  22. if (Util.isWeb()) {
  23. tabBarTextSize = 30.sp;
  24. } else {
  25. tabBarTextSize = 60.sp;
  26. }
  27. _tabController = TabController(length: tabs.length, vsync: this);
  28. }
  29. @override
  30. Widget build(BuildContext context) {
  31. return Scaffold(
  32. body: Column(
  33. children: [
  34. CommonTitleWidget(),
  35. Material(
  36. color: Colors.grey[100],
  37. child: TabBar(
  38. labelColor: Colors.black,
  39. unselectedLabelColor: Colors.grey,
  40. controller: _tabController,
  41. tabs: tabs
  42. .map((e) => Tab(
  43. child: Text(
  44. e,
  45. style: TextStyle(fontSize: tabBarTextSize),
  46. )))
  47. .toList()),
  48. ),
  49. Expanded(
  50. child: TabBarView(
  51. controller: _tabController,
  52. children: [
  53. CountryListWidget(),
  54. ContactUSWidget(),
  55. AboutUSWidget(),
  56. ],
  57. )),
  58. CommonFooterWidget(),
  59. ],
  60. ),
  61. );
  62. }
  63. @override
  64. void dispose() {
  65. _tabController.dispose();
  66. super.dispose();
  67. }
  68. }