Flutter实现商品列表图文混排

效果如图

Flutter实现商品列表图文混排_第1张图片

代码 

import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('这是我的FlutterAPP'),
          centerTitle: true,
          backgroundColor: Colors.red,
          textTheme: TextTheme(
              title: TextStyle(
                  fontSize: 18,
                  color: Colors.yellow,
                  fontStyle: FontStyle.italic
              )
          ),

        ),

        body: HomeText(),
      ),
//      theme: ThemeData(
//          primarySwatch: Colors.blue
//      ),
    );
  }
}

class HomeText extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ConstrainedBox(
      constraints: BoxConstraints.expand(),
      child: Column(
        children: [
          Stack(
            alignment: Alignment.bottomCenter,
            children: [
              Container(
                alignment: Alignment.center,
                width: 200,
                height: 100,
                color: Colors.green,
                child: Image.network(
                  'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1591175847643&di=6e41a32b6e6355aacbfae14d03439a83&imgtype=0&src=http%3A%2F%2Fimgwx4.2345.com%2Fdypcimg%2Fdongman%2Fimg%2F2%2F25%2Fsup75205_223x310.jpg',
                  fit: BoxFit.fill,
                  width: 200,
                  height: 100,
                ),
              ),

              Container(
                width:200,
                color: Colors.black,
                child: Text(
                  '我最爱看数码宝贝',
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 16,
                  ),
                  textAlign: TextAlign.center,
                ),
              )
            ],
          ),
          SizedBox(height: 20,),

          ClipRRect(
            borderRadius: BorderRadius.circular(20),
            child: Stack(
              alignment: Alignment.bottomCenter,
              children: [
                Container(
                  alignment: Alignment.center,
                  width: 200,
                  height: 100,
                  color: Colors.green,
                  child: Image.network(
                    'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1591175847643&di=6e41a32b6e6355aacbfae14d03439a83&imgtype=0&src=http%3A%2F%2Fimgwx4.2345.com%2Fdypcimg%2Fdongman%2Fimg%2F2%2F25%2Fsup75205_223x310.jpg',
                    fit: BoxFit.fill,
                    width: 200,
                    height: 100,
                  ),
                ),

                Container(
                  width: 200,
                  color: Colors.black,
                  child: Text(
                    '我最爱看数码宝贝',
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 16,
                    ),
                    textAlign: TextAlign.center,
                  ),
                )
              ],
            ),
          ),

          SizedBox(height: 20,),

          ClipRRect(
            borderRadius: BorderRadius.only(
              topLeft: Radius.circular(20),
              topRight: Radius.circular(20),
            ),
            child: Stack(
              alignment: Alignment.bottomCenter,
              children: [
                Container(
                  alignment: Alignment.center,
                  width: 200,
                  height: 100,
                  color: Colors.green,
                  child: Image.network(
                    'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1591175847643&di=6e41a32b6e6355aacbfae14d03439a83&imgtype=0&src=http%3A%2F%2Fimgwx4.2345.com%2Fdypcimg%2Fdongman%2Fimg%2F2%2F25%2Fsup75205_223x310.jpg',
                    fit: BoxFit.fill,
                    width: 200,
                    height: 100,
                  ),
                ),

                Container(
                  width: 200,
                  color: Colors.black,
                  child: Text(
                    '我最爱看数码宝贝',
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 16,
                    ),
                    textAlign: TextAlign.center,
                  ),
                )
              ],
            ),
          ),

        ],
      ),
    );
  }
}

 

你可能感兴趣的:(flutter,flutter)