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

Alignment in line breaking mode #29

Closed
Skyost opened this issue Jan 18, 2021 · 6 comments
Closed

Alignment in line breaking mode #29

Skyost opened this issue Jan 18, 2021 · 6 comments

Comments

@Skyost
Copy link
Contributor

Skyost commented Jan 18, 2021

Hey,

I've followed the instructions here to implement the line breaking feature in my app. It really suits my needs, but there's a little caveat using a Wrap widget in order to display Tex break parts : some parts are not aligned. Here are some examples :

Screenshot_1
Screenshot_2
Screenshot_3

Is there a way to align the Math widgets in a Wrap ?

Thanks !

@MuratovArthur
Copy link

@Skyost

Hey!

I am a beginner in flutter, so I couldn't use the author's documentation to implement the line-breaking feature correctly. I have an error: Error: The method 'texBreak' isn't defined for the class 'Math'.

Could you help me? Could you share your code?

@Skyost
Copy link
Contributor Author

Skyost commented Feb 17, 2021

@MuratovArthur You have to install the dev version from git (see here).

@MuratovArthur
Copy link

@Skyost

Hey!

Thank you for helping me!

I've tried to install the dev version from git, but it required to update some other packages. I've updated sdk to sdk: ">=2.6.0 <3.0.0", flutter_svg to flutter_svg: ^0.20.0-nullsafety.3.

After that, I've tried to run my app, but there was an error Error: Too few positional arguments: 8 required, 7 given. child: selectionControls!.buildToolbar(.

Did you face such an error?)

@Skyost
Copy link
Contributor Author

Skyost commented Feb 18, 2021

@MuratovArthur Nope because I'm not using selectionControls.buildToolbar, but the error is only telling you that you're missing an argument at that line.

@Skyost
Copy link
Contributor Author

Skyost commented Mar 15, 2021

I finally have some results using the following code :

@override
Widget build(BuildContext context) {
  Math math = Math.tex(input);

  List<Math> parts = math.texBreak().parts;
  if (parts.length == 1) {
    return parts.first;
  }

  return RichText(
    text: TextSpan(
      children: _handleParts(parts),
    ),
  );
}

List<InlineSpan> _handleParts(List<Math> parts) {
  List<InlineSpan> result = [];
  for (Math part in parts) {
    result.add(WidgetSpan(
      baseline: TextBaseline.alphabetic,
      alignment: PlaceholderAlignment.baseline,
      child: part,
    ));
    result.add(const TextSpan(
      text: ' ',
    ));
  }
  return result;
}

I don't think it's the best way to achieve this, but at least it works.

@yavuztarhan
Copy link

yavuztarhan commented Mar 16, 2021

@MuratovArthur You have to install the dev version from git (see here).

i tried add the package flutter_math_fork: ^0.3.0 like yours, it needs tuple 2.0.0(which depends quiver 2.0.0) but your pupspec.yaml not contains tuple, also google sign in depends quiver 3.0.0 , i am stuck

thanks,
i solved ;

dependencies:
quiver: ^2.0.0+1
dependency_overrides:
quiver: "3.0.0"

creativecreatorormaybenot pushed a commit to simpleclub-extended/flutter_math that referenced this issue Jan 14, 2022
* Fix `SelectableMath` compatibility with `provider` 6.0

* use MathController as a source for EquationRow's ProxyProvider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants