Code Monkey home page Code Monkey logo

jtech_recipe's People

Contributors

wuxubaiyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

xiaohaola

jtech_recipe's Issues

Review feedback

  1. Use final rather than var when possible.
  2. Make fields private when possible.
  3. Prefer single quote. Ref: https://dart-lang.github.io/linter/lints/prefer_single_quotes.html
  4. Be consistent for type defining. E.g.:
  // 手机号校验状态
  final phoneVerifyNotifier = ValueChangeNotifier<bool>(false);

  // 授权请求状态
  final authStateNotifier = ValueChangeNotifier(false); // Add <bool> or remove previous <bool>


  as well as here: `smsCountdownNotifier = ValueChangeNotifier<int>(0)`
  1. Dart doc should start with triple slash ///. Code comment should start with double slash //.
    Ref: https://dart.dev/guides/language/effective-dart/documentation#do-use--doc-comments-to-document-members-and-types
  2. Cheaper approach: counterText = ''
      decoration: InputDecoration(
        counter: const SizedBox(),
  1. Prefer moving non-UI logic to business logic layer and avoid nested ValueListenableBuilders. Consider define a new notifier to tell UI what should be rendered instead of letting UI calculate it from different data streams. Consider add enum to describe status instead of hard code checking the number value 0, -1, and >0.
        suffixIcon: ValueListenableBuilder<bool>(
          valueListenable: logic.phoneVerifyNotifier,
          builder: (_, verifyPhone, __) {
            return ValueListenableBuilder<int>(
              valueListenable: logic.smsCountdownNotifier,
              builder: (_, countdown, __) {
                var text = countdown > 0 ? "验证码已发送($countdown)" : "获取验证码";
                return TextButton(
                  onPressed: verifyPhone && countdown == 0
                      ? () => logic.sendSMS(context)
                      : null,
                  child: LoadingView(
                    loading: countdown == -1,
                    child: Text(text),
                  ),
                );
              },
            );
          },

If do want to listen from multiple data sources. Consider Listenable.merge or implement ValueListenableBuilder2<V1, V2> by self.
8. (_, verifyPhone, __) => (_, phoneVerified, __)
9. Naming for time period variables should end with the unit. E.g var countDown => countdownSeconds or countdownMs. Also, countdown is one word.
10. Allowing ValueChangeNotifier to conditionally notify listeners when updating value might not be a good idea. It lets the ValueNotifier to hold stale state that subscriber not aware of. If a state is not ready for notifying, the caller should hold it rather than ValueNotifier
11. WTF is this.

  void update(bool notify) {
    if (notify) notifyListeners();
  }
  1. Check state surviving before navigating. Otherwise it might cause unexpectedly re-pushing the home page.
      await authApi.auth(phoneNumber: phoneNumber, code: code);
      // 登录成功跳转首页
      routerManage.pushReplacementNamed(RoutePath.home);
  1. Call super.dispose() after all controllers are disposed. Not before.
  2. ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.