What's new in Flutter 2022

2022. 7. 6. 12:21DEV/Flutter

반응형

Dart enum : enhanced_enumerations

Before : extension 사용 필수

enum Water { frozen, boiling }

extension Members on Water {
  int waterToTemp(Water water) {
    switch (water) {
      case Water.frozen:
        return 32;
        break;

      default:
        return 212;
        break;
    }
  }

  String convertToString() => 'The $name water is ${waterToTemp(this)}F.';
}

void main() {
  print(Water.frozen.convertToString());
}
=>
The frozen water is 32F.

After : enum에서 바로 override 사용

enum Water {
  frozen(32),
  boiling(212);

  final int tempInFahrenheit;
  const Water(this.tempInFahrenheit);

  @override
  String toString() => 'The $name water is ${tempInFahrenheit}F.';
}

void main() {
  print(Water.frozen);
}
=>
The frozen water is 32F.

Named Arguments 위치

Before : Named args는 항상 마지막에 위치

void main() {
  final factorials = List<int>.generate(
    10, 
    (int i) {
      if (i == 0) {
        return 1;
      } else {
        var result = 1;
        for (var r = 2; r <= i; ++r) {
          result *= r;
        }
        return result;
      }
  }, growable: true);

  print(factorials.toString());
}
=>
[1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]

After : 순서 자유

void main() {
  final factorials = List<int>.generate(
    10, 
    growable: true, 
    (int i) {
    if (i == 0) {
      return 1;
    } else {
      var result = 1;
      for (var r = 2; r <= i; ++r) {
        result *= r;
      }
      return result;
    }
  });
}

Super constructors

Before : Manual forwarding
-> 파라미터가 얼마나 많던 적던 하나하나 직접 설정해줘야했다

class OutlinedButton extends ButtonStyleButton {
  // Constructor
  const OutlinedButton({
    Key? key,
    required VoidCallback? onPressed,
    VoidCallback? onLongPRess,
    bool autofocus = false,
    Clip clipBehavior = Clip.none,
    required Widget child,
  }) : super(
            key: key,
            onPressed: onPressed,
            onLongPRess: onLongPRess,
            autofocus: autofocus,
            clipBehavior: clipBehavior,
            child: child);
}

class OutlinedButton extends ButtonStyleButton {
  // Constructor
  const OutlinedButton({
    super.key,
    required super.onPressed,
    super.onLongPress,
    super.autofocus = false,
    super.clipBehaviro = Clip.none,
    required Widget super,child
  }) ;
}

Flutter & Firebase

FlutterFire

🔗 FlutterFire
🔗 Firebase Documentation : Flutter Overview는 최신 내용이 아닐 수 있으니 Firebase Doc를 권장한다.

The official
Firebase plugins for Flutter

Installation

flutter pub add firebase_core

Flutter Casual Games Toolkit

🔗 https://flutter.dev/games

Flutter Favorites Package (Flutter 2.5)

FlutterFire

cloud_firestor, cloud_function, firebase_auth, firebase_core, firebase_crashlytics, firebase_messaging, firebase_storage

Flutter Community Plus Package

android_alarm_manager_plus, android_intent_plus, battery_plus, connectivity_plus, device_info_plus, netwkork_info_plus, package_info_plus, senskors_plus, share_plus

Native Error 캡처

sentry, sentry_flutter

Infinite scroll, Flutter splash 지원

infinite_scroll_pagination, flutter_native_splash

References
What's new in Flutter
Introducing Flutter 3

반응형