first commit

This commit is contained in:
编码猿
2024-09-27 01:32:49 +08:00
commit 28ebe05a64
7399 changed files with 1174529 additions and 0 deletions

37
滴滴淘/ddt_flutter/.gitignore vendored Normal file
View File

@@ -0,0 +1,37 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
# Web related
lib/generated_plugin_registrant.dart
# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

View File

@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
version:
revision: 0b8abb4724aa590dd0f429683339b1e045a1594d
channel: stable
project_type: app

View File

@@ -0,0 +1 @@
43a636de-d1b6-4544-ab29-e4e89e7c9e7f

View File

@@ -0,0 +1,18 @@
# ddt_flutter
A new Flutter project.
## Getting Started
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

View File

@@ -0,0 +1,7 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

View File

@@ -0,0 +1 @@
8e0252bb-af06-475e-8d0e-d28a3d3df17c

View File

@@ -0,0 +1 @@
d882b3e0-9a44-4e7e-80ca-79d58dd0b3de

View File

@@ -0,0 +1,61 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.ddt.flutter.ddt_flutter"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

View File

@@ -0,0 +1 @@
22ff8037-0289-4c73-b821-c6950b257dd8

View File

@@ -0,0 +1 @@
6fe742bc-f23e-4a86-81b0-26d52ec4c53b

View File

@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ddt.flutter.ddt_flutter">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

View File

@@ -0,0 +1 @@
dbe36970-b3ea-4892-a973-e0e41301a896

View File

@@ -0,0 +1,30 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ddt.flutter.ddt_flutter">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="ddt_flutter"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

View File

@@ -0,0 +1 @@
9ae182c1-5062-455b-aec9-c079210eae16

View File

@@ -0,0 +1 @@
1eb87a8a-50dd-4fb3-af7f-b3291688424a

View File

@@ -0,0 +1 @@
fafe6770-6654-419a-ac6a-b4e572fe0792

View File

@@ -0,0 +1 @@
764cf3e5-c1ff-4463-930b-c2036f67ae65

View File

@@ -0,0 +1 @@
e2970d34-fe99-4b38-919e-d3784e4e5ea1

View File

@@ -0,0 +1,13 @@
package com.ddt.flutter.ddt_flutter;
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterActivity {
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}

View File

@@ -0,0 +1 @@
2b499589-2194-4819-a731-af9dc1bc4024

View File

@@ -0,0 +1 @@
90c3d273-8d99-45de-a66e-b16c68a746d1

View File

@@ -0,0 +1 @@
64b0e779-68ae-4f59-b599-93556a986223

View File

@@ -0,0 +1 @@
526c70c0-9c64-4e01-b8f6-03288d5f1de4

View File

@@ -0,0 +1 @@
b8d564fc-60cb-4838-a53e-902cbe1f656e

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>

View File

@@ -0,0 +1 @@
6722e97c-8a3b-456f-92b4-90fc8102345c

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 B

View File

@@ -0,0 +1 @@
43b34d00-37c4-4cf1-b01c-e50b5a60f509

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

View File

@@ -0,0 +1 @@
07a1b96e-4bdd-4211-91f8-1d60ffc4547b

Binary file not shown.

After

Width:  |  Height:  |  Size: 721 B

View File

@@ -0,0 +1 @@
ec869fbc-555b-4c8f-bdf8-fdf2c4e31bec

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1 @@
82f7656f-03a6-4988-ac0f-064f21f6747d

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1 @@
d004aeec-679a-46dd-8e0d-992853530c6d

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
</resources>

View File

@@ -0,0 +1 @@
cef74f17-218d-4171-87d1-a5f9ef5ac7d5

View File

@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ddt.flutter.ddt_flutter">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

View File

@@ -0,0 +1,29 @@
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@@ -0,0 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true

View File

@@ -0,0 +1 @@
2ef68bab-61dd-4ffc-8d11-29a1e08e571b

