项目添加第三方框架GetX/添加图片、修改适配大小
BIN
circle_app/asset/images/login/add.png
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
circle_app/asset/images/login/down_arr.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
circle_app/asset/images/navigator/back.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
circle_app/asset/images/tabbar/circle_normal.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
circle_app/asset/images/tabbar/circle_selected.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
circle_app/asset/images/tabbar/mine_normal.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
circle_app/asset/images/tabbar/mine_selected.png
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
circle_app/asset/images/tabbar/msg_normal.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
circle_app/asset/images/tabbar/msg_selected.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
10
circle_app/lib/app/home/binding.dart
Normal file
@ -0,0 +1,10 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class HomeBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => HomeLogic());
|
||||
}
|
||||
}
|
||||
7
circle_app/lib/app/home/logic.dart
Normal file
@ -0,0 +1,7 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'state.dart';
|
||||
|
||||
class HomeLogic extends GetxController {
|
||||
final HomeState state = HomeState();
|
||||
}
|
||||
5
circle_app/lib/app/home/state.dart
Normal file
@ -0,0 +1,5 @@
|
||||
class HomeState {
|
||||
HomeState() {
|
||||
///Initialize variables
|
||||
}
|
||||
}
|
||||
18
circle_app/lib/app/home/view.dart
Normal file
@ -0,0 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
class HomePage extends StatelessWidget {
|
||||
HomePage({Key? key}) : super(key: key);
|
||||
|
||||
final logic = Get.lazyPut(() => HomeLogic());
|
||||
final state = Get.find<HomeLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Colors.red,
|
||||
);
|
||||
}
|
||||
}
|
||||
4
circle_app/lib/common/values/values.dart
Normal file
@ -0,0 +1,4 @@
|
||||
const String images = 'assets/images/';
|
||||
const String login_images = 'assets/images/login';
|
||||
const String navigator_images = 'assets/images/navigator';
|
||||
const String tabbar_images = 'assets/images/tabbar';
|
||||
@ -1,4 +1,10 @@
|
||||
import 'package:circle_app/app/home/binding.dart';
|
||||
import 'package:circle_app/app/home/view.dart';
|
||||
import 'package:circle_app/router/app_pages.dart';
|
||||
import 'package:circle_app/router/app_routers.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
@ -10,106 +16,17 @@ class MyApp extends StatelessWidget {
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
// This is the theme of your application.
|
||||
//
|
||||
// Try running your application with "flutter run". You'll see the
|
||||
// application has a blue toolbar. Then, without quitting the app, try
|
||||
// changing the primarySwatch below to Colors.green and then invoke
|
||||
// "hot reload" (press "r" in the console where you ran "flutter run",
|
||||
// or simply save your changes to "hot reload" in a Flutter IDE).
|
||||
// Notice that the counter didn't reset back to zero; the application
|
||||
// is not restarted.
|
||||
primarySwatch: Colors.blue,
|
||||
),
|
||||
home: const MyHomePage(title: 'Flutter Demo Home Page'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
const MyHomePage({super.key, required this.title});
|
||||
|
||||
// This widget is the home page of your application. It is stateful, meaning
|
||||
// that it has a State object (defined below) that contains fields that affect
|
||||
// how it looks.
|
||||
|
||||
// This class is the configuration for the state. It holds the values (in this
|
||||
// case the title) provided by the parent (in this case the App widget) and
|
||||
// used by the build method of the State. Fields in a Widget subclass are
|
||||
// always marked "final".
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
State<MyHomePage> createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
int _counter = 0;
|
||||
|
||||
void _incrementCounter() {
|
||||
setState(() {
|
||||
// This call to setState tells the Flutter framework that something has
|
||||
// changed in this State, which causes it to rerun the build method below
|
||||
// so that the display can reflect the updated values. If we changed
|
||||
// _counter without calling setState(), then the build method would not be
|
||||
// called again, and so nothing would appear to happen.
|
||||
_counter++;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// This method is rerun every time setState is called, for instance as done
|
||||
// by the _incrementCounter method above.
|
||||
//
|
||||
// The Flutter framework has been optimized to make rerunning build methods
|
||||
// fast, so that you can just rebuild anything that needs updating rather
|
||||
// than having to individually change instances of widgets.
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
// Here we take the value from the MyHomePage object that was created by
|
||||
// the App.build method, and use it to set our appbar title.
|
||||
title: Text(widget.title),
|
||||
),
|
||||
body: Center(
|
||||
// Center is a layout widget. It takes a single child and positions it
|
||||
// in the middle of the parent.
|
||||
child: Column(
|
||||
// Column is also a layout widget. It takes a list of children and
|
||||
// arranges them vertically. By default, it sizes itself to fit its
|
||||
// children horizontally, and tries to be as tall as its parent.
|
||||
//
|
||||
// Invoke "debug painting" (press "p" in the console, choose the
|
||||
// "Toggle Debug Paint" action from the Flutter Inspector in Android
|
||||
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
|
||||
// to see the wireframe for each widget.
|
||||
//
|
||||
// Column has various properties to control how it sizes itself and
|
||||
// how it positions its children. Here we use mainAxisAlignment to
|
||||
// center the children vertically; the main axis here is the vertical
|
||||
// axis because Columns are vertical (the cross axis would be
|
||||
// horizontal).
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const Text(
|
||||
'You have pushed the button this many times:',
|
||||
),
|
||||
Text(
|
||||
'$_counter',
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: _incrementCounter,
|
||||
tooltip: 'Increment',
|
||||
child: const Icon(Icons.add),
|
||||
), // This trailing comma makes auto-formatting nicer for build methods.
|
||||
);
|
||||
//填入设计稿中设备的屏幕尺寸,单位dp
|
||||
return ScreenUtilInit(
|
||||
designSize: const Size(375, 812),
|
||||
minTextAdapt: true,
|
||||
splitScreenMode: true,
|
||||
builder: (context, child) {
|
||||
return GetMaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
initialBinding: HomeBinding(),
|
||||
home: HomePage(),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
16
circle_app/lib/router/app_pages.dart
Normal file
@ -0,0 +1,16 @@
|
||||
import 'package:circle_app/app/home/binding.dart';
|
||||
import 'package:circle_app/app/home/view.dart';
|
||||
import 'package:get/get_navigation/src/routes/get_route.dart';
|
||||
|
||||
import 'app_routers.dart';
|
||||
|
||||
class AppPages {
|
||||
|
||||
static final routes = [
|
||||
GetPage(
|
||||
name: AppRoutes.Home,
|
||||
page: () => HomePage(),
|
||||
binding: HomeBinding(),
|
||||
),
|
||||
];
|
||||
}
|
||||
3
circle_app/lib/router/app_routers.dart
Normal file
@ -0,0 +1,3 @@
|
||||
abstract class AppRoutes {
|
||||
static const Home = '/home';
|
||||
}
|
||||
@ -70,11 +70,27 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
flutter_screenutil:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_screenutil
|
||||
sha256: "0a122936b450324cbdfd51be0819cc6fcebb093eb65585e9cd92263f7a1a8a39"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.7.0"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
get:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: get
|
||||
sha256: "2ba20a47c8f1f233bed775ba2dd0d3ac97b4cf32fc17731b3dfc672b06b0e92a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.6.5"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@ -35,6 +35,8 @@ dependencies:
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.2
|
||||
get: ^4.5.0
|
||||
flutter_screenutil: ^5.6.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
@ -59,8 +61,8 @@ flutter:
|
||||
uses-material-design: true
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
assets:
|
||||
- assets/images/
|
||||
# - images/a_dot_ham.jpeg
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
|
||||