Flutter 文字邊框/邊框顏色


效果圖下

其實思路很簡單 與css圖層樣式疊加類似

我們巧妙用原生庫里面的Stack Widget實現這個效果

Stack(
  children: <Widget>[
    // Stroked text as border.
    Text(
      'Test Text~',
      style: TextStyle(
        fontSize: 40,
        foreground: Paint()
        ..style = PaintingStyle.stroke
        ..strokeWidth = 6
        ..color = Colors.blue[700],
      ),
    ),
    // Solid text as fill.
    Text(
      'Test Text~',
      style: TextStyle(
        fontSize: 40,
        color: Colors.grey[300],
      ),
    ),
  ],
)

官方文檔也是有案例的:https://api.flutter.dev/flutter/painting/TextStyle-class.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM