Skip to content

Commit fbb78c8

Browse files
Add flutter basics
1 parent 8384a7f commit fbb78c8

Some content is hidden

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

65 files changed

+1714
-0
lines changed

.github/workflows/flutter-basics.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Flutter basics
2+
3+
on: [push]
4+
5+
env:
6+
flutter_version: "1.9.1+hotfix.6"
7+
java_version: "12.x"
8+
9+
jobs:
10+
format:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 5
13+
steps:
14+
- uses: actions/checkout@v1
15+
- uses: actions/setup-java@v1
16+
with:
17+
java-version: ${{ env.java_version }}
18+
- uses: subosito/flutter-action@v1
19+
with:
20+
flutter-version: ${{ env.flutter_version }}
21+
- name: Install dependencies
22+
run: |
23+
cd flutter-basics
24+
flutter pub get
25+
- name: Lint
26+
run: flutter format --dry-run . --set-exit-if-changed
27+
28+
lint:
29+
runs-on: ubuntu-latest
30+
timeout-minutes: 5
31+
steps:
32+
- uses: actions/checkout@v1
33+
- uses: actions/setup-java@v1
34+
with:
35+
java-version: ${{ env.java_version }}
36+
- uses: subosito/flutter-action@v1
37+
with:
38+
flutter-version: ${{ env.flutter_version }}
39+
- name: Install dependencies
40+
run: |
41+
cd flutter-basics
42+
flutter pub get
43+
- name: Lint
44+
run: flutter analyze
45+
46+
test:
47+
runs-on: ubuntu-latest
48+
timeout-minutes: 5
49+
steps:
50+
- uses: actions/checkout@v1
51+
- uses: actions/setup-java@v1
52+
with:
53+
java-version: ${{ env.java_version }}
54+
- uses: subosito/flutter-action@v1
55+
with:
56+
flutter-version: ${{ env.flutter_version }}
57+
- name: |
58+
cd flutter-basics
59+
Install dependencies
60+
run: flutter pub get
61+
- name: Test
62+
run: flutter test
63+
64+
build:
65+
runs-on: ubuntu-latest
66+
timeout-minutes: 5
67+
needs: [format, lint, test]
68+
steps:
69+
- uses: actions/checkout@v1
70+
- uses: actions/setup-java@v1
71+
with:
72+
java-version: ${{ env.java_version }}
73+
- uses: subosito/flutter-action@v1
74+
with:
75+
flutter-version: ${{ env.flutter_version }}
76+
- name: Install dependencies
77+
run: |
78+
cd flutter-basics
79+
flutter pub get
80+
- name: Build
81+
run: flutter build apk

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ Each project
2727

2828
### Dart
2929
- [GitHub Actions Workflow with Flutter installation cache](flutter-install-cache)
30+
- [Flutter basics: screens, routing, tests, data input, CI](flutter-basics)

flutter-basics/.gitignore

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
.packages
28+
.pub-cache/
29+
.pub/
30+
/build/
31+
32+
# Android related
33+
**/android/**/gradle-wrapper.jar
34+
**/android/.gradle
35+
**/android/captures/
36+
**/android/gradlew
37+
**/android/gradlew.bat
38+
**/android/local.properties
39+
**/android/**/GeneratedPluginRegistrant.java
40+
41+
# iOS/XCode related
42+
**/ios/**/*.mode1v3
43+
**/ios/**/*.mode2v3
44+
**/ios/**/*.moved-aside
45+
**/ios/**/*.pbxuser
46+
**/ios/**/*.perspectivev3
47+
**/ios/**/*sync/
48+
**/ios/**/.sconsign.dblite
49+
**/ios/**/.tags*
50+
**/ios/**/.vagrant/
51+
**/ios/**/DerivedData/
52+
**/ios/**/Icon?
53+
**/ios/**/Pods/
54+
**/ios/**/.symlinks/
55+
**/ios/**/profile
56+
**/ios/**/xcuserdata
57+
**/ios/.generated/
58+
**/ios/Flutter/App.framework
59+
**/ios/Flutter/Flutter.framework
60+
**/ios/Flutter/Generated.xcconfig
61+
**/ios/Flutter/app.flx
62+
**/ios/Flutter/app.zip
63+
**/ios/Flutter/flutter_assets/
64+
**/ios/Flutter/flutter_export_environment.sh
65+
**/ios/ServiceDefinitions.json
66+
**/ios/Runner/GeneratedPluginRegistrant.*
67+
68+
# Exceptions to above rules.
69+
!**/ios/**/default.mode1v3
70+
!**/ios/**/default.mode2v3
71+
!**/ios/**/default.pbxuser
72+
!**/ios/**/default.perspectivev3
73+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

