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