You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter容器内多文本布局技术问询:如何在STORE OF VALUE区块下方添加'BTC'文本

Solution: Add 'BTC' Text Under 'STORE OF VALUE' in Flutter GridView

Got it! Let's tweak your StockPage to add the 'BTC' text right below the 'STORE OF VALUE' heading while keeping all your existing layout and styling intact. Here's the adjusted code with clear modifications:

import 'package:flutter/material.dart';

class StockPage extends StatelessWidget {
  const StockPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: GridView.count(
        crossAxisCount: 2,
        padding: const EdgeInsets.all(16),
        crossAxisSpacing: 16,
        mainAxisSpacing: 16,
        childAspectRatio: 1.5,
        children: [
          // Modified STORE OF VALUE container
          Container(
            decoration: BoxDecoration(
              color: Colors.green,
              borderRadius: BorderRadius.circular(8),
            ),
            child: const Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(
                  'STORE OF VALUE',
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 16,
                    fontWeight: FontWeight.bold,
                  ),
                  textAlign: TextAlign.center,
                ),
                SizedBox(height: 8), // Small spacing between heading and BTC
                Text(
                  'BTC',
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 14,
                  ),
                ),
              ],
            ),
          ),
          // Existing SMART CONTRACTS container (unchanged)
          Container(
            decoration: BoxDecoration(
              color: Colors.green,
              borderRadius: BorderRadius.circular(8),
            ),
            child: const Center(
              child: Text(
                'SMART CONTRACTS',
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 16,
                  fontWeight: FontWeight.bold,
                ),
                textAlign: TextAlign.center,
              ),
            ),
          ),
          // Add your other remaining category containers here...
        ],
      ),
    );
  }
}

Quick Breakdown of the Changes:

  • Swapped the single Center widget inside the 'STORE OF VALUE' container for a Column—this lets us stack the heading and 'BTC' text vertically.
  • Kept mainAxisAlignment: MainAxisAlignment.center to maintain the original centered alignment of content in the container.
  • Added a SizedBox(height: 8) to create a clean gap between the heading and 'BTC' text (you can adjust this value for more/less spacing).
  • Left all other GridView properties (like crossAxisCount, spacing, childAspectRatio) and container styles exactly as they were—so your overall layout stays consistent.

Feel free to tweak the TextStyle for the 'BTC' text (font size, weight, color) to match your design needs!

内容的提问来源于stack exchange,提问作者Remy Danon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 22:02:50