簡體   English   中英

Flutter文本小部件將中間的單詞分解到下一行如何停止

[英]Flutter text widget breaks up words in the middle to the next line how to stop

找到了解決方案,它是使用三引號。

Text("""Loooong text ... 放在這里。""")

這就是我的項目中所做的,以防止單詞在行中間被打斷。 在此處輸入圖像描述

沒有它。 其中一些詞在新行中被分成兩半。 在此處輸入圖像描述

["

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {

    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: Center(
          child: Container(
            padding:EdgeInsets.only(left: 30, right:30),
            child:RichText(
              text: TextSpan(children: [
            TextSpan(
                text: "這是一趟十分令人",
                style: TextStyle(color: Colors.green, fontSize: 30.0)),
            TextSpan(
              text: "愉\u200d悅",
              style: TextStyle(
                  color: Colors.red,
                  fontWeight: FontWeight.bold,
                  fontSize: 30.0),
            ),
            TextSpan(
                text: "的旅程",
                style: TextStyle(color: Colors.green, fontSize: 30.0)),
          ])),
          )
        ),
      ),
    );
  }
}
["

用這個:<\/p>

Text(text.replaceAll("\u200b", "")),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM