Skip to content

Commit e1fd255

Browse files
add
1 parent eaa6ca5 commit e1fd255

File tree

193 files changed

+11150
-70
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+11150
-70
lines changed

README.md

Lines changed: 413 additions & 70 deletions
Large diffs are not rendered by default.

flutter_guide/.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
.dart_tool/
26+
.flutter-plugins
27+
.flutter-plugins-dependencies
28+
.packages
29+
.pub-cache/
30+
.pub/
31+
/build/
32+
33+
# Web related
34+
lib/generated_plugin_registrant.dart
35+
36+
# Symbolication related
37+
app.*.symbols
38+
39+
# Obfuscation related
40+
app.*.map.json
41+
42+
# Exceptions to above rules.
43+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

flutter_guide/.metadata

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: b041144f833e05cf463b8887fa12efdec9493488
8+
channel: stable
9+
10+
project_type: app

flutter_guide/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# guide
2+
3+
A new Flutter application.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13+
14+
For help getting started with Flutter, view our
15+
[online documentation](https://flutter.dev/docs), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.

flutter_guide/android/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
gradle-wrapper.jar
2+
/.gradle
3+
/captures/
4+
/gradlew
5+
/gradlew.bat
6+
/local.properties
7+
GeneratedPluginRegistrant.java
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
def localProperties = new Properties()
2+
def localPropertiesFile = rootProject.file('local.properties')
3+
if (localPropertiesFile.exists()) {
4+
localPropertiesFile.withReader('UTF-8') { reader ->
5+
localProperties.load(reader)
6+
}
7+
}
8+
9+
def flutterRoot = localProperties.getProperty('flutter.sdk')
10+
if (flutterRoot == null) {
11+
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12+
}
13+
14+
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15+
if (flutterVersionCode == null) {
16+
flutterVersionCode = '1'
17+
}
18+
19+
def flutterVersionName = localProperties.getProperty('flutter.versionName')
20+
if (flutterVersionName == null) {
21+
flutterVersionName = '1.0'
22+
}
23+
24+
apply plugin: 'com.android.application'
25+
apply plugin: 'kotlin-android'
26+
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27+
28+
android {
29+
compileSdkVersion 28
30+
31+
sourceSets {
32+
main.java.srcDirs += 'src/main/kotlin'
33+
}
34+
35+
lintOptions {
36+
disable 'InvalidPackage'
37+
}
38+
39+
defaultConfig {
40+
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
41+
applicationId "com.flutter.guide"
42+
minSdkVersion 16
43+
targetSdkVersion 28
44+
versionCode flutterVersionCode.toInteger()
45+
versionName flutterVersionName
46+
}
47+
48+
buildTypes {
49+
release {
50+
// TODO: Add your own signing config for the release build.
51+
// Signing with the debug keys for now, so `flutter run --release` works.
52+
signingConfig signingConfigs.debug
53+
}
54+
}
55+
}
56+
57+
flutter {
58+
source '../..'
59+
}
60+
61+
dependencies {
62+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
63+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.flutter.guide">
3+
<!-- Flutter needs it to communicate with the running application
4+
to allow setting breakpoints, to provide hot reload, etc.
5+
-->
6+
<uses-permission android:name="android.permission.INTERNET"/>
7+
</manifest>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.flutter.guide">
3+
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
4+
calls FlutterMain.startInitialization(this); in its onCreate method.
5+
In most cases you can leave this as-is, but you if you want to provide
6+
additional functionality it is fine to subclass or reimplement
7+
FlutterApplication and put your custom class here. -->
8+
<application
9+
android:name="io.flutter.app.FlutterApplication"
10+
android:label="guide"
11+
android:icon="@mipmap/ic_launcher">
12+
<activity
13+
android:name=".MainActivity"
14+
android:launchMode="singleTop"
15+
android:theme="@style/LaunchTheme"
16+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
17+
android:hardwareAccelerated="true"
18+
android:windowSoftInputMode="adjustResize">
19+
20+
<meta-data
21+
android:name="io.flutter.embedding.android.NormalTheme"
22+
android:resource="@style/NormalTheme"
23+
/>
24+
25+
<meta-data
26+
android:name="io.flutter.embedding.android.SplashScreenDrawable"
27+
android:resource="@drawable/launch_background"
28+
/>
29+
<intent-filter>
30+
<action android:name="android.intent.action.MAIN"/>
31+
<category android:name="android.intent.category.LAUNCHER"/>
32+
</intent-filter>
33+
34+
<intent-filter>
35+
<action android:name="android.intent.action.VIEW"/>
36+
<category android:name="android.intent.category.DEFAULT" />
37+
<category android:name="android.intent.category.BROWSABLE" />
38+
<data android:scheme="ubnet" android:host="ub.com"/>
39+
</intent-filter>
40+
41+
</activity>
42+
<!-- Don't delete the meta-data below.
43+
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
44+
<meta-data
45+
android:name="flutterEmbedding"
46+
android:value="2" />
47+
</application>
48+
</manifest>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.flutter.guide
2+
3+
import android.app.Activity
4+
import android.util.Log
5+
import io.flutter.plugin.common.*
6+
import java.util.*
7+
import kotlin.concurrent.timerTask
8+
9+
/**
10+
* des:
11+
*/
12+
class BasicMessageChannelDemo(var activity: Activity, messenger: BinaryMessenger) : BasicMessageChannel.MessageHandler<Any> {
13+
14+
private var channel: BasicMessageChannel<Any>
15+
private var count = 0
16+
17+
init {
18+
channel = BasicMessageChannel(messenger, "com.flutter.guide.BasicMessageChannel", StandardMessageCodec())
19+
channel.setMessageHandler(this)
20+
startTimer()
21+
}
22+
23+
24+
fun startTimer() {
25+
var timer = Timer().schedule(timerTask {
26+
activity.runOnUiThread {
27+
var map = mapOf("count" to count++)
28+
channel.send(map,object :BasicMessageChannel.Reply<Any>{
29+
override fun reply(reply: Any?) {
30+
31+
}
32+
})
33+
}
34+
}, 0, 1000)
35+
36+
}
37+
38+
override fun onMessage(message: Any?, reply: BasicMessageChannel.Reply<Any>) {
39+
val name = (message as Map<String, Any>)["name"]
40+
val age = (message as Map<String, Any>)["age"]
41+
42+
var map = mapOf("name" to "hello,$name",
43+
"age" to "$age"
44+
)
45+
46+
reply.reply(map)
47+
}
48+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.flutter.guide
2+
3+
import android.app.Activity
4+
import io.flutter.plugin.common.BasicMessageChannel
5+
import io.flutter.plugin.common.BinaryMessenger
6+
import io.flutter.plugin.common.EventChannel
7+
import java.util.*
8+
import kotlin.concurrent.timerTask
9+
10+
class EventChannelDemo(var activity: Activity, messenger: BinaryMessenger):EventChannel.StreamHandler {
11+
private var channel: EventChannel
12+
private var index = 0
13+
private var events: EventChannel.EventSink? = null
14+
init {
15+
channel = EventChannel(messenger, "com.flutter.guide.EventChannel")
16+
channel.setStreamHandler(this)
17+
startTimer()
18+
}
19+
20+
21+
fun startTimer() {
22+
var timer = Timer().schedule(timerTask {
23+
index++
24+
var map = mapOf("name" to "laomeng${index}",
25+
"age" to "${index}"
26+
)
27+
activity.runOnUiThread {
28+
events?.success(map)
29+
}
30+
31+
}, 0, 1000)
32+
33+
}
34+
35+
override fun onListen(arguments: Any?, events: EventChannel.EventSink?) {
36+
this.events = events
37+
}
38+
39+
override fun onCancel(arguments: Any?) {
40+
this.events = null
41+
}
42+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.flutter.guide
2+
3+
import io.flutter.embedding.android.FlutterActivity
4+
import io.flutter.embedding.engine.FlutterEngine
5+
6+
class MainActivity : FlutterActivity() {
7+
8+
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
9+
super.configureFlutterEngine(flutterEngine)
10+
MethodChannelDemo(this,flutterEngine.dartExecutor.binaryMessenger)
11+
BasicMessageChannelDemo(this,flutterEngine.dartExecutor.binaryMessenger)
12+
EventChannelDemo(this,flutterEngine.dartExecutor.binaryMessenger)
13+
flutterEngine.plugins.add(MyPlugin())
14+
}
15+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.flutter.guide
2+
3+
import android.app.Activity
4+
import android.content.Context
5+
import androidx.annotation.UiThread
6+
import io.flutter.plugin.common.BinaryMessenger
7+
import io.flutter.plugin.common.MethodCall
8+
import io.flutter.plugin.common.MethodChannel
9+
import java.util.*
10+
import kotlin.concurrent.timerTask
11+
12+
/**
13+
* des:
14+
*/
15+
class MethodChannelDemo(var activity: Activity, messenger: BinaryMessenger) : MethodChannel.MethodCallHandler {
16+
17+
private var channel: MethodChannel
18+
private var count = 0
19+
20+
init {
21+
channel = MethodChannel(messenger, "com.flutter.guide.MethodChannel")
22+
channel.setMethodCallHandler(this)
23+
startTimer()
24+
}
25+
26+
27+
fun startTimer() {
28+
var timer = Timer().schedule(timerTask {
29+
activity.runOnUiThread {
30+
var map = mapOf("count" to count++)
31+
channel.invokeMethod("timer", map)
32+
}
33+
}, 0, 1000)
34+
35+
}
36+
37+
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
38+
if (call.method == "sendData") {
39+
val name = call.argument("name") as String?
40+
val age = call.argument("age") as Int?
41+
42+
var map = mapOf("name" to "hello,$name",
43+
"age" to "$age"
44+
)
45+
result.success(map)
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)