简体   繁体   English

我该怎么做才能使无论文本多长时间都将具有相同的起始对齐方式?

[英]What can I do so that no matter how long the text all will have same starting alignment?

I do a stateless widget category_card which is going to use four times.我做了一个无状态的小部件 category_card 将使用四次。

import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

class CategoryCard extends StatelessWidget {
  final String svgSrc;
  final String title;
  final VoidCallback press;
  const CategoryCard(
      {Key? key,
      required this.svgSrc,
      required this.title,
      required this.press})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ClipRRect(
      borderRadius: BorderRadius.circular(13),
      child: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Container(
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(13),
            boxShadow: [
              BoxShadow(
                color: Colors.grey.withOpacity(0.15),
                spreadRadius: 5,
                blurRadius: 7,
                offset: const Offset(0, 3), // changes position of shadow
              ),
            ],
          ),
          child: Material(
            color: Colors.transparent,
            child: InkWell(
              onTap: press,
              child: Padding(
                padding: const EdgeInsets.all(20.0),
                child: Column(
                  children: [
                    const Spacer(),
                    SvgPicture.asset(
                      svgSrc,
                      height: 100,
                      width: 100,
                    ),
                    const Spacer(),
                    Text(
                      title,
                      style: Theme.of(context).textTheme.subtitle1!.copyWith(
                          fontWeight: FontWeight.w800,
                          fontSize: 15,
                          color: Colors.blueGrey[900]),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

My output is alright, but the text part for long text such as medical condition the word is not align with the shorter word such as allergy.我的输出没问题,但是长文本的文本部分(例如医疗状况)与较短的词(例如过敏)不一致。 What can I do so that no matter how long the text all will have same starting alignment?我该怎么做才能使无论文本多长时间都将具有相同的起始对齐方式? enter image description here在此处输入图像描述

you can use Column property for making all it's item at the same point您可以使用Column属性在同一点制作所有项目

Column(
crossAxisAlignment: CrossAxisAlignment.start, // or you can change it depends your need  
children: [

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 所有设备都有IMEI号码吗? 如果是这样,另一台设备可以具有相同的设备吗? - Do all Devices have a IMEI number? If so, Can another Device Have the same one? 如何旋转Android方向,使起始方向全为0? - How do I rotate Android orientation so the starting orientation is all 0's? 如何将按钮对齐方式固定为在不同屏幕中具有相同外观 - How can I fix the button alignment to have same appearance in different screens 如何保存我输入的编辑文本并在开始新意图时访问它? - How do I save my inputted edit text and have it accessible when starting a new intent? 如何使ListView条目具有居中对齐? (Android) - How do I make the ListView entries have centered alignment? (Android) 如何从Google Assistant获取文本,以便我可以解析文本以执行某些操作? - How can I get text from Google Assistant so that I can parse the text to do certain action? 我想在DoubleClick事件中显示一些文本怎么办? 我已经附上我的源代码 - I want to display some text onDoubleClick event how to do so ? i have attached my sourcecode Along 无论我做什么,我都无法保存相机拍摄的图像。 我该怎么做? - I'm unable to save camera captured image no matter what I do. How do I do it? 无论我做什么,DividerItemDecoration 都不起作用 - DividerItemDecoration will not work no matter what I do 如何使 TextView 具有完整的圆形背景,无论它显示多长的文本 - How to make a TextView have a fully round background, no matter what length text it displays
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM