Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate from Tuple to Dart 3 Records #80

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
8 changes: 0 additions & 8 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.5.1"
tuple:
dependency: transitive
description:
name: tuple
sha256: "0ea99cd2f9352b2586583ab2ce6489d1f95a5f6de6fb9492faaf97ae2060f0aa"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
typed_data:
dependency: transitive
description:
Expand Down
19 changes: 9 additions & 10 deletions lib/src/ast/syntax_tree.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
import 'package:tuple/tuple.dart';

import '../render/layout/line.dart';
import '../render/layout/line_editable.dart';
Expand Down Expand Up @@ -580,8 +579,8 @@ class EquationRowNode extends ParentableNode<GreenNode>
},
// Selector translates global cursor position to local caret index
// Will only update Line when selection range actually changes
child: Selector2<TextSelection, Tuple2<LayerLink, LayerLink>,
Tuple3<TextSelection, LayerLink?, LayerLink?>>(
child: Selector2<TextSelection, (LayerLink, LayerLink),
(TextSelection, LayerLink?, LayerLink?)>(
selector: (context, selection, handleLayerLinks) {
final start = selection.start - this.pos;
final end = selection.end - this.pos;
Expand All @@ -598,10 +597,10 @@ class EquationRowNode extends ParentableNode<GreenNode>
: const TextSelection.collapsed(offset: -1);

final startHandleLayerLink =
caretPositions.contains(start) ? handleLayerLinks.item1 : null;
caretPositions.contains(start) ? handleLayerLinks.$1 : null;
final endHandleLayerLink =
caretPositions.contains(end) ? handleLayerLinks.item2 : null;
return Tuple3(
caretPositions.contains(end) ? handleLayerLinks.$2 : null;
return (
caretSelection,
startHandleLayerLink,
endHandleLayerLink,
Expand All @@ -617,9 +616,9 @@ class EquationRowNode extends ParentableNode<GreenNode>
preferredLineHeight: options.fontSize,
cursorBlinkOpacityController:
Provider.of<Wrapper<AnimationController>>(context).value,
selection: conf.item1,
startHandleLayerLink: conf.item2,
endHandleLayerLink: conf.item3,
selection: conf.$1,
startHandleLayerLink: conf.$2,
endHandleLayerLink: conf.$3,
cursorColor: value.cursorColor,
cursorOffset: value.cursorOffset,
cursorRadius: value.cursorRadius,
Expand Down Expand Up @@ -863,7 +862,7 @@ void _traverseNonSpaceNodes(
void Function(_NodeSpacingConf? prev, _NodeSpacingConf? curr) callback,
) {
_NodeSpacingConf? prev;
// Tuple2<AtomType, AtomType> curr;
// (AtomType, AtomType) curr;
for (final child in childTypeList) {
if (child.leftType == AtomType.spacing ||
child.rightType == AtomType.spacing) {
Expand Down
13 changes: 6 additions & 7 deletions lib/src/render/layout/multiscripts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:math' as math;

import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:tuple/tuple.dart';

import '../../ast/options.dart';
import '../../ast/size.dart';
Expand Down Expand Up @@ -209,10 +208,10 @@ class MultiscriptsLayoutDelegate extends IntrinsicLayoutDelegate<_ScriptPos> {
isBaseCharacterBox: isBaseCharacterBox,
);

final subShift = postscriptRes.item2;
final supShift = postscriptRes.item1;
final presubShift = prescriptRes.item2;
final presupShift = prescriptRes.item1;
final subShift = postscriptRes.$2;
final supShift = postscriptRes.$1;
final presubShift = prescriptRes.$2;
final presupShift = prescriptRes.$1;

// Rule 18f
final height = [
Expand Down Expand Up @@ -258,7 +257,7 @@ class _ScriptUvConf {
const _ScriptUvConf(this.fullHeight, this.baseline, this.options);
}

Tuple2<double, double> calculateUV({
(double, double) calculateUV({
required _ScriptUvConf base,
_ScriptUvConf? sub,
_ScriptUvConf? sup,
Expand Down Expand Up @@ -324,5 +323,5 @@ Tuple2<double, double> calculateUV({
}
}
}
return Tuple2(u, v);
return (u, v);
}
3 changes: 1 addition & 2 deletions lib/src/widgets/selectable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:provider/provider.dart';
import 'package:tuple/tuple.dart';

import '../ast/options.dart';
import '../ast/style.dart';
Expand Down Expand Up @@ -515,7 +514,7 @@ class InternalSelectableMathState extends State<InternalSelectableMath>
),
),
Provider.value(
value: Tuple2(startHandleLayerLink, endHandleLayerLink),
value: (startHandleLayerLink, endHandleLayerLink),
),
// We can't just provide an AnimationController, otherwise
// Provider will throw
Expand Down
3 changes: 1 addition & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: flutter_math_fork
description: Fast and high-quality TeX math equation rendering with pure Dart & Flutter.
description: Fast and high-quality TeX math equation rendering with pure Dart & Flutter.
version: 0.7.1
homepage: https://github.com/simpleclub-extended/flutter_math_fork

Expand All @@ -15,7 +15,6 @@ dependencies:
provider: ^6.0.5
meta: ^1.8.0
collection: ^1.17.0
tuple: ^2.0.1

dev_dependencies:
flutter_test:
Expand Down