View File

@@ -0,0 +1 @@
62f8ba0c-39c2-4e18-a694-faf8dbda2422

View File

@@ -0,0 +1,6 @@
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip

View File

@@ -0,0 +1,15 @@
include ':app'
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}

View File

@@ -0,0 +1 @@
f8b4b6f0-acbc-43ec-8a5b-dae0e4469c79

View File

@@ -0,0 +1 @@
e7dc70dc-c800-458f-a262-fe87e1bcc3a0

View File

@@ -0,0 +1,51 @@
class R {
/// 静态资源配置,程序自动生成,请勿手动修改
/// ![](http://127.0.0.1:2227/lib/static/img/ts.jpg)
static final String libStaticImgTsJpg = 'lib/static/img/ts.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/hotel.png)
static final String libStaticImgHotelPng = 'lib/static/img/hotel.png';
/// ![](http://127.0.0.1:2227/lib/static/img/taxi.png)
static final String libStaticImgTaxiPng = 'lib/static/img/taxi.png';
/// ![](http://127.0.0.1:2227/lib/static/img/mt.jpg)
static final String libStaticImgMtJpg = 'lib/static/img/mt.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/mb.jpg)
static final String libStaticImgMbJpg = 'lib/static/img/mb.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/wn.jpg)
static final String libStaticImgWnJpg = 'lib/static/img/wn.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/pgg.jpg)
static final String libStaticImgPggJpg = 'lib/static/img/pgg.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/yacj.png)
static final String libStaticImgYacjPng = 'lib/static/img/yacj.png';
/// ![](http://127.0.0.1:2227/lib/static/img/sw.jpg)
static final String libStaticImgSwJpg = 'lib/static/img/sw.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/myjr.png)
static final String libStaticImgMyjrPng = 'lib/static/img/myjr.png';
/// ![](http://127.0.0.1:2227/lib/static/img/swzf.png)
static final String libStaticImgSwzfPng = 'lib/static/img/swzf.png';
/// ![](http://127.0.0.1:2227/lib/static/img/shop.jpg)
static final String libStaticImgShopJpg = 'lib/static/img/shop.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/airplane.png)
static final String libStaticImgAirplanePng = 'lib/static/img/airplane.png';
/// ![](http://127.0.0.1:2227/lib/static/img/ry.jpg)
static final String libStaticImgRyJpg = 'lib/static/img/ry.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/hsl.jpg)
static final String libStaticImgHslJpg = 'lib/static/img/hsl.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/logo.png)
static final String libStaticImgLogoPng = 'lib/static/img/logo.png';
/// ![](http://127.0.0.1:2227/lib/static/img/wmzx.png)
static final String libStaticImgWmzxPng = 'lib/static/img/wmzx.png';
/// ![](http://127.0.0.1:2227/lib/static/img/snrq.png)
static final String libStaticImgSnrqPng = 'lib/static/img/snrq.png';
/// ![](http://127.0.0.1:2227/lib/static/img/yh.jpg)
static final String libStaticImgYhJpg = 'lib/static/img/yh.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/xka.jpg)
static final String libStaticImgXkaJpg = 'lib/static/img/xka.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/bus.png)
static final String libStaticImgBusPng = 'lib/static/img/bus.png';
/// ![](http://127.0.0.1:2227/lib/static/img/classall.png)
static final String libStaticImgClassallPng = 'lib/static/img/classall.png';
/// ![](http://127.0.0.1:2227/lib/static/img/yy.jpg)
static final String libStaticImgYyJpg = 'lib/static/img/yy.jpg';
/// ![](http://127.0.0.1:2227/lib/static/img/ll.jpg)
static final String libStaticImgLlJpg = 'lib/static/img/ll.jpg';
}

View File

@@ -0,0 +1 @@
0b03739f-aaf6-4d6d-8363-6fa78ae45389

View File

