Giter VIP home page Giter VIP logo

Comments (4)

ReinBentdal avatar ReinBentdal commented on May 18, 2024 1

A way to achieve what you want is by doing this:

final styledText = (String data) => Text(data)
  .fontSize(16)
  .fontWeight(FontWeight.w600)
  .textColor(Colors.black);

styledText('NAME')
styledText('AGE')

from styled_widget.

moraispgsi avatar moraispgsi commented on May 18, 2024

Hi @linxydmhg the second example is similar to a previous pull-request that I have made that was rejected by @ReinBentdal #17. All of this can be accomplished with your own code by adding an extension method like I did in the pull request, without the need to change the library.

from styled_widget.

moraispgsi avatar moraispgsi commented on May 18, 2024

@linxydmhg Here is a snippet to get you started

typedef Text TextWrapper(Text text);
typedef Text TextWrapperWithContext(Text text, BuildContext context);

extension StyledText on Text {
  wrap(TextWrapper textWrapper) {
    if(textWrapper == null) {
      return this;
    }
    return textWrapper(this);
  }

  wrapWithContext(TextWrapperWithContext textWrapperWithContext, BuildContext context) {
    if(textWrapperWithContext == null) {
      return this;
    }
    return textWrapperWithContext(this, context);
  }
}

from styled_widget.

linxydmhg avatar linxydmhg commented on May 18, 2024

@ReinBentdal That works out perfectly.

from styled_widget.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.