Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ dev_dependencies:
sdk: flutter
intl_utils: ^2.8.2

dependency_overrides:
intl: 0.20.2

flutter:
uses-material-design: true

Expand Down
11 changes: 11 additions & 0 deletions lib/src/add_ons/add_ons_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:deriv_chart/src/add_ons/add_on_config.dart';
import 'package:deriv_chart/src/add_ons/repository.dart';
import 'package:deriv_chart/src/misc/chart_diagnostics.dart';
import 'package:shared_preferences/shared_preferences.dart';

/// Called to create an AddOnConfig object from a map.
Expand Down Expand Up @@ -73,6 +74,7 @@ class AddOnsRepository<T extends AddOnConfig> extends ChangeNotifier

if (!prefs.containsKey(addOnsKey)) {
// No saved indicators or drawing tools.
chartDiag('repo#$hashCode loadFromPrefs($addOnsKey): no saved items');
notifyListeners();
return;
}
Expand All @@ -90,6 +92,9 @@ class AddOnsRepository<T extends AddOnConfig> extends ChangeNotifier
_hiddenStatus.add(false);
}

chartDiag('repo#$hashCode loadFromPrefs($addOnsKey): loaded '
'${items.map((T c) => c.configId).toList()}');

notifyListeners();
}

Expand All @@ -98,6 +103,8 @@ class AddOnsRepository<T extends AddOnConfig> extends ChangeNotifier
void add(T addOnConfig) {
items.add(addOnConfig);
_hiddenStatus.add(false);
chartDiag('repo#$hashCode add(${addOnConfig.configId}) -> $addOnsKey, '
'items: ${items.map((T c) => c.configId).toList()}');
_writeToPrefs();
notifyListeners();
}
Expand Down Expand Up @@ -128,6 +135,9 @@ class AddOnsRepository<T extends AddOnConfig> extends ChangeNotifier
}
final removedItem = items.removeAt(index);
_hiddenStatus.removeAt(index);
chartDiag('repo#$hashCode removeAt($index) '
'removed ${removedItem.configId} -> $addOnsKey, '
'items: ${items.map((T c) => c.configId).toList()}');
_writeToPrefs();
// Notify about the deletion
onDeleteCallback?.call(removedItem, index);
Expand All @@ -148,6 +158,7 @@ class AddOnsRepository<T extends AddOnConfig> extends ChangeNotifier
void clear() {
items.clear();
_hiddenStatus.clear();
chartDiag('repo#$hashCode clear() -> $addOnsKey');
_writeToPrefs();
notifyListeners();
}
Expand Down
30 changes: 19 additions & 11 deletions lib/src/deriv_chart/chart/main_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,11 @@ class _ChartImplementationState extends BasicChartState<MainChart> {

@override
Widget build(BuildContext context) => LayoutBuilder(
// Force remount when markerSeries changes.
// LayoutBuilder only re-invokes its builder on constraint changes;
// without a key that tracks markerSeries identity, the old
// MarkerArea subtree persists after trade-type switches.
key: ObjectKey(widget.markerSeries),
builder: (BuildContext context, BoxConstraints constraints) {
final XAxisModel xAxis = context.watch<XAxisModel>();

Expand Down Expand Up @@ -579,17 +584,20 @@ class _ChartImplementationState extends BasicChartState<MainChart> {
),
);

Widget _buildMarkerArea() => MultipleAnimatedBuilder(
animations: <Listenable>[
currentTickAnimation,
topBoundQuoteAnimationController,
bottomBoundQuoteAnimationController
],
builder: (BuildContext context, _) => MarkerArea(
markerSeries: widget.markerSeries!,
quoteToCanvasY: chartQuoteToCanvasY,
animationInfo: AnimationInfo(
currentTickPercent: currentTickAnimation.value,
Widget _buildMarkerArea() => KeyedSubtree(
key: ObjectKey(widget.markerSeries),
child: MultipleAnimatedBuilder(
animations: <Listenable>[
currentTickAnimation,
topBoundQuoteAnimationController,
bottomBoundQuoteAnimationController
],
builder: (BuildContext context, _) => MarkerArea(
markerSeries: widget.markerSeries!,
quoteToCanvasY: chartQuoteToCanvasY,
animationInfo: AnimationInfo(
currentTickPercent: currentTickAnimation.value,
),
),
),
);
Expand Down
Loading
Loading