$30 off During Our Annual Pro Sale. View Details »

Writing better Flutter Code
 with Flutter Lint / Part1

Writing better Flutter Code
 with Flutter Lint / Part1

#flutter
#flutterjp
#flutterdev
#yumemi_grow

Kenichi Kambara

April 12, 2023
Tweet

More Decks by Kenichi Kambara

Other Decks in Technology

Transcript

  1. 2023.04.12


    ਆݪ ݈Ұ (@korodroid)
    Writing better Flutter Code

    with Flutter Lint / Part1
    YUMEMI.grow Mobile #2

    View Slide

  2. ࣗݾ঺հ
    •ۀ຿ɿϞόΠϧΞϓϦ։ൃ/ٕज़ࢧԉ/จԽৢ੒׆ಈ


    •ߨԋɿΠϕϯτొஃ(ւ֎14ճɺࠃ಺100ճ+)


    •ࣥචɿ7࡭


    •झຯɿϥϯχϯά/ӳձ࿩/ΞϓϦ։ൃ
    ਆݪ ݈Ұ (NTTςΫϊΫϩε/ΤόϯδΣϦετ)

    View Slide

  3. About my Flutter product (Private works)
    Sekaiphone Pro(Flutter/Kotlin/Swift) MyToDo(Flutter)

    View Slide


  4. Lintπʔϧ(੩తղੳ)Λ׆༻͢ΔϝϦοτྫ
    1. જࡏతͳόάͷݕग़


    2. ϨϏϡʔ࡞ۀͷෛՙܰݮ


    3. ΞϓϦͷύϑΥʔϚϯεվળ

    View Slide


  5. Flutter޲͚Lintπʔϧ(
    fl
    utter_lints)
    https://pub.dev/packages/
    fl
    utter_lints

    View Slide


  6. Walking through “
    fl
    utter_lints”
    ↑ඞཁʹԠͯ͡ɺ࠷৽൛ʹߋ৽

    View Slide


  7. Walking through “analysis_options.yaml”

    View Slide


  8. Walking through “
    fl
    utter.yaml”
    # Recommended lints for Flutter apps, packages, and plugins.


    include: package:lints/recommended.yaml


    linter:


    rules:


    - avoid_print


    - avoid_unnecessary_containers


    - avoid_web_libraries_in_
    fl
    utter


    - no_logic_in_create_state


    - prefer_const_constructors


    - prefer_const_constructors_in_immutables


    - prefer_const_declarations


    - prefer_const_literals_to_create_immutables


    - sized_box_for_whitespace


    - sort_child_properties_last


    - use_build_context_synchronously


    - use_full_hex_values_for_
    fl
    utter_colors


    - use_key_in_widget_constructors

    View Slide


  9. Walking through “recommended.yaml”

    View Slide

  10. # Recommended lints for Flutter apps, packages, and plugins.


    include: package:lints/recommended.yaml


    linter:


    rules:


    - avoid_print


    - avoid_unnecessary_containers


    - avoid_web_libraries_in_
    fl
    utter


    - no_logic_in_create_state


    - prefer_const_constructors


    - prefer_const_constructors_in_immutables


    - prefer_const_declarations


    - prefer_const_literals_to_create_immutables


    - sized_box_for_whitespace


    - sort_child_properties_last


    - use_build_context_synchronously


    - use_full_hex_values_for_
    fl
    utter_colors


    - use_key_in_widget_constructors

    Walking through “
    fl
    utter.yaml” again

    View Slide


  11. Walking through “Linter for Dart”
    https://dart-lang.github.io/linter/lints/
    productionίʔυʹ͓͚Δprint཈੍

    View Slide


  12. Example: “avoid_print”

    View Slide


  13. More examples
    ྫ.Πϯελϯεੜ੒ͷͨΊͷnewར༻཈੍

    View Slide


  14. More examples
    ྫ.Collection͕ಛఆཁૉΛؚΉ͔൱͔ͷ൑ఆ

    View Slide

  15. ·ͱΊ
    •FlutterΞϓϦ։ൃͰ΋ੵۃతʹLint׆༻ʂ


    •ެࣜϦϑΝϨϯεͷϓϥΫςΟε΋ࢀߟʹʂ


    •Linter for Dart͸ɺݴޠֶशͷಡΈ෺ͱͯ͠΋͓͢͢Ίʂ

    View Slide


  16. Please let me know if you have any requests

    such as technical speeches, technical writings and so on.
    Facebook:http://fb.com/kanbara.kenichi


    Twitter:@korodroid


    LinkedIn:http://www.linkedin.com/in/korodroid
    Thank you so much

    View Slide