본문 바로가기
ETC/develop

Flutter Application Develop just For me:D#1

by asdf12345 2023. 5. 11.

1. Add Image

pubspec.yaml

  assets:
      - images/test.png

main.dart

...
body: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        Center(child: Image.asset('images/test.png',width:width*0.8),),
        Padding(padding: EdgeInsets.all(width * 0.024),
        ),
...

 

2. HTTPS Request

Install HTTP Package

pubspeck.yaml

...
dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  http: #Add this line
 ...

screen.dart

...
  void _callAPI() async {
    var url = Uri.parse(
      'https://b3cl4ssy.tistory.com',
    );
    var response = await http.get(url);
    print('Response status: ${response.statusCode}');
    print('Response body: ${response.body}');

    
  }
...
child: ButtonTheme(
              minWidth: width * 0.8, 
              height: height * 0.05, 
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(16)
              ),
              child: ElevatedButton(onPressed:_callAPI,
                child: Text(
                  'Send HTTPS', 
                  style: TextStyle(fontSize: width * 0.06,  color: Colors.white), 
                ), 
                style: ElevatedButton.styleFrom(
                  shape: StadiumBorder(),
                  //minimumSize: const Size.fromHeight(60),
                  primary: Colors.black, // Background color
                  padding:
                      const EdgeInsets.symmetric(vertical: 15, horizontal: 95),
                ),
              )
            )
...

 

3. Signing

1) Create key.jks in android/app folder

keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

2) Create key.properties in android/app folder

storePassword=***Password***
keyPassword=***Password***
keyAlias=key
storeFile=./key.jks

3. Add code below in andrid/app/build.gradle

def keystoreProperties = new Properties()
   def keystorePropertiesFile = rootProject.file('app/key.properties')
   if (keystorePropertiesFile.exists()) {
       keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
   }
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
...


android {
...
    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    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.release
        }
    }
...

4. Build 

 flutter build appbundle  --no-tree-shake-icons
flutter build apk --split-per-abi --no-tree-shake-icons

 

'ETC > develop' 카테고리의 다른 글

node.js & Express Develop#3  (0) 2021.03.16
node.js & Express Develop#2  (0) 2021.03.14
node.js & Express Develop#1  (0) 2021.03.12
node.js & Express Develop#0  (0) 2021.03.11