* UpperCamelCase

class, enum, typedef, type parametes (annotaion class with parameter) 등

 

* lowerCamelCase

class members, top-level definitions, variables, parameters, and named parameters, constant variable, enum values

- constant variable 하고 enum values 가 좀 특이하네

- enum SCREAMING_CAPS 스타일은 내가 만든 거 아닐때만 쓰라고 하는 듯 (기존 코드 또는 protobuf로 생성한 코드)

 

const pi = 3.14;
const defaultTimeout = 1000;
final urlScheme = RegExp('^([a-z]+):');

enum BeeGees {
  barryGibb,
  mauriceGibb,
  robinGibb
}

class Dice {
  static final numberGenerator = Random();
}

 

* lowercase_with_underscores

filename, import prefixes

- 파일명하고 디렉토리는 언더스코어로~~

 

* import 관련

알파벳 및 섹션별 정렬

위에부터 dart: > package: > relative imports (relative 사용도 추천하진 않는 듯)

대충 dart > 남들 package > 내 package 순으로 정리하면 될 듯

 

 

* 참고

dart.dev/guides/language/effective-dart/style

 

Effective Dart: Style

Formatting and naming rules for consistent, readable code.

dart.dev

 

'dart' 카테고리의 다른 글

flutter vscode 설정  (0) 2021.05.05
flutter 폴더 구조 정리  (0) 2021.05.05
dart,flutter convention 및 linter  (0) 2021.05.05
flutter 유튜브 참고  (0) 2021.05.05
flutter 유튜브 채널 요약 좀 해보자  (0) 2021.05.05

 

코딩 컨벤션(가이드라인)에 따라 코드를 작성하다 보면 자연스레 이쁜 코드를 작성하는 습관이 들어서,

개인적으로 코딩 컨벤션은 최대한 맞추려고 하는 편이다.

기본적으로 언어별, 프레임워크별, 라이브러리별 컨벤션이 약간씩 차이나는 경우가 있는데,

'가장 작은 scope 기준으로 스타일을 맞춘다는' 기본 컨셉만 지키면 크게 무리가 없다

예) 특정 파일에 함수와 파일이 컨벤션이 다른 경우, 더 작은 scope인 함수에 맞춘다

scope: 블럭 < 함수 < 파일 < 모듈(디렉토리) < ...

 

* 코딩 컨벤션

dart 하고 flutter가 가끔 차이나는 경우가 있는 거 같네. 대략적인것만 훑어보고 linter 대로 따라가자

github.com/flutter/flutter/issues/20858

 

Should global constants be prefixed with `k` ? · Issue #20858 · flutter/flutter

The Flutter style guide recommends prefixing global constants with 'k', https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#begin-global-constant-names-with-prefix-k , But ...

github.com

 

* 그러면 linter는 뭘로 할까나~

flutter linter는 구글이 주도하는 pedantic하고, 커뮤니티쪽에서 주도하는 effective_dart를 많이 사용하는 듯 하다

고민해봤자 답 없으니 star 수 더 많은 pedantic 사용하자

 

github.com/google/pedantic

 

google/pedantic

How to get the most value from Dart static analysis - google/pedantic

github.com

github.com/tenhobi/effective_dart

 

tenhobi/effective_dart

Linter rules corresponding to the guidelines in Effective Dart - tenhobi/effective_dart

github.com


* 사용 방법 요약

1. pubspec.yaml

dev_dependencies:
  pedantic: ^1.11.0

2. analysis_options.yaml 파일 프로젝트 최상단에 생성하고 아래 내용 작성

include: package:pedantic/analysis_options.yaml

3. 따로 세부설정은 하지 않음

 


 

* 코딩 컨벤션 참고

dart.dev/guides/language/effective-dart/style

 

Effective Dart: Style

Formatting and naming rules for consistent, readable code.

dart.dev

github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo

 

flutter/flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond. - flutter/flutter

github.com

 

* Flutter

www.youtube.com/channel/UCwXdFgeE9KYzlDdR7TG9cMw

 

Flutter

Welcome to the official Flutter YouTube channel. Subscribe to stay up to date with best practices about the Flutter SDK. See real code examples, and watch engineers from around the world putting Flutter to work! Subscribe to stay connected → https://goo.

www.youtube.com

 

* The Coding Papa 더코딩파파

www.youtube.com/channel/UCUH2DSbsNUz2sW3kBNn4ibw

 

The Coding Papa 더코딩파파

한국의 IT산업의 미래를 위해!!

www.youtube.com

 

* 코드팩토리

www.youtube.com/channel/UCxZ2AlaT0hOmxzZVbF_j_Sw

 

코드팩토리

코드팩토리는 왕초보도 배울 수 있는 코딩 교육을 목표로 하는 채널입니다.

www.youtube.com

 

* 개발하는남자

www.youtube.com/channel/UCbMGBIayK26L4VaFrs5jyBw

 

개발하는남자

개발을 즐기는 사람이 되고 싶은 개발자.

www.youtube.com

* The Flutter Way

www.youtube.com/channel/UCJm7i4g4z7ZGcJA_HKHLCVw

 

The Flutter Way

If you want to improve your flutter skill then join our channel because we try to upload two videos each month.

www.youtube.com

* doctor code

www.youtube.com/channel/UCCkjYARLbR1ws4_lMuvJ2vg

 

doctor code

I am a Medical student and I love programming and web design, in my channel, I publish my work and how I made it i hope you will like it and tell me what you think about it don't forget to like the videos and share it to your friend and don't forget to sub

www.youtube.com

 

 

일단 카테고리는 다 만들어놨는데, 몇 개나 하다가 퍼질런지 ㅎㅎ

어차피 한 번 훑어볼 거 시간되면 짬짬이 정리도 하면서 보자~~

근데 영상이 워낙 짧아서 뭐 정리할 게 있으려나...

 

www.youtube.com/channel/UCwXdFgeE9KYzlDdR7TG9cMw

 

코드블럭 dark 테마 dart 언어 3종 비교 (언어: java)

 

Atom one dark

 

Monokai

 

Darcula

 

 

 

존경하는 티스토리님께
dart도 코드 문법 강조 플러그인에서 추가해주세요
혹시 시간되시면 material 하고 vscode 테마도 추가해주세요

 

티스토리 기본 '코드 문법 강조(syntax highlight)' 플러그인에서 dart 지원을 안 하네

색깔 넣느라고 이거저거 설정하기 구찮으니 있는 거 중에 제일 맘에 드는걸로 고르자

 

언어는 java가 가장 매끄럽게 나오는 것 같고, 테마는 dark 중에 하나 고르면 될 듯

(테마는 변경하면 기존 글도 다 적용되니 아무거나 골라도 됨)

 

* dark theme

Atom one dark

Monokai

Darcula: intellij 계열에서 기본 제공하는 테마라 익숙

 

* light theme

Atom one light

Github

Visual Studio

Xcode


 

// html

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
// css

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
// javascript

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
// python

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
// java

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
// C++

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
// Kotlin

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
// Swift

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
// PHP

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
// Go

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
// C#

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
// SQL

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
// Scala

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}

 

// R

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}

 

 

+ Recent posts