Skip to content

Commit 06eb214

Browse files
conf: Add support for multiple build flavors.
conf: Add support for multiple build flavors.
2 parents 09461be + 340b2d8 commit 06eb214

8 files changed

Lines changed: 110 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ jobs:
7676

7777
# Build
7878
- name: Build APK
79-
run: flutter build apk --dart-define=SENTRY_DSN=${SENTRY_DSN}
79+
run: flutter build apk --flavor production --target lib/main_production.dart --dart-define=SENTRY_DSN=${SENTRY_DSN}

.gitignore

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
.history
1010
.svn/
1111

12-
# IntelliJ related
12+
# IDE related
1313
*.iml
1414
*.ipr
1515
*.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/
16+
.idea/*
17+
!.idea/runConfigurations/
18+
.vscode/*
19+
!.vscode/launch.json
2220

2321
# Flutter/Dart/Pub related
2422
**/doc/api/

.idea/runConfigurations/development.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/production.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vscode/launch.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Launch development",
6+
"request": "launch",
7+
"type": "dart",
8+
"program": "lib/main_development.dart",
9+
"args": [
10+
"--verbose",
11+
"--flavor",
12+
"development",
13+
"--target",
14+
"lib/main_development.dart"
15+
]
16+
},
17+
{
18+
"name": "Launch production",
19+
"request": "launch",
20+
"type": "dart",
21+
"program": "lib/main_production.dart",
22+
"args": [
23+
"--verbose",
24+
"--flavor",
25+
"production",
26+
"--target",
27+
"lib/main_production.dart"
28+
]
29+
}
30+
]
31+
}

android/app/build.gradle

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@ android {
5757
signingConfig signingConfigs.debug
5858
}
5959
}
60+
61+
// TODO: Remove when below fix is available in stable channel.
62+
// https://github.com/flutter/flutter/pull/82309
63+
lintOptions {
64+
checkReleaseBuilds false
65+
}
66+
67+
flavorDimensions "default"
68+
productFlavors {
69+
production {
70+
dimension "default"
71+
applicationIdSuffix ""
72+
manifestPlaceholders = [appName: "Codephile"]
73+
}
74+
development {
75+
dimension "default"
76+
applicationIdSuffix ""
77+
manifestPlaceholders = [appName: "[DEV] Codephile"]
78+
}
79+
}
6080
}
6181

6282
flutter {

lib/main_development.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import 'dart:async';
2+
3+
import 'package:flutter/foundation.dart';
4+
import 'package:flutter/material.dart';
5+
import 'package:hive_flutter/hive_flutter.dart';
6+
import 'package:hydrated_bloc/hydrated_bloc.dart';
7+
import 'package:path_provider/path_provider.dart';
8+
9+
import 'data/constants/strings.dart';
10+
import 'presentation/core/main_app.dart';
11+
12+
Future<void> main() async {
13+
// Necessary if you intend to initialize in an async function.
14+
WidgetsFlutterBinding.ensureInitialized();
15+
16+
await _initHive();
17+
final hydratedStorage = await _initHydratedBloc();
18+
19+
// Zone for Hydrated Bloc.
20+
HydratedBlocOverrides.runZoned(
21+
() async => runApp(await Codephile.run()),
22+
storage: hydratedStorage,
23+
);
24+
}
25+
26+
Future<void> _initHive() async {
27+
await Hive.initFlutter();
28+
await Hive.openBox(AppStrings.hiveBoxName);
29+
}
30+
31+
Future<Storage> _initHydratedBloc() async {
32+
return HydratedStorage.build(
33+
storageDirectory: kIsWeb
34+
? HydratedStorage.webStorageDirectory
35+
: await getApplicationSupportDirectory(),
36+
);
37+
}
File renamed without changes.

0 commit comments

Comments
 (0)