@@ -0,0 +1,5 @@
import 'package:event_bus/event_bus.dart';
class Application {
static EventBus eventBus;
}

View File

@@ -0,0 +1 @@
# 全局公共函数和事件

View File

@@ -0,0 +1 @@
9ed5090f-3c1a-46ba-b640-4cbc40d1dff0

View File

@@ -0,0 +1 @@
# App 全局的基本配置

View File

@@ -0,0 +1,68 @@
import 'package:flutter/material.dart';
import 'package:flutter_app/view/components/WebViewWidget.dart';
class Config {
// default 默认布局twoColumn 两栏布局
static String indexLayout = "default";
// 未激活时候底部tabbar 样式
static const List<Icon> tabImages = [
Icon(Icons.home, size: 25.0, color: Colors.grey,),
Icon(Icons.view_quilt, size: 25.0, color: Colors.grey,),
Icon(Icons.favorite_border, size: 25.0, color: Colors.grey,),
Icon(Icons.person_outline, size: 25.0, color: Colors.grey,),
];
// 激活时候底部tabbar 样式
static const List<Icon> tabSelectedImages = [
Icon(Icons.home, size: 25.0, color: Colors.orange,),
Icon(Icons.view_module, size: 25.0, color: Colors.orange,),
Icon(Icons.favorite, size: 25.0, color: Colors.orange,),
Icon(Icons.pperson, size: 25.0, color: Colors.orange,),
];
// 默认 白天模式
static bool dark = false;
// 默认返回 白天模式
static ThemeData themeData = getThemeData(dark);
static ThemeData themeDataDark = new ThemeData.dark();
// 返回白天还是黑夜模式
static getThemeData(bool dark){
if(dark){
return themeDataDark;
}else{
return themeDataLight;
}
}
// 默认白天模式的配置
static ThemeData themeDataLight = new ThemeData(
primarySwatch: Colors.orange,
primaryColor: Colors.orange,
accentColor: Colors.white,
primaryColorBrightness: Brightness.light,
);
// 启动页面配置
static const Map Welcome = {
"title": "夜色社区",
"img": "lib/static/img/logo.png",
"waitTime": 4,
"loadingText": "Waiting"
};
// 路由配置
static final Map<String, WidgetBuilder> routers = {
"/about": (_) => new WebViewWidget('https://github.com/helpcode', 'GitHub'),
};
static final publivKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCzkEs/kJgaFGIAM/TQRjzUtJ9v"+
"e9enk6heGj/JbcvHVOwFYw2qCNUhuaFE9rYDL+CzX3+cf7inRIJCvSnC0bdGCZ+i"+
"943uSudTkqT+guv03jTzvLy2TD+Bp41/ToNiPWG56p1keHE0Gwsr7o0waIcWrLpF"+
"JnzyW/fOYQjboRz7nwIDAQAB";
}

View File

@@ -0,0 +1,15 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCzkEs/kJgaFGIAM/TQRjzUtJ9ve9enk6heGj/JbcvHVOwFYw2q
CNUhuaFE9rYDL+CzX3+cf7inRIJCvSnC0bdGCZ+i943uSudTkqT+guv03jTzvLy2
TD+Bp41/ToNiPWG56p1keHE0Gwsr7o0waIcWrLpFJnzyW/fOYQjboRz7nwIDAQAB
AoGADgMCfDFSTSauBwoG3oG8mXSGxHJLf74b80vlEljJAAL2b+0s0cnip8EOfo0p
4tHHnPekw5eL1zGXYJHWQmeO/3ymZS/nnVq1K5YRM+AtYyUMAiChIt/zWOGXPN6k
yUARaTK/cRZNY2XPPDK0H44eLF2RDE/SObPD0BZ0u9m92aECQQDYSIrYw0klyGJe
ePaV0+2ZtVVhDYN+eYmWHu9/T+aOIPFS5ePUonBftSfcp7pTeJZ3O/eI/4W6pdzz
13MRseUZAkEA1ImPvtbL39A8OtciY16LgDX5O5Vkm5p5+TKRhG5B38bgnOQQHu2d
oJKvxjEJcWDfiJ6/ThHsFHqyvViJ+cIFdwJBAIWlpe62FdA8F9UK6EzDLXIq5DxZ
rmSL06IpMZM5G12+K4EvP26YhdoORjiKiI+l10yMiLRmOQuSDIu9GYTYqZkCQEQ5
/Ij4ju3D/PGuif14JjP8H4u/A1LoHeufDhODCWZ6gzQaCgrDoGwhaoemyi85N8i1
nRfErRJN6P7bYz9nxzUCQDC8yEIcgKczxFIo20k4R+CINyJTB5S6dsVW6gmpiHZK
6+MWkDut4o/Fibwp4jm5Fh9zau597aP5Xnt8mA2LRc8=
-----END RSA PRIVATE KEY-----

