没有解释 因为我也不是很懂 


List<String> searchRecordTexts = [
  'aaaaa',
  'bbbbb',
  'ccccc',
  'ddddd',
  'eeeee',
  'fffff',
  'gggggg',
  'qqqqqq',
  'wwwwww',
];

class SingleChildScroll extends StatelessWidget {
  @override
  Widget build (BuildContext context) {
    return Container(
      color: Theme.of(context).accentColor,
      child: Row(
        children: <Widget>[
          SizedBox(
            width: 10,
          ),
          Text(
            '热搜:',
            style: TextStyle(color: Colors.white, fontSize: 13, decoration: TextDecoration.none),
          ),
          Expanded(
            child: SingleChildScrollView(
              scrollDirection: Axis.horizontal,
              padding: EdgeInsets.symmetric(horizontal: 20),
              child: Row(
                children: searchRecordTexts.map((String item) {
                  return GestureDetector(
                    onTap: () {
                      Navigator.of(context).pushNamed('/home');
                    },
                    child: Container(
                      margin: EdgeInsets.all(5),
                      height: 40,
                      child: new Material(
                        borderRadius: BorderRadius.circular(10.0),
//              shadowColor: Colo rs.blue.shade200,
//              elevation: 5.0,
                        color: Color(0xFFfe8524),
                        child: Padding(
                          padding: const EdgeInsets.only(left: 18, right: 18),
                          child: Center(
                            child: Text(
                              item,
                              style: TextStyle(color: Colors.white, fontSize: 13),
                            ),
                          ),
                        ),
                      ),
                    ),
                  );
//            return Text(item);
//            return _KingKongItemWidget(
//              item: item,
//            );
                }).toList(),
              ),
            ),
          )
        ],
      ),
    );
  }
}

 

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