728x90

Platform 관련 함수는 웹에서 사용이 불가능한 모양

 

 

사용하지 않거나,

그럼에도 불구하고 사용하고싶으면 try-catch 감싸라는 이야기 존재

 

 

//You can use a try-catch block to prevent the exception from breaking the flow:

bool kisweb;
try{
    if(Platform.isAndroid||Platform.isIOS) {
        kisweb=false;
    } else {
        kisweb=true;
    }
} catch(e){
    kisweb=true;
}



 

Reference

https://stackoverflow.com/questions/58459483/unsupported-operation-platform-operatingsystem

 

Unsupported operation: Platform._operatingSystem

My flutter code isn't running on web. I found that "bool kisweb" can be used to detect the platform. But my code is failing at "FirebaseAuth.instance". Does this mean I can't use Firebaseauth on ...

stackoverflow.com

 

728x90

'Dev > Flutter' 카테고리의 다른 글

[Flutter/Dart] .. (Double dot/이중점) 연산자 - cascade  (0) 2021.01.15
[Flutter] 플러터로 Web하기  (0) 2020.09.07
728x90

 

Flutter의 Dart에서 함수 호출시 ".." 을 사용하는 경우가 있다.

이는 동일한 객체에 대해 여러 메소드를 호출하려할 때 간략하게 쓰는 것임.

즉, 동일한 타겟을 반복하지 않아도 되도록 하는 것

ex)
list.add(color1);
list.add(color2);
list.add(color3);
list.add(color4);

// with cascade

List list = [];
list
  ..add(color1)
  ..add(color2)
  ..add(color3)
  ..add(color4);
//It's the cascade operator of Dart

var l1 = new List<int>()..add(0)..addAll([1, 2, 3]);

//results in l1 being a list [0, 1, 2, 3]

var l1 = new List<int>().add(0).addAll([1, 2, 3]);

 

 

results in an error, because .add(0) returns void

.. (in the former example) refers to new List(), while . (in the later) refers to the return value of the previous part of the expression.

.. was introduced to avoid the need to return this in all kinds of methods like add() to be able to use an API in a fluent way.

.. provides this out of the box for all classes.

 

 

Reference

stackoverflow.com/questions/49447736/list-use-of-double-dot-in-dart

 

List use of double dot (.) in dart?

Sometimes I see this List list = []; Then list..add(color) Whats the difference in using 1 dot(.) and 2 dot(..)?

stackoverflow.com

 

728x90

'Dev > Flutter' 카테고리의 다른 글

[Flutter/web] Platform 함수 에러 관련  (0) 2021.01.15
[Flutter] 플러터로 Web하기  (0) 2020.09.07
728x90

 

Flutter

1) 각 플랫폼 별로 build시 개별적인 툴 사용

- Android: Android Studio, IntelliJ

- iOS: Xcode

- Web: IntelliJ, VSCode

 

2) web의 경우

- 2020년 기준, flutter web은 beta channel로 사용해야함.

- intelliJ가 더 익숙하여 해당 IDE를 사용하여 개발 환경을 구축해 봄.

(1)  Plugin -> Flutter SDK 설치 (Dart도 함께 설치됨)

     Flutter SDK 폴더 안에 dart sdk 폴더가 있으므로 필요시에는 path를 해당 부분으로 연결하면 됨

(2) 앞서 받은 Flutter SDK 폴더를  환경변수에 추가하고, 다음의 명령어 설정

flutter channel beta
flutter upgrade

flutter config --enable-web //web개발기능 활성화

(3) web 개발 기능을 활성화하면 chrome 브라우저 검출이 가능해짐(=안드로이드 앱실행과 같이 Chrome 디버깅 가능)

(4) IntelliJ IDE에서 Flutter New Project 진행 (기존에 생기던 Android, iOS와 더불어 web 폴더가 생김)

(5) 최종적으로 프로젝트 빌드시에는 flutter build web 혹은 flutter run --release 사용

(6) build 후, 프로젝트 내부 build폴더에 web 폴더가 생성됨.

    프로젝트경로/build/web 폴더 내에 있는 파일들을 서버에 올리면 됨.

 

 

 

 

Reference

flutter.dev/docs/get-started/web

zerogyun.dev/2020/02/07/Flutter%EC%97%90%EC%84%9C%20web%EC%9D%84%20%EC%B6%94%EA%B5%AC%ED%95%98%EB%A9%B4%20%EC%95%88%EB%90%98%EB%8A%94%EA%B1%B8%EA%B9%8C/

www.youtube.com/watch?v=htuHNO9JeRU&feature=youtu.be

www.youtube.com/watch?v=E6fLm5XlJDY

www.youtube.com/watch?v=rpkKYQCioW0

 

 

 

 

728x90

+ Recent posts