首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >颤振与设计系统

颤振与设计系统
EN

Stack Overflow用户
提问于 2021-12-14 20:50:11
回答 1查看 70关注 0票数 1

我已经使用本机Design System开发了一个Android(Java),现在我将开始使用Flutter开发一个新的Design System,但是我对Flutter不太熟悉,我有一些问题没有通过在互联网上得到回答。

安卓上的我有

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<resources>

    //Brand Primary colors
    <color name="color_primary" category="color">#FDE6E3</color>
    <color name="color_secondary" category="color">#FE918D</color>

</resources>

如何使这个color文件在Flutter

安卓上的我有

代码语言:javascript
复制
    <resources>    
  //Font Sizes
  <dimen name="font_XXS" category="font-size">12sp</dimen>
  <dimen name="font_size_XS" category="font-size">16sp</dimen>


  
  //Spacing Inline
  <dimen name="spacing_XS" category="spacing-inline">4dp</dimen>
  <dimen name="spacing_XXS" category="spacing-inline">8dp</dimen>
  
  
  //Border Radius
  <dimen name="border_radius_none" category="radius">0dp</dimen>
  <dimen name="border_radius_XS" category="radius">4dp</dimen>
  

  //Border Width
  <dimen name="border_width_none" category="border-width">0dp</dimen>
  <dimen name="border_width_medium" category="border-width">2dp</dimen>

  
</resources>

如何使这个dimen文件在Flutter

在Android上,我把所有这些都放在一起来创建一个Link组件。

代码语言:javascript
复制
public class CustomLink extends AppCompatTextView {

private Context mContext;

public CustomLink(Context context) {
    super(context);
    this.mContext = context;
}

public CustomLink(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    this.mContext = context;

    TypedArray attrsArray = context.obtainStyledAttributes(attrs, R.styleable.CustomLink,
            0, 0);
    initializeCustomLink();
    attrsArray.recycle();
}


private void initializeCustomLink() {
    initializeLinkContainer();

}

private void initializeLinkContainer() {
    float scale = getResources().getDisplayMetrics().density;

    this.setLinkTextColor(getResources().getColor(R.color.color_primary)); //Here I use a Design feature

    this.setTextColor(getResources().getColor(R.color.color_secondary)); //Here I use a Design System feature

    this.setTextSize((getResources.getDimension.font_XXS) / (int) scale); //Here I use a Design System feature

    this.setMovementMethod(LinkMovementMethod.getInstance());


   }

}

我如何在Flutter**?** 中做这些基本的事情?

EN

回答 1

Stack Overflow用户

发布于 2021-12-14 20:55:43

在公用文件夹下,应保留常量数据。

在这里,链接:https://github.com/dicodingacademy/a199-flutter-expert-project/tree/main/lib

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70355390

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档