flutter-basics/.metadata

+10
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: 68587a0916366e9512a78df22c44163d041dd5f3
8+
channel: stable
9+
10+
project_type: app

flutter-basics/.vscode/extension.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"recommendations": [
3+
"dart-code.flutter",
4+
"dart-code.dart-code",
5+
"coenraads.bracket-pair-colorizer-2"
6+
]
7+
}

flutter-basics/.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.formatOnSave": true,
3+
}

flutter-basics/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Flutter basics
2+
3+
Screens, routing, tests, data input, CI
4+
5+
## Usage
6+
7+
[Test workflow](../.github/workflows/flutter-basics.yml)
8+
9+
```
10+
flutter pub get
11+
flutter format --dry-run . --set-exit-if-changed
12+
flutter analyze
13+
flutter test
14+
flutter build apk
15+
```
+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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.example.flutter_demo"
42+
minSdkVersion 16
43+
targetSdkVersion 28
44+
versionCode flutterVersionCode.toInteger()
45+
versionName flutterVersionName
46+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
47+
}
48+
49+
buildTypes {
50+
release {
51+
// TODO: Add your own signing config for the release build.
52+
// Signing with the debug keys for now, so `flutter run --release` works.
53+
signingConfig signingConfigs.debug
54+
}
55+
}
56+
}
57+
58+
flutter {
59+
source '../..'
60+
}
61+
62+
dependencies {
63+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
64+
testImplementation 'junit:junit:4.12'
65+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
66+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
67+
}
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.example.flutter_demo">
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>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.example.flutter_demo">
3+
4+
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
5+
calls FlutterMain.startInitialization(this); in its onCreate method.
6+
In most cases you can leave this as-is, but you if you want to provide
7+
additional functionality it is fine to subclass or reimplement
8+
FlutterApplication and put your custom class here. -->
9+
<application
10+
android:name="io.flutter.app.FlutterApplication"
11+
android:label="flutter_demo"
12+
android:icon="@mipmap/ic_launcher">
13+
<activity
14+
android:name=".MainActivity"
15+
android:launchMode="singleTop"
16+
android:theme="@style/LaunchTheme"
17+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
18+
android:hardwareAccelerated="true"
19+
android:windowSoftInputMode="adjustResize">
20+
<!-- This keeps the window background of the activity showing
21+
until Flutter renders its first frame. It can be removed if
22+
there is no splash screen (such as the default splash screen
23+
defined in @style/LaunchTheme). -->
24+
<meta-data
25+
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
26+
android:value="true" />
27+
<intent-filter>
28+
<action android:name="android.intent.action.MAIN"/>
29+
<category android:name="android.intent.category.LAUNCHER"/>
30+
</intent-filter>
31+
</activity>
32+
</application>
33+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.example.flutter_demo
2+
3+
import android.os.Bundle
4+
5+
import io.flutter.app.FlutterActivity
6+
import io.flutter.plugins.GeneratedPluginRegistrant
7+
8+
class MainActivity: FlutterActivity() {
9+
override fun onCreate(savedInstanceState: Bundle?) {
10+
super.onCreate(savedInstanceState)
11+
GeneratedPluginRegistrant.registerWith(this)
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Modify this file to customize your launch splash screen -->
3+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
4+
<item android:drawable="@android:color/white" />
5+
6+
<!-- You can insert your own image assets here -->
7+
<!-- <item>
8+
<bitmap
9+
android:gravity="center"
10+
android:src="@mipmap/launch_image" />
11+
</item> -->
12+
</layer-list>
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
4+
<!-- Show a splash screen on the activity. Automatically removed when
5+
Flutter draws its first frame -->
6+
<item name="android:windowBackground">@drawable/launch_background</item>
7+
</style>
8+
</resources>
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.example.flutter_demo">
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>

flutter-basics/android/build.gradle

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
buildscript {
2+
ext.kotlin_version = '1.2.71'
3+
repositories {
4+
google()
5+
jcenter()
6+
}
7+
8+
dependencies {
9+
classpath 'com.android.tools.build:gradle:3.2.1'
10+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11+
}
12+
}
13+
14+
allprojects {
15+
repositories {
16+
google()
17+
jcenter()
18+
}
19+
}
20+
21+
rootProject.buildDir = '../build'
22+
subprojects {
23+
project.buildDir = "${rootProject.buildDir}/${project.name}"
24+
}
25+
subprojects {
26+
project.evaluationDependsOn(':app')
27+
}
28+
29+
task clean(type: Delete) {
30+
delete rootProject.buildDir
31+
}
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.gradle.jvmargs=-Xmx1536M
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Fri Jun 23 08:50:38 CEST 2017
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

0 commit comments

Comments
 (0)