提交 edf184fe 编写于 作者: 徐群-ios's avatar 徐群-ios

初始化仓库

上级
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/
# 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/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
# Symbolication related
app.*.symbols
# Obfuscation related
app.*.map.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
# 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.
version:
revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
channel: stable
project_type: app
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
- platform: android
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
- platform: ios
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
- platform: linux
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
- platform: macos
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
- platform: web
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
- platform: windows
create_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
base_revision: b06b8b2710955028a6b562f5aa6fe62941d6febf
# User provided section
# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "my_app2",
"request": "launch",
"type": "dart",
"deviceId": "00008030-000C18503A90802E"
},
{
"name": "iOS模拟器",
"request": "launch",
"type": "dart",
"deviceId": "1DA4CCCC-D0B8-47DF-B671-FAC9B80F7030"
},
{
"name": "my_app2 (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "my_app2 (release mode)",
"request": "launch",
"type": "dart",
"flutterMode": "release",
"deviceId": "00008030-000C18503A90802E"
}
]
}
\ No newline at end of file
# my_app2
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://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks
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 plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.my_app2"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
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 {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.my_app2">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool 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>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.my_app2">
<application
android:label="my_app2"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
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">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<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>
package com.example.my_app2
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
<?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:colorBackground" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
<?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>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.my_app2">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool 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>
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
include ':app'
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
因为 它太大了无法显示 源差异 。您可以改为 查看blob
**/dgph
*.mode1v3
*.mode2v3
*.moved-aside
*.pbxuser
*.perspectivev3
**/*sync/
.sconsign.dblite
.tags*
**/.vagrant/
**/DerivedData/
Icon?
**/Pods/
**/.symlinks/
profile
xcuserdata
**/.generated/
Flutter/App.framework
Flutter/Flutter.framework
Flutter/Flutter.podspec
Flutter/Generated.xcconfig
Flutter/ephemeral/
Flutter/app.flx
Flutter/app.zip
Flutter/flutter_assets/
Flutter/flutter_export_environment.sh
ServiceDefinitions.json
Runner/GeneratedPluginRegistrant.*
# Exceptions to above rules.
!default.mode1v3
!default.mode2v3
!default.pbxuser
!default.perspectivev3
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>App</string>
<key>CFBundleIdentifier</key>
<string>io.flutter.flutter.app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>App</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
</dict>
</plist>
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
此差异已折叠。
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Profile"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-App-20x20@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-App-29x29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-App-40x40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-App-60x60@3x.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@1x.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-App-20x20@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@1x.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-App-29x29@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@1x.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-App-40x40@2x.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@1x.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-App-76x76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-App-83.5x83.5@2x.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "Icon-App-1024x1024@1x.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
{
"images" : [
{
"idiom" : "universal",
"filename" : "LaunchImage.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "LaunchImage@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "LaunchImage@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
# Launch Screen Assets
You can customize the launch screen with your own desired assets by replacing the image files in this directory.
You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Ydg-fD-yQy"/>
<viewControllerLayoutGuide type="bottom" id="xbc-2k-c8Z"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4">
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="1a2-6s-vTC"/>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="4X2-HB-R7a"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<image name="LaunchImage" width="168" height="185"/>
</resources>
</document>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--Flutter View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>My App2</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>my_app2</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
#import "GeneratedPluginRegistrant.h"
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:my_app2/Network/api/product_api.dart';
import 'package:my_app2/Network/http/BaseApi.dart';
class Customization extends StatefulWidget {
const Customization({super.key});
State<Customization> createState() => _CustomizationState();
}
class _CustomizationState extends State<Customization> {
@override
void initState() {
super.initState();
ProductListApi request = ProductListApi(page: 1, pageSize: 10);
request.request(onSuccessed: (value) {
print(value);
}, onFailed: (error) {
print(error.toString());
});
}
@override
Widget build(BuildContext context) {
List<String> dataSource = [
"https://static.preclight.com/uploads/2023-02-08/63e36bec6e8f4.png",
"https://static.preclight.com/uploads/2023-02-20/63f2e9568b736.jpg",
"https://static.preclight.com/uploads/2023-02-07/63e219498801e.jpg",
"https://static.preclight.com/uploads/2023-02-07/63e2123ea9287.jpg",
"https://static.preclight.com/uploads/2023-02-07/63e21685eb2b4.png",
"https://static.preclight.com/uploads/2023-01-31/63d8f975dc915.jpg",
"https://static.preclight.com/uploads/2023-01-31/63d8f4cde0315.jpg",
"https://static.preclight.com/uploads/2023-02-22/63f59104a7fe7.png",
"https://static.preclight.com/uploads/2023-01-19/63c8e4eb35d16.png",
"https://static.preclight.com/uploads/2022-11-30/6387278fd8022.jpg"
];
return Scaffold(
appBar: AppBar(title: const Text('热门产品')),
body: CustomScrollView(slivers: [
SliverPadding(
padding: const EdgeInsets.symmetric(horizontal: 12),
sliver: SliverList(
delegate: ProductSliverBuilderDelegate(dataSource, 10)),
),
SliverList(
delegate:
SliverChildBuilderDelegate((BuildContext context, int index) {
return const SizedBox(
height: 40,
child: Text("hello world"),
);
}, childCount: 2))
]));
}
}
class ProductSliverBuilderDelegate extends SliverChildBuilderDelegate {
static int _computeActualChildCount(int itemCount) {
return math.max(0, itemCount * 2 - 1);
}
final List<String> dataSource;
final double spacing;
ProductSliverBuilderDelegate(this.dataSource, this.spacing)
: assert(spacing > 0),
super((context, index) {
final int itemIndex = index ~/ 2;
final Widget? widget;
if (index.isEven) {
double height = MediaQuery.of(context).size.width - 12.0 * 2;
String imgUrl = dataSource[itemIndex];
widget = Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(12.0))),
clipBehavior: Clip.antiAlias,
height: height,
child: Stack(
fit: StackFit.expand,
children: [Image.network(imgUrl)],
),
);
} else {
widget = Divider(
height: spacing,
color: Colors.transparent,
);
}
return widget;
}, childCount: _computeActualChildCount(dataSource.length));
}
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_swiper_view/flutter_swiper_view.dart';
import 'package:my_app2/MockDatas/MockData.dart';
import 'package:my_app2/Models/BuyerShowModel.dart';
import 'package:waterfall_flow/waterfall_flow.dart';
// ignore: must_be_immutable
class Example01 extends StatefulWidget {
const Example01({super.key});
@override
State<Example01> createState() => _Example01State();
}
class _Example01State extends State<Example01> {
List<Color> colors = <Color>[];
List<String> imgs = <String>[
"https://static.preclight.com/uploads/2022-12-07/639040aa41197.jpg",
"https://static.preclight.com/uploads/2022-12-07/6390419bf2995.jpg",
"https://static.preclight.com/uploads/2023-01-10/63bcdd798edb3.jpg",
"https://static.preclight.com/uploads/2023-01-03/63b4258a294e8.png",
];
List<BuyerShowModel> list = [];
@override
void initState() {
super.initState();
buyershowList().then((value) {
setState(() {
list = value;
});
});
}
Widget buildWaterfallFlow(BuildContext context) {
int crossAxisCount = 2;
double crossAxisSpacing = 10.0;
double mainAxisSpacing = 10.0;
double itemWidth = (MediaQuery.of(context).size.width - 30.0) / 2.0;
return SliverWaterfallFlow(
gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount,
crossAxisSpacing: crossAxisSpacing,
mainAxisSpacing: mainAxisSpacing),
delegate: SliverChildBuilderDelegate((BuildContext c, int index) {
final BuyerShowModel model = list[index];
final double coverH = model.coverHeight / model.coverWidth * itemWidth;
return Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8.0)),
color: Colors.white),
alignment: Alignment.center,
clipBehavior: Clip.antiAlias,
child: Column(children: [
SizedBox(
width: itemWidth,
height: coverH,
child: Image.network(model.cover),
),
const SizedBox(
height: 10.0,
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Text(
model.title,
textAlign: TextAlign.left,
textDirection: TextDirection.ltr,
softWrap: true,
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: const TextStyle(
color: Color(0xFF333333),
fontSize: 13,
fontWeight: FontWeight.w800,
fontFamily: 'PingFangSC-Medium'),
),
),
const SizedBox(
height: 10,
),
Row(
children: [
const SizedBox(
width: 10,
),
SizedBox(
width: 20,
height: 20,
child: ClipRRect(
borderRadius: BorderRadius.circular(10.0),
clipBehavior: Clip.antiAlias,
child: Image.network(model.avatar),
),
),
const SizedBox(
width: 5.0,
),
Expanded(
child: Text(
model.userName,
textAlign: TextAlign.left,
textDirection: TextDirection.ltr,
softWrap: true,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style:
const TextStyle(color: Color(0xff666666), fontSize: 12),
)),
const SizedBox(
width: 10,
),
const Image(
image: AssetImage('assets/multiImgs/unlike.png'),
width: 14,
height: 14,
),
const SizedBox(
width: 5.0,
),
const Text(
'0.8万',
style: TextStyle(color: Color(0xff666666), fontSize: 12),
),
const SizedBox(
width: 10,
)
],
),
const SizedBox(
height: 18.0,
)
]),
);
}, childCount: list.length),
);
}
Widget buildTopFixedWidget(BuildContext context) {
double screenW = MediaQuery.of(context).size.width;
double bannerH = 500.0 / 375.0 * screenW;
return Stack(
children: <Widget>[
Positioned(
top: 0,
child: Container(
height: bannerH,
width: screenW,
decoration: const BoxDecoration(color: Colors.blue),
child: Swiper(
autoplay: true,
itemBuilder: (BuildContext context, int index) {
return Image.network(
imgs[index],
fit: BoxFit.fill,
);
},
itemCount: imgs.length,
pagination: const SwiperPagination(
builder: SwiperPagination.rect,
margin: EdgeInsets.symmetric(vertical: 70)),
),
),
),
Positioned(
left: 13,
right: 13,
bottom: 10,
child: Container(
height: 98,
decoration: const BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage(
'assets/multiImgs/home_floatingBar_bacground.png'))),
)),
],
);
}
@override
Widget build(BuildContext context) {
double screenW = MediaQuery.of(context).size.width;
double bannerH = 500.0 / 375.0 * screenW + 49;
return Scaffold(
appBar: AppBar(
title: const Text('Example01'),
leading: const BackButton(color: Colors.black),
backgroundColor: Colors.transparent,
elevation: 0.0,
),
backgroundColor: const Color(0xFFF7F7F7),
extendBodyBehindAppBar: true,
body: CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: SizedBox(
height: bannerH,
child: buildTopFixedWidget(context),
)),
SliverPadding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
sliver: buildWaterfallFlow(context),
),
],
));
}
Color getRandomColor(int index) {
if (index >= colors.length) {
Color color = Color.fromARGB(255, Random.secure().nextInt(255),
Random.secure().nextInt(255), Random.secure().nextInt(255));
colors.add(color);
}
return colors[index];
}
}
import 'package:flutter/material.dart';
import 'package:waterfall_flow/waterfall_flow.dart';
class Example02 extends StatelessWidget {
const Example02({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("瀑布流")),
);
}
}
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
/// 滚动视图主要由3个部分组成:Scrollable、Viewport和Sliver
/// Scrollable: 用于处理滑动手势,确定滑动偏移,滑动偏移变化时构建的Viewport
/// Viewport: 显示的视窗,即列表的可视区域
/// Sliver: 视窗里显示的元素
class ExampleModel {
const ExampleModel({required this.name, required this.path});
final String name;
final String path;
}
class ExampleList extends StatelessWidget {
ExampleList({super.key})
: examples = [
const ExampleModel(name: "example01", path: '/Example01'),
const ExampleModel(name: "stack example", path: '/StackExample')
];
final List<ExampleModel> examples;
Widget getItem(int index, BuildContext context) {
ExampleModel model = examples[index];
return GestureDetector(
child: Container(
height: 60.0,
color: Colors.blue,
padding: const EdgeInsets.fromLTRB(15, 10, 15, 10),
child: Row(children: [
const Image(image: AssetImage('assets/singleImgs/air.png')),
const SizedBox(
width: 10,
),
Text(model.name)
]),
),
onTap: () => context.go(model.path),
);
}
Widget list() {
return ListView.separated(
padding: const EdgeInsets.all(0),
itemCount: examples.length,
//列表项构造器
itemBuilder: (BuildContext context, int index) {
return getItem(index, context);
},
//分割器构造器
separatorBuilder: (BuildContext context, int index) {
return const Divider(
color: Colors.lightGreen,
height: 0.5,
);
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Example list')), body: list());
}
}
import 'package:flutter/material.dart';
import 'package:flutter_swiper_view/flutter_swiper_view.dart';
class StackExample extends StatelessWidget {
const StackExample({super.key});
@override
Widget build(BuildContext context) {
double screenW = MediaQuery.of(context).size.width;
double bannerH = 500.0 / 375.0 * screenW;
return Scaffold(
appBar: AppBar(title: const Text('Stack Example')),
body: Container(
height: 620,
decoration: const BoxDecoration(color: Colors.red),
child: Stack(children: [
Positioned(
top: 0,
child: Container(
height: bannerH,
width: screenW,
decoration: const BoxDecoration(color: Colors.blue),
child: Swiper(
itemBuilder: (BuildContext context, int index) {
return Image.network(
"https://static.preclight.com/uploads/2022-12-28/63abffead582c.jpg",
fit: BoxFit.fill,
);
},
itemCount: 5,
pagination: const SwiperPagination(
builder: SwiperPagination.rect,
margin: EdgeInsets.symmetric(vertical: 70)),
),
),
),
Positioned(
left: 13,
bottom: 10,
child: Container(
width: screenW - 26,
height: 98,
decoration: const BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage(
'assets/multiImgs/home_floatingBar_bacground.png'))),
)),
]),
),
);
}
}
import 'package:flutter/material.dart';
import 'package:my_app2/MockDatas/MockData.dart';
import 'package:my_app2/Models/BuyerShowModel.dart';
import 'package:flutter_swiper_view/flutter_swiper_view.dart';
import 'package:waterfall_flow/waterfall_flow.dart';
class Home extends StatefulWidget {
const Home({super.key});
@override
State<Home> createState() => HomeState();
}
class HomeState extends State<Home> {
List<String> imgs = <String>[
"https://static.preclight.com/uploads/2022-12-07/639040aa41197.jpg",
"https://static.preclight.com/uploads/2022-12-07/6390419bf2995.jpg",
"https://static.preclight.com/uploads/2023-01-10/63bcdd798edb3.jpg",
"https://static.preclight.com/uploads/2023-01-03/63b4258a294e8.png",
];
List<BuyerShowModel> list = [];
@override
void initState() {
super.initState();
buyershowList().then((value) {
setState(() {
list = value;
});
});
}
Widget buildWaterfallFlow(BuildContext context) {
int crossAxisCount = 2;
double crossAxisSpacing = 10.0;
double mainAxisSpacing = 10.0;
double itemWidth = (MediaQuery.of(context).size.width - 30.0) / 2.0;
return SliverWaterfallFlow(
gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount,
crossAxisSpacing: crossAxisSpacing,
mainAxisSpacing: mainAxisSpacing),
delegate: SliverChildBuilderDelegate((BuildContext c, int index) {
final BuyerShowModel model = list[index];
final double coverH = model.coverHeight / model.coverWidth * itemWidth;
return Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8.0)),
color: Colors.white),
alignment: Alignment.center,
clipBehavior: Clip.antiAlias,
child: Column(children: [
SizedBox(
width: itemWidth,
height: coverH,
child: Image.network(model.cover),
),
const SizedBox(
height: 10.0,
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Text(
model.title,
textAlign: TextAlign.left,
textDirection: TextDirection.ltr,
softWrap: true,
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: const TextStyle(
color: Color(0xFF333333),
fontSize: 13,
fontWeight: FontWeight.w800,
fontFamily: 'PingFangSC-Medium'),
),
),
const SizedBox(
height: 10,
),
Row(
children: [
const SizedBox(
width: 10,
),
SizedBox(
width: 20,
height: 20,
child: ClipRRect(
borderRadius: BorderRadius.circular(10.0),
clipBehavior: Clip.antiAlias,
child: Image.network(model.avatar),
),
),
const SizedBox(
width: 5.0,
),
Expanded(
child: Text(
model.userName,
textAlign: TextAlign.left,
textDirection: TextDirection.ltr,
softWrap: true,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style:
const TextStyle(color: Color(0xff666666), fontSize: 12),
)),
const SizedBox(
width: 10,
),
const Image(
image: AssetImage('assets/multiImgs/unlike.png'),
width: 14,
height: 14,
),
const SizedBox(
width: 5.0,
),
const Text(
'0.8万',
style: TextStyle(color: Color(0xff666666), fontSize: 12),
),
const SizedBox(
width: 10,
)
],
),
const SizedBox(
height: 18.0,
)
]),
);
}, childCount: list.length),
);
}
Widget buildTopFixedWidget(BuildContext context) {
double screenW = MediaQuery.of(context).size.width;
double bannerH = 500.0 / 375.0 * screenW;
return Stack(
children: <Widget>[
Positioned(
top: 0,
child: Container(
height: bannerH,
width: screenW,
decoration: const BoxDecoration(color: Colors.blue),
child: Swiper(
autoplay: true,
itemBuilder: (BuildContext context, int index) {
return Image.network(
imgs[index],
fit: BoxFit.fill,
);
},
itemCount: imgs.length,
pagination: const SwiperPagination(
builder: SwiperPagination.rect,
margin: EdgeInsets.symmetric(vertical: 70)),
),
),
),
Positioned(
left: 13,
right: 13,
bottom: 10,
child: Container(
height: 98,
decoration: const BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage(
'assets/multiImgs/home_floatingBar_bacground.png'))),
)),
],
);
}
@override
Widget build(BuildContext context) {
double screenW = MediaQuery.of(context).size.width;
double bannerH = 500.0 / 375.0 * screenW + 49;
return Scaffold(
appBar: AppBar(
title: const Text(''),
backgroundColor: Colors.transparent,
elevation: 0.0,
),
backgroundColor: const Color(0xFFF7F7F7),
extendBodyBehindAppBar: true,
body: CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: SizedBox(
height: bannerH,
child: buildTopFixedWidget(context),
)),
SliverPadding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
sliver: buildWaterfallFlow(context),
),
],
),
);
}
}
import 'package:flutter/material.dart';
class Mine extends StatelessWidget {
const Mine({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('我的')),
body: const Center(child: Text('我的')),
);
}
}
import 'dart:convert';
import 'package:flutter/services.dart' show rootBundle;
import 'package:my_app2/Models/BuyerShowModel.dart';
class BuyerShowResult {
BuyerShowResult(this.total, this.page, this.pageSize, this.dataList);
final int total;
final int page;
final int pageSize;
List<BuyerShowModel>? dataList;
BuyerShowResult.fromJson(Map<String, dynamic> json)
: total = json['total'],
page = json['page'],
pageSize = json['pageSize'] {
if (json['data_list'] != null) {
var list = <BuyerShowModel>[];
json['data_list'].forEach((v) {
list.add(BuyerShowModel.fromJson(v));
});
dataList = list;
}
}
}
Future<String> _loadJson(String assets) async {
return await rootBundle.loadString(assets);
}
Future<List<BuyerShowModel>> buyershowList() async {
String jsonString = await _loadJson('assets/buyershows.json');
final jsonResponse = json.decode(jsonString);
BuyerShowResult result = BuyerShowResult.fromJson(jsonResponse);
return result.dataList ?? [];
}
import 'package:json_annotation/json_annotation.dart';
part 'BuyerShowModel.g.dart';
@JsonSerializable()
class BuyerShowModel {
BuyerShowModel(this.title, this.cover, this.coverWidth, this.coverHeight,
this.avatar, this.userName);
@JsonKey(defaultValue: '')
final String title;
@JsonKey(defaultValue: '')
final String cover;
@JsonKey(name: 'cover_width', defaultValue: 0)
final double coverWidth;
@JsonKey(name: 'cover_height', defaultValue: 0)
final double coverHeight;
@JsonKey(name: 'create_avatar', defaultValue: '')
final String avatar;
@JsonKey(name: 'create_user', defaultValue: '')
final String userName;
factory BuyerShowModel.fromJson(Map<String, dynamic> json) =>
_$BuyerShowModelFromJson(json);
Map<String, dynamic> toJson() => _$BuyerShowModelToJson(this);
}
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'BuyerShowModel.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
BuyerShowModel _$BuyerShowModelFromJson(Map<String, dynamic> json) =>
BuyerShowModel(
json['title'] as String? ?? '',
json['cover'] as String? ?? '',
(json['cover_width'] as num?)?.toDouble() ?? 0,
(json['cover_height'] as num?)?.toDouble() ?? 0,
json['create_avatar'] as String? ?? '',
json['create_user'] as String? ?? '',
);
Map<String, dynamic> _$BuyerShowModelToJson(BuyerShowModel instance) =>
<String, dynamic>{
'title': instance.title,
'cover': instance.cover,
'cover_width': instance.coverWidth,
'cover_height': instance.coverHeight,
'create_avatar': instance.avatar,
'create_user': instance.userName,
};
import 'package:json_annotation/json_annotation.dart';
part 'ProductModel.g.dart';
@JsonSerializable()
class ProductModel {
ProductModel(this.id, this.productType, this.cover, this.productName);
@JsonKey(defaultValue: 0)
final int id;
@JsonKey(name: 'product_type', defaultValue: 1)
final int productType;
@JsonKey(name: 'product_front_pic', defaultValue: '')
final String cover;
@JsonKey(name: 'product_name', defaultValue: '')
final String productName;
factory ProductModel.fromJson(Map<String, dynamic> json) =>
_$ProductModelFromJson(json);
Map<String, dynamic> toJson() => _$ProductModelToJson(this);
}
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'ProductModel.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
ProductModel _$ProductModelFromJson(Map<String, dynamic> json) => ProductModel(
json['id'] as int? ?? 0,
json['product_type'] as int? ?? 1,
json['product_front_pic'] as String? ?? '',
json['product_name'] as String? ?? '',
);
Map<String, dynamic> _$ProductModelToJson(ProductModel instance) =>
<String, dynamic>{
'id': instance.id,
'product_type': instance.productType,
'product_front_pic': instance.cover,
'product_name': instance.productName,
};
import 'package:my_app2/Models/ProductModel.dart';
import 'package:my_app2/Network/http/BaseApi.dart';
import 'package:my_app2/Network/service/XmhService.dart';
class ProductListApi extends BaseApi<List<ProductModel>> {
ProductListApi({required this.page, required this.pageSize});
final int page;
final int pageSize;
@override
String serviceKey() {
return XmhServiceKey;
}
@override
RequestMethod method() {
return RequestMethod.get;
}
@override
String uri() {
return '/magicbox/product/getProductList';
}
@override
HttpParams get getApiQuery => {'page': page, 'pageSize': pageSize};
@override
List<ProductModel>? toModel(Map<String, dynamic> json) {
if (json['data'] != null && json['data']['data_list'] != null) {
var dataList = json['data']['data_list'];
List<ProductModel> list = [];
dataList.forEach((v) {
list.add(ProductModel.fromJson(v));
});
return list;
}
return null;
}
}
import 'dart:convert';
import './Service.dart';
import 'package:dio/dio.dart';
import './ServiceManager.dart';
enum RequestMethod { get, post }
typedef HttpParams = Map<String, dynamic>;
typedef HttpHeader = Map<String, dynamic>;
class Test {
Test(this.value);
final int value;
}
class AA<T> {
T getResponse(Map<String, dynamic> json) => throw Exception('子类重写');
}
class BB extends AA<Test> {
@override
Test getResponse(Map<String, dynamic> json) {
return Test(1);
}
}
class BaseApi<Model> {
String serviceKey() {
return "";
}
String uri() {
return "";
}
RequestMethod method() {
return RequestMethod.get;
}
HttpParams get getApiQuery => {};
HttpParams get getApiBody => {};
HttpHeader get getApiHeader => {};
Model? toModel(Map<String, dynamic> json) {
throw Exception('子类重写');
}
}
class ApiError {
ApiError.system(this.message) : code = -999999;
ApiError.server({required this.code, this.message});
final int code;
final String? message;
@override
String toString() {
return message ?? "";
}
}
extension ApiRequest<Model> on BaseApi<Model> {
void request(
{required Function(Model?) onSuccessed,
required Function(ApiError) onFailed}) async {
Service service;
if (ServiceManager().serviceMap.containsKey(serviceKey())) {
service = ServiceManager().getService(serviceKey());
} else {
throw Exception('服务尚未注册');
}
Dio dio = service.dio;
Map<String, dynamic>? headerParams = {};
var globalHeaderParams = service.serviceHeader();
if (globalHeaderParams != null) {
headerParams.addAll(globalHeaderParams);
}
headerParams.addAll(getApiHeader);
Map<String, dynamic>? queryParams = {};
var globalQueryParams = service.serviceQuery();
if (globalQueryParams != null) {
queryParams.addAll(globalQueryParams);
}
queryParams.addAll(getApiQuery);
Map<String, dynamic>? bodyParams = {};
var globalBodyParams = service.serviceBody();
if (globalBodyParams != null) {
bodyParams.addAll(globalBodyParams);
}
bodyParams.addAll(getApiBody);
Options options = Options(headers: headerParams);
Response? response;
try {
switch (method()) {
case RequestMethod.get:
response = await dio.get(uri(),
queryParameters: queryParams, options: options);
break;
case RequestMethod.post:
response = await dio.post(uri(),
data: bodyParams, queryParameters: queryParams, options: options);
break;
}
} on DioError catch (error) {
onFailed(ApiError.system(service.errorFactory(error)));
}
if (response != null && response.data != null) {
String dataStr = json.encode(response.data);
Map<String, dynamic> dataMap = json.decode(dataStr);
dataMap = service.responseFactory(dataMap);
int code = dataMap['code'];
if (code == 0) {
Model? resModel = toModel(dataMap);
onSuccessed(resModel);
} else {
String message = dataMap['msg'] ?? "";
onFailed(ApiError.server(code: code, message: message));
}
}
}
}
import 'package:dio/dio.dart';
class Service {
final Dio dio = Dio();
late var _baseUrl = "";
set baseUrl(value) {
if (_baseUrl == value) {
return;
}
_baseUrl = value;
dio.options.baseUrl = _baseUrl;
}
get baseUrl => _baseUrl;
Map<String, dynamic>? serviceHeader() {
return null;
}
Map<String, dynamic>? serviceQuery() {
return null;
}
Map<String, dynamic>? serviceBody() {
return null;
}
/// dio 默认设置,由具体的服务去实现
void initDio() {}
/// 数据加工
Map<String, dynamic> responseFactory(Map<String, dynamic> dataMap) {
return dataMap;
}
String errorFactory(DioError error) {
String errorMessage;
switch (error.type) {
case DioErrorType.connectionTimeout:
errorMessage = "Connection timeout";
break;
case DioErrorType.receiveTimeout:
errorMessage = "Receive timeout";
break;
case DioErrorType.sendTimeout:
errorMessage = "Send timeout";
break;
default:
errorMessage = error.message ?? "未知错误";
}
return errorMessage;
}
String serviceKey() {
return "";
}
}
import './Service.dart';
class ServiceManager {
static final ServiceManager _instance = ServiceManager._internal();
factory ServiceManager() {
return _instance;
}
ServiceManager._internal();
Map serviceMap = {};
int test = 1;
void init() {
print('init');
print(serviceMap);
print('hello world ${this.hashCode}');
}
void registService(Service service) {
service.initDio();
String key = service.serviceKey();
serviceMap[key] = service;
test += 1;
}
Service getService(String servieKey) {
if (serviceMap.containsKey(servieKey)) {
return serviceMap[servieKey];
}
throw Exception('服务尚未注册');
}
}
import '../http/Service.dart';
import 'package:dio/dio.dart';
const String XmhServiceKey = "_XmhServiceKey";
class XmhService extends Service {
@override
String serviceKey() {
return XmhServiceKey;
}
@override
void initDio() {
dio.options.headers = {
'Accept': 'application/json,*/*',
'Content-Type': 'application/json'
};
dio.options.baseUrl = 'https://platform.upmobius.com';
dio.options.connectTimeout = const Duration(seconds: 10);
dio.options.receiveTimeout = const Duration(seconds: 10);
dio.options.contentType = 'application/json';
dio.interceptors.add(LogInterceptor(requestBody: true, responseBody: true));
}
}
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:my_app2/Customization/Customization.dart';
import 'package:my_app2/Home/Home.dart';
import 'package:my_app2/Mine/Mine.dart';
import 'package:my_app2/Network/http/ServiceManager.dart';
import 'package:my_app2/Network/service/XmhService.dart';
void main() {
runApp(const MyApp());
ServiceManager().registService(XmhService());
}
// final GoRouter _router = GoRouter(routes: <RouteBase>[
// GoRoute(
// path: '/',
// builder: (context, state) => ExampleList(),
// routes: <RouteBase>[
// GoRoute(
// path: 'Example01',
// builder: (context, state) => Example01(),
// ),
// GoRoute(
// path: 'StackExample',
// builder: (context, state) => const StackExample(),
// )
// ])
// ]);
final GoRouter _router = GoRouter(routes: <RouteBase>[
GoRoute(
path: '/',
builder: (context, state) => const App(),
routes: <RouteBase>[])
]);
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routerConfig: _router,
);
}
}
class App extends StatefulWidget {
const App({super.key});
@override
State<App> createState() => _AppState();
}
class _AppState extends State<App> {
int _currentIndex = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: IndexedStack(
index: _currentIndex,
children: const [Home(), Customization(), Mine()],
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex,
items: const [
BottomNavigationBarItem(
icon: ImageIcon(
AssetImage('assets/multiImgs/home.png'),
size: 32,
),
label: '首页'),
BottomNavigationBarItem(
icon: ImageIcon(
AssetImage('assets/multiImgs/custom.png'),
size: 32,
),
label: '定制'),
BottomNavigationBarItem(
icon: ImageIcon(
AssetImage('assets/multiImgs/mine.png'),
size: 32,
),
label: '我的')
],
onTap: (index) {
setState(() {
_currentIndex = index;
});
},
),
);
}
}
flutter/ephemeral
# Project-level configuration.
cmake_minimum_required(VERSION 3.10)
project(runner LANGUAGES CXX)
# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "my_app2")
# The unique GTK application identifier for this application. See:
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
set(APPLICATION_ID "com.example.my_app2")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
cmake_policy(SET CMP0063 NEW)
# Load bundled libraries from the lib/ directory relative to the binary.
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
# Root filesystem for cross-building.
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endif()
# Define build configuration options.
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()
# Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_14)
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
endfunction()
# Flutter library and tool build rules.
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
add_subdirectory(${FLUTTER_MANAGED_DIR})
# System-level dependencies.
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
# Define the application target. To change its name, change BINARY_NAME above,
# not the value here, or `flutter run` will no longer work.
#
# Any new source files that you add to the application should be added here.
add_executable(${BINARY_NAME}
"main.cc"
"my_application.cc"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
)
# Apply the standard set of build settings. This can be removed for applications
# that need different build settings.
apply_standard_settings(${BINARY_NAME})
# Add dependency libraries. Add any application-specific dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)
# Only the install-generated bundle's copy of the executable will launch
# correctly, since the resources must in the right relative locations. To avoid
# people trying to run the unbundled copy, put it in a subdirectory instead of
# the default top-level location.
set_target_properties(${BINARY_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
)
# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)
# === Installation ===
# By default, "installing" just makes a relocatable bundle in the build
# directory.
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()
# Start with a clean build bundle directory every time.
install(CODE "
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
" COMPONENT Runtime)
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
install(FILES "${bundled_library}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endforeach(bundled_library)
# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
# Install the AOT library on non-Debug builds only.
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册