import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
enum BuildType {
development,
production,
}
class Environment {
static Environment _instance;
static Environment get instance => _instance;
final BuildType _buildType;
static BuildType get buildType => instance._buildType;
const Environment._internal(this._buildType);
factory Environment.newInstance(BuildType buildType) {
assert(buildType != null);
if(_instance == null) {
_instance = Environment._internal(buildType);
}
return _instance;
}
bool get isDebuggle => _buildType == BuildType.development;
void run (Widget app) {
runApp(app);
}
}
import 'dart:convert';
import './environment.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class Development extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SubDevelopment()
),
);
}
}
class SubDevelopment extends StatefulWidget {
@override
_SubDevelopmentState createState() => _SubDevelopmentState();
}
class _SubDevelopmentState extends State<SubDevelopment> {
String text = '';
@override
void initState() {
getValue();
super.initState();
}
void getValue() async {
var value = await json.decode(await rootBundle.loadString('config/config_dev.json'));
setState(() {
text = value['property'] ?? '';
});
}
@override
Widget build(BuildContext context) {
return Container(
child: Center(
child: Text(
'$text',
style: TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
);
}
}
main() => Environment.newInstance(BuildType.development).run(Development());
import 'dart:convert';
import './environment.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class Production extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SubProduction()
),
);
}
}
class SubProduction extends StatefulWidget {
@override
_SubProductionState createState() => _SubProductionState();
}
class _SubProductionState extends State<SubProduction> {
String text = '';
@override
void initState() {
getValue();
super.initState();
}
void getValue() async {
var value = await json.decode(await rootBundle.loadString('config/config_proc.json'));
setState(() {
text = value['property'] ?? '';
});
}
@override
Widget build(BuildContext context) {
return Container(
child: Center(
child: Text(
'$text',
style: TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
),
);
}
}
main() => Environment.newInstance(BuildType.production).run(Production());
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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.ina.flutter_flavor"
minSdkVersion 16
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
flavorDimensions "build-type"
productFlavors {
development {
dimension "build-type"
applicationIdSuffix ".dev"
}
production {
dimension "build-type"
}
}
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 '../..'
}
[Flutter] 버전 2.0.4 build Failed 발생 (0) | 2021.09.15 |
---|---|
[CSS] 스크롤 스냅(Snap) 처리하기 (0) | 2021.08.04 |
[Flutter] VlcPlayer 플러그인 상태 값 (0) | 2021.07.14 |
[Flutter] VlcPlayer 무한 영상 재생 (0) | 2021.07.13 |
[Flutter] 탭 메뉴(Tab Menu) 만들기 (0) | 2021.06.24 |
댓글 영역