BertrandBev / code_field

A customizable code text field supporting syntax highlighting
https://bertrandbev.github.io/code_field/
MIT License
230 stars 61 forks source link

"theme" not usable in CodeController #77

Closed CodingSmiles closed 1 year ago

CodingSmiles commented 1 year ago

I am not able to use the CodeController's option to add a theme. Here is my issue image My error message: The named parameter 'theme' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'theme'.

CodingSmiles commented 11 months ago

I can't see this comment on Github, so I'm replying with an email. Unfortunately, I don't know any solutions to the error. There must be something but I'm definitely not the right person to ask this to. I left that project months ago now 😅

On Tue, Oct 3, 2023 at 11:30 AM SunMin,Kim @.***> wrote:

@CodingSmiles https://github.com/CodingSmiles Is there a solution to this error?

— Reply to this email directly, view it on GitHub https://github.com/BertrandBev/code_field/issues/77#issuecomment-1744262270, or unsubscribe https://github.com/notifications/unsubscribe-auth/AW2BCF6HGED7T72RMXMVZ3LX5OSZLAVCNFSM6AAAAAAYB5E6EOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBUGI3DEMRXGA . You are receiving this because you were mentioned.Message ID: @.***>

CodingSmiles commented 11 months ago

Replying to myself here, I did a little bit of work and made it work

[image: image.png]

Sorry if I'm doing it wrong or nobody asked about this.

On Tue, Oct 3, 2023 at 2:30 PM Aadiraj Anil @.***> wrote:

I can't see this comment on Github, so I'm replying with an email. Unfortunately, I don't know any solutions to the error. There must be something but I'm definitely not the right person to ask this to. I left that project months ago now 😅

On Tue, Oct 3, 2023 at 11:30 AM SunMin,Kim @.***> wrote:

@CodingSmiles https://github.com/CodingSmiles Is there a solution to this error?

— Reply to this email directly, view it on GitHub https://github.com/BertrandBev/code_field/issues/77#issuecomment-1744262270, or unsubscribe https://github.com/notifications/unsubscribe-auth/AW2BCF6HGED7T72RMXMVZ3LX5OSZLAVCNFSM6AAAAAAYB5E6EOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBUGI3DEMRXGA . You are receiving this because you were mentioned.Message ID: @.***>

dhust commented 11 months ago

Replying to myself here, I did a little bit of work and made it work [image: image.png] Sorry if I'm doing it wrong or nobody asked about this.

Your image isn't showing. How did you get themes to work?

dhust commented 11 months ago

So instead of returning a CodeField:

return CodeField(
    controller: _codeController!,
    textStyle: TextStyle(fontFamily: 'SourceCode'),

  );

We need to return a CodeTheme with the CodeFieldas a child:

return CodeTheme(
    data: const CodeThemeData(styles: monokaiSublimeTheme),
    child: CodeField(
      controller: _codeController!,
      textStyle: const TextStyle(fontFamily: 'SourceCode'),
    ),
  );