Skip to content

Commit

Permalink
DateTime.now().toIso8601String()在iphone 11 pro max上生成的字段会有重复现象,建议替换成u…
Browse files Browse the repository at this point in the history
…uid或者其他生成随机数的方法

具体说明可参考: https://www.jianshu.com/p/d461272c9f85
  • Loading branch information
yulun committed Apr 18, 2020
1 parent a466d4d commit 7b7ce69
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion example/lib/todo_list_page/todo_component/state.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:fish_redux/fish_redux.dart';
import 'package:uuid/uuid.dart';

class ToDoState implements Cloneable<ToDoState> {
String uniqueId;
Expand All @@ -7,7 +8,7 @@ class ToDoState implements Cloneable<ToDoState> {
bool isDone;

ToDoState({this.uniqueId, this.title, this.desc, this.isDone = false}) {
uniqueId ??= DateTime.now().toIso8601String();
uniqueId ??= Uuid().v4();
}

@override
Expand Down
1 change: 1 addition & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies:
flutter:
sdk: flutter
path_provider: ^0.4.1
uuid: 2.0.4

dev_dependencies:
test: ^1.3.0
Expand Down

0 comments on commit 7b7ce69

Please sign in to comment.