【问题标题】:Aligning text using RichText in flutter在 Flutter 中使用 RichText 对齐文本
【发布时间】:2021-08-21 19:46:42
【问题描述】:

Text UI

我想使用 RichText 小部件在颤振中创建类似这样的 UI。你能帮我写代码吗?我不明白如何设计这样的用户界面?

【问题讨论】:

  • 重新创建此 UI 有什么问题?你能提供更多信息吗?

标签: flutter richtext


【解决方案1】:

使用WidgetSpan 提供偏移量以获得上标。执行以下操作:

Container(
            padding: EdgeInsets.all(10),
            child: Center(
              child: RichText(
                text: TextSpan(children: [
                  WidgetSpan(
                      child: Transform.translate(
                          offset: const Offset(0.0, -7.0), child:                               
                    Text("Rs"))),
                  TextSpan(
                      text: '1,500',
                      style: TextStyle(color: Colors.black,                             
                        fontSize: 18,fontWeight:FontWeight.bold),
                      recognizer: TapGestureRecognizer()
                        ..onTap = () {
                          // navigate to desired screen
                        })
                ]),
              ),
            ))

【讨论】:

    猜你喜欢
    • 2021-11-01
    • 1970-01-01
    • 2021-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    • 1970-01-01
    • 2019-11-17
    相关资源
    最近更新 更多