-
-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 6281 LateError: LateInitializationError (#6287)
* Multi-lingual input for product name * Fix LateError: LateInitializationError
- Loading branch information
Showing
22 changed files
with
1,266 additions
and
689 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'package:flutter/rendering.dart'; | ||
|
||
class DashedLinePainter extends CustomPainter { | ||
DashedLinePainter({ | ||
required Color color, | ||
this.dashGap = 3.0, | ||
this.dashSpace = 3.0, | ||
}) : _paint = Paint() | ||
..color = color | ||
..strokeWidth = 1.0; | ||
|
||
final double dashGap; | ||
final double dashSpace; | ||
|
||
final Paint _paint; | ||
|
||
@override | ||
void paint(Canvas canvas, Size size) { | ||
double startX = 0.0; | ||
|
||
while (startX < size.width) { | ||
canvas.drawLine( | ||
Offset(startX, 0), | ||
Offset(startX + dashGap, 0), | ||
_paint, | ||
); | ||
|
||
startX += dashGap + dashSpace; | ||
} | ||
} | ||
|
||
@override | ||
bool shouldRepaint(DashedLinePainter oldDelegate) => | ||
dashGap != oldDelegate.dashGap || dashSpace != oldDelegate.dashSpace; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
packages/smooth_app/lib/pages/input/debounced_text_editing_controller.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
/// Wraps a TextEditingController and debounces its changes. | ||
class DebouncedTextEditingController extends TextEditingController { | ||
DebouncedTextEditingController({ | ||
TextEditingController? controller, | ||
this.debounceTime = const Duration(milliseconds: 500), | ||
}) { | ||
replaceWith(controller ?? TextEditingController()); | ||
} | ||
|
||
final Duration debounceTime; | ||
TextEditingController? _controller; | ||
Timer? _debounce; | ||
|
||
void replaceWith(TextEditingController controller) { | ||
_controller?.removeListener(_onWrappedTextEditingControllerChanged); | ||
_controller = controller; | ||
_controller?.addListener(_onWrappedTextEditingControllerChanged); | ||
} | ||
|
||
void _onWrappedTextEditingControllerChanged() { | ||
if (_debounce?.isActive == true) { | ||
_debounce!.cancel(); | ||
} | ||
|
||
_debounce = Timer( | ||
debounceTime, | ||
() => super.notifyListeners(), | ||
); | ||
} | ||
|
||
@override | ||
set text(String newText) => _controller?.value = value; | ||
|
||
@override | ||
String get text => _controller?.text ?? ''; | ||
|
||
@override | ||
TextEditingValue get value => _controller?.value ?? TextEditingValue.empty; | ||
|
||
@override | ||
set value(TextEditingValue newValue) => _controller?.value = newValue; | ||
|
||
@override | ||
void clear() => _controller?.clear(); | ||
|
||
@override | ||
void dispose() { | ||
_debounce?.cancel(); | ||
super.dispose(); | ||
} | ||
} |
Oops, something went wrong.