Programming/Flutter

[Flutter]Flutter 들이박기

stein 2022. 1. 15. 23:52

https://docs.flutter.dev/get-started/install/macos

 

macOS install

How to install on macOS.

docs.flutter.dev

Update your path

You can update your PATH variable for the current session at the command line, as shown in Get the Flutter SDK. You’ll probably want to update this variable permanently, so you can run flutter commands in any terminal session.

 


정렬 방식이 특이하다.


Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

https://dart.dev/go/unsound-null-safety

 

Unsound null safety

Mixing language versions lets you migrate to null safety at your own pace, with some of the benefits of null safety.

dart.dev

dart package는 language version이 다르더라도 사용할 수 있게 한다. 이를 mixed-version programs라 부르고 unsound null safety로 구동된다.

 

https://dart.dev/go/unsound-null-safety

 

Unsound null safety

Mixing language versions lets you migrate to null safety at your own pace, with some of the benefits of null safety.

dart.dev

무시하고 구동하려면 다음과 같은 명령어를 쓴다.(둘 중 하나)

 

Disable sound null safety using the --no-sound-null-safety flag to the or flutter command:

$ dart --no-sound-null-safety run
$ flutter run --no-sound-null-safety

🤔 'Flutter에서는 정렬, 여백, 레이아웃 등 거의 모든것이 위젯입니다.' → 즉, 웹에서 html tag와 위젯이 비슷한 곳에 배치되는 것 처럼 느껴진다. 다만 StatefulWidget/StatelessWidget를 상속하여서 state에 대해 좀 더 중요하게 생각한다. 


You might wonder why StatefulWidget and State are separate objects. In Flutter, these two types of objects have different life cycles. Widgets are temporary objects, used to construct a presentation of the application in its current state. State objects, on the other hand, are persistent between calls to build(), allowing them to remember information.

 


 

 

[Flutter]primarySwatch 색상 선택 시 주의사항

이런 식으로 Colors.white를 사용하면 에러가 난다. 에러를 읽어보면 Color는 MaterialColor 타입의 하위타입이 아니라서 그렇다는데, white의 내부 구성을 보면 자료형이 Color로 되어있다는 것을 알 수 있

artiper.tistory.com

이제 그냥 primaryColor를 바꿀 수 없게 되었다(업데이트 이후에) 

https://stackoverflow.com/questions/69295173/primarycolor-property-in-themedata-does-not-work-in-flutter

 

"primaryColor" property in "ThemeData" does not work in Flutter

I'm currently investigating how to use ThemeData in the Flutter application. It should work with the code below, but the color theme doesn't apply as expected. Curiously, using the "primarySwa...

stackoverflow.com

하지만 위의 방식대로 하면 scheme의 required 변수들을 엄청나게 필요로 하는데

나는 primary color만 바꾸고 싶은데..

MaterialApp(
	theme: ThemeData(
		colorScheme: ColorScheme.fromSwatch(
  			primarySwatch: Colors.grey,
		),
    )
)

위와 같은 방식으로 바꾸면 된다.

primaryColor는 아마 쓰기 힘들것 같고, primarySwatch를 사용하도록 강요하는 느낌이다.

 

[Flutter]primarySwatch 색상 선택 시 주의사항

이런 식으로 Colors.white를 사용하면 에러가 난다. 에러를 읽어보면 Color는 MaterialColor 타입의 하위타입이 아니라서 그렇다는데, white의 내부 구성을 보면 자료형이 Color로 되어있다는 것을 알 수 있

artiper.tistory.com