View File

@@ -0,0 +1,6 @@
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCzkEs/kJgaFGIAM/TQRjzUtJ9v
e9enk6heGj/JbcvHVOwFYw2qCNUhuaFE9rYDL+CzX3+cf7inRIJCvSnC0bdGCZ+i
943uSudTkqT+guv03jTzvLy2TD+Bp41/ToNiPWG56p1keHE0Gwsr7o0waIcWrLpF
JnzyW/fOYQjboRz7nwIDAQAB
-----END PUBLIC KEY-----

View File

@@ -0,0 +1 @@
942611d3-0164-477c-9494-5287a340012f

View File

@@ -0,0 +1,91 @@
import 'dart:io';
// ignore: non_constant_identifier_names
var preview_server_port = 2227;
void main() async {
bool working = false;
var pubSpec = new File('pubspec.yaml');
var pubLines = pubSpec.readAsLinesSync();
var newLines = <String>[];
var resource = <String>[];
for (var line in pubLines) {
if (line.contains('begin') && line.contains('#') && line.contains('assets')) {
working = true;
newLines.add(line);
}
if (line.contains('end') && line.contains('#') && line.contains('assets')) working = false;
if (working) {
if (line.trim().startsWith('#') && line.trim().endsWith('*')) {
newLines.add(line);
var directory = new Directory(line.replaceAll('#', '').replaceAll('*', '').trim());
if (directory.existsSync()) {
var list = directory.listSync(recursive: true);
resource.add("/// 静态资源配置,程序自动生成,请勿手动修改");
for (var file in list) {
if (new File(file.path)
.statSync()
.type == FileSystemEntityType.file) {
var path = file.path.replaceAll('\\', '/');
var varName = path.replaceAll('/', '_').replaceAll('.', '_').toLowerCase();
var pos = 0;
String char;
while (true) {
pos = varName.indexOf('_', pos);
if (pos == -1) break;
char = varName.substring(pos + 1, pos + 2);
varName = varName.replaceFirst('_$char', '_${char.toUpperCase()}');
pos++;
}
varName = varName.replaceAll('_', '');
resource.add("/// ![](http://127.0.0.1:$preview_server_port/$path)");
resource.add("static final String $varName = '$path';");
newLines.add(' - $path');
}
}
} else {
throw new FileSystemException('Directory wrong');
}
}
} else {
newLines.add(line);
}
}
var r = new File('lib/R.dart');
if (r.existsSync()) {
r.deleteSync();
}
r.createSync();
var content = 'class R {\n';
for (var line in resource) {
content = '$content $line\n';
}
content = '$content}\n';
r.writeAsStringSync(content);
var spec = '';
for (var line in newLines) {
spec = '$spec$line\n';
}
pubSpec.writeAsStringSync(spec);
var ser;
try {
ser = await HttpServer.bind('127.0.0.1', preview_server_port);
print('成功启动图片预览服务器于本机<$preview_server_port>端口');
ser.listen(
(req) {
var index = req.uri.path.lastIndexOf('.');
var subType = req.uri.path.substring(index);
req.response
..headers.contentType = new ContentType('image', subType)
..add(new File('.${req.uri.path}').readAsBytesSync())
..close();
},
);
} catch (e) {
print('图片预览服务器已启动或端口被占用');
}
}

