加群452892873 下載對應34課文件,運行方法,建好項目,直接替換lib目錄
CheckOut.dart
import 'package:flutter/material.dart'; import 'package:flutter_jdshop/services/ScreenAdapter.dart'; class CheckOutPage extends StatefulWidget { CheckOutPage({Key key}) : super(key: key); _CheckOutPageState createState() => _CheckOutPageState(); } class _CheckOutPageState extends State<CheckOutPage> { Widget _checkOutItem() { return Row( children: <Widget>[ Container( width: ScreenAdapter.width(160), child: Image.network( "https://www.itying.com/images/flutter/list2.jpg", fit: BoxFit.cover), ), Expanded( flex: 1, child: Container( padding: EdgeInsets.fromLTRB(10, 10, 10, 5), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text("華為旗艦店Mate9手機", maxLines: 2), Text("白色,175", maxLines: 1), Stack( children: <Widget>[ Align( alignment: Alignment.centerLeft, child: Text("¥1111", style: TextStyle(color: Colors.red)), ), Align( alignment: Alignment.centerRight, child: Text('x2'), ) ], ) ], ), ), ) ], ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('結算'), ), body: Stack( children: <Widget>[ ListView( children: <Widget>[ Container( color: Colors.white, child: Column( children: <Widget>[ ListTile( leading: Icon(Icons.add_location), title: Center(child: Text("請添加收貨地址")), trailing: Icon(Icons.navigate_next), ), SizedBox(height: 10), ListTile( leading: Icon(Icons.add_location), title: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text('張三 13325187796'), SizedBox(height: 10), Text('北京海淀區') ], ), trailing: Icon(Icons.navigate_next), ), SizedBox(height: 10), ], ), ), SizedBox(height: 20), Container( color: Colors.white, padding: EdgeInsets.all(ScreenAdapter.width(20)), child: Column( children: <Widget>[ _checkOutItem(), Divider(), _checkOutItem(), Divider(), _checkOutItem() ], ), ), Container( color: Colors.white, padding: EdgeInsets.all(ScreenAdapter.width(20)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text('商品總金額¥100'), Divider(), Text('立減:¥5'), Divider(), Text('運費:¥8') ], ), ) ], ), Positioned( bottom: 0, width: ScreenAdapter.width(750), height: ScreenAdapter.height(100), child: Container( width: ScreenAdapter.width(750), height: ScreenAdapter.height(100), decoration: BoxDecoration( color: Colors.white, border: Border( top: BorderSide(width: 1, color: Colors.black26))), child: Stack( children: <Widget>[ Align( alignment: Alignment.centerLeft, child: Text("總價:140", style: TextStyle(color: Colors.red)), ), Align( alignment: Alignment.centerRight, child: RaisedButton( child: Text("立即下單", style: TextStyle(color: Colors.white)), color: Colors.red, onPressed: () {}, ), ) ], ), ), ) ], )); } }