jtech_recipe's People
Forkers
xiaohaolajtech_recipe's Issues
Review feedback
- Use final rather than var when possible.
- Make fields private when possible.
- Prefer single quote. Ref: https://dart-lang.github.io/linter/lints/prefer_single_quotes.html
- 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)`
- 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 - Cheaper approach:
counterText = ''
decoration: InputDecoration(
counter: const SizedBox(),
- Prefer moving non-UI logic to business logic layer and avoid nested
ValueListenableBuilder
s. 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();
}
- 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);
- Call
super.dispose()
after all controllers are disposed. Not before. - ...
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.