Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
image: cirrusci/flutter:3.3.0

cache:
paths:
- /flutter/bin/cache/dart-sdk

include:
- template: 'Workflows/Branch-Pipelines.gitlab-ci.yml'

stages:
- check
- test
- build
- release

# Check app for format and lint exceptions (fail fast)
Check App:
stage: check
except:
- main
before_script:
- flutter --version
script:
- make format
- make clean
- make lint

# Check code quality
code_quality:
stage: test
except:
- main
before_script:
- export PATH="$PATH":"$HOME/.pub-cache/bin"
- flutter pub global activate dart_code_metrics
script:
- metrics lib -r codeclimate > gl-code-quality-report.json
artifacts:
reports:
codequality: gl-code-quality-report.json

# Run tests and report quality
Test:
stage: test
except:
- main
before_script:
- export PATH="$PATH":"$HOME/.pub-cache/bin"
- flutter pub global activate junitreport
script:
- flutter test --machine --coverage | tojunit -o report.xml
- lcov --summary coverage/lcov.info
- genhtml coverage/lcov.info --output=coverage
coverage: '/lines\.*: \d+\.\d+\%/'
artifacts:
name: coverage
paths:
- $CI_PROJECT_DIR/coverage
reports:
junit: report.xml

# Build the app to check if release builds still work
Build Android (.apk):
stage: build
except:
- main
script:
- make build-android-apk
dependencies:
- Check App
artifacts:
expire_in: 2 days
paths:
- build-output/app.apk
25 changes: 25 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "counter_workshop",
"request": "launch",
"type": "dart"
},
{
"name": "counter_workshop (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "counter_workshop (release mode)",
"request": "launch",
"type": "dart",
"flutterMode": "release"
}
]
}
104 changes: 104 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#
# Makefile for CI/CD Environments and commandline users
#

# Dev Builds
run-dev:
flutter run
run-stage:
flutter run
run-prod:
flutter run

# Profile Builds
run-dev-profile:
flutter run --profile
run-stage-profile:
flutter run --profile
run-prod-profile:
flutter run --profile

# Release Builds
run-dev-release:
flutter run --release
run-stage-release:
flutter run --release
run-prod-release:
flutter run --release

# Format & Lint
format:
flutter format . --line-length 120 --set-exit-if-changed
format-fix:
flutter format . --line-length 120
lint:
flutter analyze

# Testing
test:
flutter test
.PHONY: test

# Build runner
build-runner:
flutter pub run build_runner build --delete-conflicting-outputs
build-runner-watch:
flutter pub run build_runner watch --delete-conflicting-outputs

# Clean project
clean:
flutter clean
flutter pub get
make build-runner

# Export Archives .ipa, .aab and .apk
build-ios:
@echo "Build iOS"
make clean
flutter build ipa --obfuscate --split-debug-info=./build-output/debug/ --tree-shake-icons --export-options-plist=ios/ios-export-options.plist --suppress-analytics
cp build/ios/ipa/app.ipa build-output/app.ipa
build-ios-analyze:
@echo "Build iOS analyze"
flutter build ipa --analyze-size --suppress-analytics
build-android:
@echo "Build Store App Bundle"
make clean
flutter build appbundle --obfuscate --split-debug-info=./build-output/debug/
cp build/app/outputs/bundle/release/app-release.aab build-output/
mv build-output/app-release.aab build-output/app.aab
build-android-analyze:
@echo "Build Android analyze"
flutter build appbundle --analyze-size --suppress-analytics
build-android-apk:
@echo "Build self-distribution .apk"
make clean
flutter build apk --obfuscate --split-debug-info=./build-output/debug/
cp build/app/outputs/apk/release/app-release.apk build-output/
mv build-output/app-release.apk build-output/app.apk

# Release Archive to AppStore/PlayStore
release-ios:
@echo "Release iOS"
cd ios; bundle exec fastlane deploy
release-android:
@echo "Release Android"
cd android; bundle exec fastlane deploy
release:
@make build-ios && @make release-ios && @make build-android-appbundle && @make release-android

# Additional helpers
packages-outdated:
flutter pub outdated
packages-upgrade:
flutter pub upgrade
l10n:
flutter gen-l10n
appicon:
flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons.yaml
deeplink:
@printf "Android:\nadb shell am start -a android.intent.action.VIEW -c andrmoid.intent.category.BROWSABLE -d de.coodoo.counter://settings"
@printf "\n\n"
@printf "iOS:\nxcrun simctl openurl booted de.coodoo.counter://settings"



33 changes: 11 additions & 22 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
# 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

analyzer:
exclude:
- "**/*.g.dart"
- "**/*.freezed.dart"
errors:
invalid_annotation_target: ignore
missing_return: error

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
prefer_single_quotes: true
require_trailing_commas: true
always_use_package_imports: true

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.coodoo.counter_workshop">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="counter_workshop"
android:name="${applicationName}"
Expand Down
Empty file added assets/fonts/.gitkeep
Empty file.
Empty file added assets/icons/.gitkeep
Empty file.
Empty file added assets/images/.gitkeep
Empty file.
Empty file added assets/launcher_icon/.gitkeep
Empty file.
Empty file added build-output/.gitkeep
Empty file.
113 changes: 2 additions & 111 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,115 +1,6 @@
import 'package:counter_workshop/src/app.dart';
import 'package:flutter/material.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});

// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.

// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".

final String title;

@override
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;

void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}

@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
runApp(const App());
}
17 changes: 17 additions & 0 deletions lib/src/app.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:counter_workshop/src/features/counter/counter.page.dart';
import 'package:flutter/material.dart';

class App extends StatelessWidget {
const App({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Counter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const CounterPage(),
);
}
}
Empty file.
Empty file added lib/src/core/routing/.gitkeep
Empty file.
Empty file added lib/src/core/utils/.gitkeep
Empty file.
Empty file added lib/src/core/wigets/.gitkeep
Empty file.
Loading