saminsohag / flutter_packages

11 stars 3 forks source link

Feature request #12

Open Somtobro opened 4 months ago

Somtobro commented 4 months ago

Very good package and I personally think it's going to rise in demand exponentially soon.

Some things to work work on 1)Currently it doesn't cater for scrollable texts if the content leaves the screen

2)Another thing that would make the package very useful...it's more of a personal need but I think a lot people do need it....is if the package can also parse the chatgpt content and return as a List

3) a bool to enable if the package should display text as a typing animation would be wonderful too.its more engaging

4)For the titles and headers ... exposing the textstyles for these optionally would be good.the reason I say so is because the package is quite not exactly like gpt yet..the paragraphing and some little things

5)when rendering math (... )\ is different from [...]\ The square means a display I think. I noticed in the code you replaced both with the same $ sign...I think the display should take $$

Overall wonderful package and excited for the future

saminsohag commented 4 months ago

Hi there thanks for highlighting those issue. But I couldn't understand the no.1 Point properly. If you can provide some detailed explanation with some screen shorts then it would be good.

But for no 2. point the chat gpt contents are structured as tree form. So I am not sure how it should be done.

For no 3. Point I can do that. But the purpose of the package is to render the gpt content according to the app theme. And also that can be achieve easily by just adding some dots (some text...). Some think like that. It can be achieve outside the widget so I think It is not a major think.

For no 4. The package uses the app text theming. So you can change the styling of the headline text by just wrapping with a Theme widget.

For no 5. The package supports both \(..\) for inline and \[..\] for display type latex equations. And also it supports $..$ for inline and $$..$$ for block type equations. The reason is chatGPT using \(..\) and \[..\] syntax and gemini is using $..$ and $$..$$ syntax.

Somtobro commented 3 months ago

Thanks for your detailed response my friend. For 1: If the text to be renderered Especially latex,it leaves the screens and the widget doesn't become scrollable. I hope this is clearer.

Also the style for online latex is inconsistent with the rest, it makes the renderered text look ugly

saminsohag commented 3 months ago

There is a latexBuilder method in the TexMarkdown widget you can use that to make the latex scrollable I am providing an example of doing that:

use flutter_math_fork package and the use the latexBuilder method to achieve that.

  TexMarkdown(
    "some gpt markdown text",
    latexBuilder: (contex, tex, textStyle, inline) {
      var controller = ScrollController();
      Widget child = Math.tex(
        tex,
        textStyle: textStyle,
      );
      if (!inline) {
        child = Padding(
          padding: const EdgeInsets.all(0.0),
          child: Scrollbar(
            controller: controller,
            child: SingleChildScrollView(
              controller: controller,
              scrollDirection: Axis.horizontal,
              child: child,
            ),
          ),
        );
      }
      return child;
    },
  );

You can change the font of Math.tex to make the latex look good.

I hope it will be helpful for you.