View File

@@ -0,0 +1 @@
# App 开发环境下的一些代码

View File

@@ -0,0 +1 @@
0cbcbc38-50fe-4a58-aa48-e8d658c4fe89

View File

@@ -0,0 +1 @@
# 全局事件 事件总线控制,进行页面主体间通讯

View File

@@ -0,0 +1,6 @@
// ignore: camel_case_types
class indexLayoutChangeEvent {
// ignore: non_constant_identifier_names
String LayoutStyle;
indexLayoutChangeEvent(this.LayoutStyle);
}

View File

@@ -0,0 +1,5 @@
// ignore: camel_case_types
class themeChangeEvent {
bool dark;
themeChangeEvent(this.dark);
}

View File

@@ -0,0 +1 @@
6237ef09-050e-435b-85f4-d9966c31c525

View File

@@ -0,0 +1,6 @@
// ignore: camel_case_types
class config {
static const String BASE_URL = "http://192.168.0.104:3000";
//static const String BASE_URL = "https://www.geekhelp.cn";
static const String testUrl = "/index";
}

View File

@@ -0,0 +1,5 @@
# 基于dio的HTTP请求封装
- 1: config.dart 网络请求的基本配置
- 2: dio的主体封装

View File

@@ -0,0 +1,89 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/http/config.dart';
import 'package:bot_toast/bot_toast.dart';
class Http {
Dio _dio;
Http() {
this._dio = new Dio(new BaseOptions(
baseUrl: config.BASE_URL,
connectTimeout: 3000,
receiveTimeout: 3000,
));
this._dio.interceptors.add(InterceptorsWrapper(
onRequest:(RequestOptions options){
/// 请求发送前拦截,对 queryParameters 参数进行RSA公钥加密放到token中发送给后端
/// 后端私钥解密,查询数据,然后通过私钥加密数据再返回给前端
///options.headers = options.queryParameters;
///print(options.headers);
return options;
},
onResponse:(Response response) {
/// 响应拦截器,将数据返回给前端之前先使用公钥解密后端的数据,然后将解密后明文给前端
// 在返回响应数据之前做一些预处理
return response;
},
onError: (DioError e) {
return e;
}
));
}
/***
* get 请求
* url 请求地址
* params 请求参数
*/
get (String url, Object params) async {
Response response;
try {
response = await this._dio.get(url, queryParameters: params);
return response.data;
} on DioError catch (e) {
if (CancelToken.isCancel(e)) {
BotToast.showSimpleNotification(
title: 'GET请求取消',
subTitle: e.message,
hideCloseButton: true
);
}
BotToast.showSimpleNotification(
title: 'GET请求错误',
subTitle: e.message,
hideCloseButton: true
);
print(e.message);
}
}
/***
* post 请求
* url 请求地址
* params 请求参数
*/
post (String url, Object params) async {
Response response;
try {
response = await this._dio.post(url, data: params);
return response.data;
} on DioError catch (e) {
if (CancelToken.isCancel(e)) {
BotToast.showSimpleNotification(
title: 'POST请求取消',
subTitle: e.message,
hideCloseButton: true
);
}
BotToast.showSimpleNotification(
title: 'POST请求错误',
subTitle: e.message,
hideCloseButton: true
);
}
}
}

View File

@@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
// 事件总控
import 'package:event_bus/event_bus.dart';
// shared_preferences 离线数据存储
import 'package:shared_preferences/shared_preferences.dart';
// 主题切换事件
import 'package:flutter_app/event/themeChangeEvent.dart';
// 全局 event_bus 事件
import 'package:flutter_app/common/Application.dart';
// 启动欢迎组件
import 'package:flutter_app/view/components/WelcomeWidget.dart';
// 全局配置类
import 'package:flutter_app/config/index.dart';
import 'package:bot_toast/bot_toast.dart';
// 主入口
void main () async {
// 获取主题,传递给初 initApp 类
WidgetsFlutterBinding.ensureInitialized();
runApp(new initApp());
}
// ignore: camel_case_types
class initApp extends StatefulWidget {
@override
State<StatefulWidget> createState() => StartApp();
}
class StartApp extends State<initApp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: "Flutter App",
builder: BotToastInit(), //1. call BotToastInit
navigatorObservers: [BotToastNavigatorObserver()],
theme: Config.getThemeData(false),
home: WelcomeWidget(true),
routes: Config.routers,
);
}
@override
void dispose() {
super.dispose();
Application.eventBus.destroy();
}
}

View File

@@ -0,0 +1 @@
983f8dc4-232f-4709-9b17-c4279f8f0f14

View File

@@ -0,0 +1,40 @@
class StyleModel {
final int status;
final int length;
final String copyright;
final List<Infos> data;
StyleModel({ this.status, this.length, this.copyright, this.data });
factory StyleModel.fromJson(Map<String, dynamic> parsedJson){
var list = parsedJson['data'] as List;
List<Infos> imageinfo = list.map((i) => Infos.fromJson(i)).toList();
return StyleModel(
status: parsedJson['status'],
length: parsedJson['name'],
copyright: parsedJson['copyright'],
data: imageinfo,
);
}
}
class Infos {
final String title;
final String imgurl;
final String href;
final String view;
final String comments;
Infos({ this.title, this.imgurl, this.href, this.view, this.comments });
factory Infos.fromJson(Map<String, dynamic> parsedJson){
return Infos(
title: parsedJson['title'] as String,
imgurl: parsedJson['imgurl'] as String,
href: parsedJson['href'] as String,
view: parsedJson['view'] as String,
comments: parsedJson['comments'] as String,
);
}
}

View File

@@ -0,0 +1,44 @@
class Index {
int status;
List<Body> body;
Index({this.status, this.body});
Index.fromJson(Map<String, dynamic> json) {
status = json['status'];
if (json['body'] != null) {
body = new List<Body>();
json['body'].forEach((v) {
body.add(new Body.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['status'] = this.status;
if (this.body != null) {
data['body'] = this.body.map((v) => v.toJson()).toList();
}
return data;
}
}
class Body {
int id;
String text;
Body({this.id, this.text});
Body.fromJson(Map<String, dynamic> json) {
id = json['id'];
text = json['text'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['text'] = this.text;
return data;
}
}

View File

@@ -0,0 +1,3 @@
# JSON数据序列化
序列化的数据和接口数据返回的格式进行对应

View File

@@ -0,0 +1 @@
f37eb8c2-4099-4d47-9831-8291d72c4472

View File

@@ -0,0 +1 @@
# 数据请求的具体方法和view中页面分开更好解耦

View File

@@ -0,0 +1,16 @@
import 'package:flutter_app/http/config.dart';
import 'package:flutter_app/http/index.dart';
import 'package:flutter_app/model/IndexModel.dart';
class ServiceMethods {
Http _http;
ServiceMethods() {
this._http = new Http();
}
/// 获取视频数据
Future getImageList(data) async {
return new Index.fromJson(await this._http.get(config.testUrl, data));
}
}

View File

@@ -0,0 +1 @@
3fd47dee-4bcb-496c-9bb9-035c127f379f

View File

@@ -0,0 +1 @@
ad709ed6-6be2-4f94-9fe3-b24adc4cc9da

Binary file not shown.

View File

@@ -0,0 +1 @@
# App的静态资源

View File

@@ -0,0 +1 @@
3dcd5737-edd8-4571-909d-79b89a930d9e

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Some files were not shown because too many files have changed in this diff Show More