main.dart 5.4KB

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