main.dart 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import 'dart:async';
  2. import 'package:farmer_client/models/Store.dart';
  3. import 'package:farmer_client/pages/TabBar/index_page.dart';
  4. import 'package:farmer_client/pages/login/login.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:get/get.dart';
  7. import 'package:flutter_screenutil/flutter_screenutil.dart';
  8. import 'components/UI/Banner.dart';
  9. import 'components/UI/CarsCard.dart';
  10. import 'components/UI/DefaultButton.dart';
  11. import 'components/UI/Search.dart';
  12. void main() {
  13. Store().init();
  14. runApp(const MyApp());
  15. }
  16. class MyApp extends StatelessWidget {
  17. const MyApp({Key? key}) : super(key: key);
  18. // This widget is the root of your application.
  19. @override
  20. Widget build(BuildContext context) {
  21. return MaterialApp(
  22. title: 'Flutter Demo',
  23. theme: ThemeData(
  24. // This is the theme of your application.
  25. //
  26. // Try running your application with "flutter run". You'll see the
  27. // application has a blue toolbar. Then, without quitting the app, try
  28. // changing the primarySwatch below to Colors.green and then invoke
  29. // "hot reload" (press "r" in the console where you ran "flutter run",
  30. // or simply save your changes to "hot reload" in a Flutter IDE).
  31. // Notice that the counter didn't reset back to zero; the application
  32. // is not restarted.
  33. primarySwatch: Colors.blue,
  34. ),
  35. home: const MyHomePage(title: 'Flutter Demo Home Page'),
  36. );
  37. }
  38. }
  39. class MyHomePage extends StatefulWidget {
  40. const MyHomePage({Key? key, required this.title}) : super(key: key);
  41. // This widget is the home page of your application. It is stateful, meaning
  42. // that it has a State object (defined below) that contains fields that affect
  43. // how it looks.
  44. // This class is the configuration for the state. It holds the values (in this
  45. // case the title) provided by the parent (in this case the App widget) and
  46. // used by the build method of the State. Fields in a Widget subclass are
  47. // always marked "final".
  48. final String title;
  49. @override
  50. State<MyHomePage> createState() => _MyHomePageState();
  51. }
  52. class _MyHomePageState extends State<MyHomePage> {
  53. int _counter = 0;
  54. @override
  55. Widget build(BuildContext context) {
  56. ScreenUtil.init(context,
  57. deviceSize: Size(
  58. MediaQuery.of(context).size.width,
  59. MediaQuery.of(context).size.height),
  60. designSize: const Size(375, 812),
  61. minTextAdapt: true,
  62. orientation: Orientation.portrait);
  63. // var find = Get.find(tag: 'user');
  64. // This method is rerun every time setState is called, for instance as done
  65. // by the _incrementCounter method above.
  66. //
  67. // The Flutter framework has been optimized to make rerunning build methods
  68. // fast, so that you can just rebuild anything that needs updating rather
  69. // than having to individually change instances of widgets.
  70. return Scaffold(
  71. appBar: AppBar(
  72. backgroundColor: Colors.amber,
  73. // Here we take the value from the MyHomePage object that was created by
  74. // the App.build method, and use it to set our appbar title.
  75. title: Text(widget.title),
  76. ),
  77. body: Center(
  78. // Center is a layout widget. It takes a single child and positions it
  79. // in the middle of the parent.
  80. child: Column(
  81. // Column is also a layout widget. It takes a list of children and
  82. // arranges them vertically. By default, it sizes itself to fit its
  83. // children horizontally, and tries to be as tall as its parent.
  84. //
  85. // Invoke "debug painting" (press "p" in the console, choose the
  86. // "Toggle Debug Paint" action from the Flutter Inspector in Android
  87. // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
  88. // to see the wireframe for each widget.
  89. //
  90. // Column has various properties to control how it sizes itself and
  91. // how it positions its children. Here we use mainAxisAlignment to
  92. // center the children vertically; the main axis here is the vertical
  93. // axis because Columns are vertical (the cross axis would be
  94. // horizontal).
  95. mainAxisAlignment: MainAxisAlignment.center,
  96. children: const <Widget>[
  97. // Text(
  98. // '$_counter',
  99. // style: Theme.of(context).textTheme.headline4,
  100. // ),
  101. // DefaultButton(
  102. // margin: EdgeInsets.fromLTRB(0, 30.0, 0, 0), //可选配置,自定义控件中有默认配置
  103. // text: "登陆",
  104. // width: 120.0,
  105. // height: 50.0,
  106. // fontSize: 20.0,
  107. // backColor: Color(0xffff703b),
  108. // color: Colors.white,
  109. // onPressed: () {
  110. // Navigator.push(
  111. // context,
  112. // MaterialPageRoute(builder: (context) {
  113. // return MyRouteLogin();
  114. // }),
  115. // );
  116. // },
  117. // ),
  118. // CarsCard(item: CarItem(
  119. // name:'元神第二个收割机',
  120. // distance:8.8,
  121. // price:270.6,
  122. // )),
  123. Search()
  124. ],
  125. ),
  126. ),
  127. // This trailing comma makes auto-formatting nicer for build methods.
  128. );
  129. }
  130. }