mirror of
				https://github.com/AppFlowy-IO/AppFlowy.git
				synced 2025-10-31 10:03:18 +00:00 
			
		
		
		
	 a0ed043cb8
			
		
	
	
		a0ed043cb8
		
			
		
	
	
	
	
		
			
			* feat: my account settings page * test: amend tests * chore: remove unused code * test: remove widget tests * fix: text color on select buttons * test: clean and remove unused test helpers * feat: settings workspace page * chore: fixes after merge * fix: recent views bugfix * fix: make sure text buttons have color * test: add test for delete workspace in settings * test: remove pumpAndSettle for create workspace * test: longer pump duration * test: attempt with large pump duration * test: attempt workaround * chore: clean code * fix: missing language key * test: add one more check * test: pump * test: more pump * test: attempt pumpAndSettle * chore: code review * fix: persist single workspace on patch * fix: listen to workspace changes * chore: remove redundant builder * test: remove unstable test * fix: changes after merge * chore: changes after merge * feat: support changing cursor and selection color * chore: move members up in menu * feat: clean code and beautify dialogs * fix: fix test and make show selected font --------- Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
		
			
				
	
	
		
			27 lines
		
	
	
		
			568 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			568 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'dart:math';
 | |
| 
 | |
| int levenshtein(String s, String t, {bool caseSensitive = true}) {
 | |
|   if (!caseSensitive) {
 | |
|     s = s.toLowerCase();
 | |
|     t = t.toLowerCase();
 | |
|   }
 | |
| 
 | |
|   if (s == t) return 0;
 | |
| 
 | |
|   final v0 = List<int>.generate(t.length + 1, (i) => i);
 | |
|   final v1 = List<int>.filled(t.length + 1, 0);
 | |
| 
 | |
|   for (var i = 0; i < s.length; i++) {
 | |
|     v1[0] = i + 1;
 | |
| 
 | |
|     for (var j = 0; j < t.length; j++) {
 | |
|       final cost = (s[i] == t[j]) ? 0 : 1;
 | |
|       v1[j + 1] = min(v1[j] + 1, min(v0[j + 1] + 1, v0[j] + cost));
 | |
|     }
 | |
| 
 | |
|     v0.setAll(0, v1);
 | |
|   }
 | |
| 
 | |
|   return v1[t.length];
 | |
| }
 |