Flutter移动应用开发 - 转账中心界面(模仿微信支付界面和支付记录)

0. 项目简介

项目想法脱胎于2023年服务外包大赛A18题 随手买(详情

整个APP思路如下:

在这里插入图片描述

这篇博客主要服务于管司机界面的司机盈利和提现记录功能。

1. 效果展示

在这里插入图片描述

2. 代码

依赖如下

dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  // 下边提示
  fluttertoast: ^4.0.1

相关文件如下

drivermoney.dart

drivermoney.dart

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

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

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

  
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '',
      home: drivermoney(),
    );
  }
}


class _RecentEarn {
  _RecentEarn({
    required this.name,
    required this.time,
    required this.money,
  });

  final String name;
  final String time;
  final String money;
}
class _RecentGet {
  _RecentGet({
    required this.name,
    required this.time,
    required this.money,
  });

  final String name;
  final String time;
  final String money;
}

List<_RecentEarn> earn = [
  _RecentEarn(
    name: "统一阿萨姆奶茶1个",
    time: "2022-12-31 12:34",
    money: "+0.32",
  ),
  _RecentEarn(
    name: "Twizzlers Twists扭扭糖1个",
    time: "2022-12-31 12:24",
    money: "+0.42",
  ),
  _RecentEarn(
    name: "我也不知道是啥牌子充电宝1个",
    time: "2022-12-31 11:54",
    money: "+6.19",
  ),
  _RecentEarn(
    name: "统一阿萨姆奶茶1个",
    time: "2022-12-31 11:43",
    money: "+0.32",
  ),
  _RecentEarn(
    name: "统一阿萨姆奶茶1个",
    time: "2022-12-31 11:24",
    money: "+0.32",
  ),
  _RecentEarn(
    name: "Gucci同名经典男士香水100ml1个",
    time: "2022-12-30 0:12",
    money: "+30.99",
  ),
];
List<_RecentGet> gett = [
  _RecentGet(
    name: "支付宝提现",
    time: "2022-12-12 13:10",
    money: "-143.94",
  ),
  _RecentGet(
    name: "支付宝提现",
    time: "2022-12-01 03:24",
    money: "-597.48",
  ),
  _RecentGet(
    name: "中国农业银行(*4888)提现",
    time: "2022-10-28 14:10",
    money: "-458.91",
  ),
  _RecentGet(
    name: "中国农业银行(*4888)提现",
    time: "2022-10-2 13:57",
    money: "-21.43",
  ),
  _RecentGet(
    name: "中国农业银行(*4888)提现",
    time: "2022-10-1 11:24",
    money: "-1755.78",
  ),
];

class drivermoney extends StatefulWidget {
  const drivermoney({Key? key}) : super(key: key);

  
  State<drivermoney> createState() => _drivermoneyState();
}


class _drivermoneyState extends State<drivermoney> {




  Widget name_line = Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
      Row(
        children: [
          CircleAvatar(
            backgroundImage: AssetImage('assets/images/none.png'),
            radius: 35,
          ),
          Text(
            "     Lavander",
            style: TextStyle(
              color: Colors.blueGrey,
              fontWeight: FontWeight.w900,
              fontSize: 17,
            ),
          ),
        ],
      ),
      Text(
        "周窿蘋    ",
        style: TextStyle(
          color: Colors.grey,
          fontSize: 15
        ),
      ),
    ],
  );

  Widget moneyCard = Card(
    shape: RoundedRectangleBorder(borderRadius: BorderRadiusDirectional.circular(10)),
    elevation: 3,
    color: Color.fromRGBO(4, 197, 161, 1.0),
    child: SizedBox(
      width: 350,
      height: 190,
      child: Padding(
        padding: EdgeInsets.fromLTRB(25, 20, 20, 10),
        child: Column(
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(
                  "可提现现金/元",
                  style: TextStyle(
                    color: Colors.white70,
                    fontSize: 16,
                    fontWeight: FontWeight.w600,
                  )
                ),
                Icon(
                  Icons.help_outline,
                  color: Colors.white70,
                )
              ],
            ),
            SizedBox(
              height: 15,
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(
                  "25,992",
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 40,
                    fontWeight: FontWeight.w900,
                  ),
                ),
                ElevatedButton(
                  onPressed: (){
                    Fluttertoast.showToast(
                      msg: "支付宝协议没通过,结算功能失效",
                      toastLength: Toast.LENGTH_SHORT,
                      gravity: ToastGravity.BOTTOM,
                    );
                  },
                  style: ButtonStyle(
                    shape: MaterialStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(30))),
                    backgroundColor: MaterialStateProperty.all(Colors.white),
                  ),
                  child: Text(
                    "  提现  ",
                    style: TextStyle(
                      color: Color.fromRGBO(26, 248, 180, 1.0),
                      fontSize: 18,
                      fontWeight: FontWeight.w700,
                    ),
                  )
                )
              ],
            ),
            SizedBox(
              height: 25,
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Center(
                  child: Column(
                    children: [
                      Text(
                        "总收益/元",
                        style: TextStyle(
                          color: Colors.white70,
                          fontSize: 16,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                      Text(
                        "3,176.00",
                        style: TextStyle(
                          color: Colors.white70,
                          fontSize: 14,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                    ],
                  ),
                ),
                SizedBox(
                  width: 2,
                  height: 40,
                  child: DecoratedBox(
                    decoration: BoxDecoration(color: Colors.white70),
                  ),
                ),
                Center(
                  child: Column(
                    children: [
                      Text(
                        "总收益/元",
                        style: TextStyle(
                          color: Colors.white70,
                          fontSize: 16,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                      Text(
                        "3,176.00",
                        style: TextStyle(
                          color: Colors.white70,
                          fontSize: 14,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                    ],
                  ),
                ),
                SizedBox(
                  width: 2,
                  height: 40,
                  child: DecoratedBox(
                    decoration: BoxDecoration(color: Colors.white70),
                  ),
                ),
                Center(
                  child: Column(
                    children: [
                      Text(
                        "总收益/元",
                        style: TextStyle(
                          color: Colors.white70,
                          fontSize: 16,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                      Text(
                        "3,176.00",
                        style: TextStyle(
                          color: Colors.white70,
                          fontSize: 14,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    ),

  );

  Widget tabbar = DefaultTabController(
    length: 2,
    child: Scaffold(
      body: NestedScrollView(
        headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled){
          return <Widget>[
            SliverOverlapAbsorber(
              handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
              sliver: SliverAppBar(
                backgroundColor: Colors.transparent,
                elevation: 0,
                pinned: true,
                forceElevated: innerBoxIsScrolled,
                bottom:
                PreferredSize(
                  child:
                    Container(
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(30),
                          topRight: Radius.circular(30),
                        ),
                        color: Colors.teal,
                      ),
                      child: const TabBar(
                        indicatorColor: Colors.teal,//选中下划线颜色,如果使用了indicator这里设置无效
                        labelColor: Colors.white30,
                        unselectedLabelColor: Colors.white12,
                        labelStyle: TextStyle(fontSize: 18, color: Colors.indigo,),
                        unselectedLabelStyle: TextStyle(fontSize: 16, color: Colors.grey),
                        indicatorWeight: 3,
                        tabs: [
                          Tab(
                            text: "总收益明细",
                          ),
                          Tab(
                            text: "提现记录",
                          ),
                        ],
                      ),
                    ),
                    // 悬浮框锁定高度
                    preferredSize: Size(double.infinity, 0.0)
                ),
              ),
            )
          ];
        },
        body:
          TabBarView(
            children: [
              SafeArea(
                top: false,
                bottom: false,
                child: Builder(
                  builder: (BuildContext context){
                    return CustomScrollView(
                      ///反弹效果
                      physics: BouncingScrollPhysics(),
                      slivers: <Widget>[
                        SliverOverlapInjector(handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context)),
                        SliverPadding(
                          padding: const EdgeInsets.symmetric(
                            vertical: 10.0,
                            horizontal: 0.0,
                          ),
                          sliver: SliverFixedExtentList(
                            itemExtent: 85,
                            delegate: SliverChildBuilderDelegate(
                              (BuildContext context, int index){
                                final _RecentEarn data = earn[index];
                                return Column(
                                  children: [
                                    Padding(
                                      padding: EdgeInsets.fromLTRB(20, 0, 10, 15),
                                      child: Row(
                                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                        children: [
                                          Column(
                                            crossAxisAlignment: CrossAxisAlignment.start,
                                            mainAxisAlignment: MainAxisAlignment.start,
                                            children:[
                                              Text(
                                                "${data.name}",
                                                style: TextStyle(
                                                  color: Colors.grey,
                                                  fontSize: 16,
                                                ),
                                              ),
                                              // Text(
                                              //   "  ",
                                              //   style: TextStyle(
                                              //     height: 5,
                                              //   ),
                                              // ),
                                              Text(
                                                "${data.time}",
                                                style: TextStyle(
                                                  color: Colors.grey,
                                                fontSize: 14,
                                              ),
                                            ),
                                          ]
                                        ),
                                          Text(

                                            "${data.money}",
                                            textAlign:TextAlign.left,
                                            style: TextStyle(
                                              color: Color.fromRGBO(3, 16, 96, 1.0),
                                              fontSize: 22,
                                            ),
                                          ),
                                        ],
                                      )
                                    ),
                                    Divider(
                                      color: Colors.grey,
                                      thickness: 1,
                                    ),
                                  ],
                                );
                              },
                              childCount: earn.length,
                            ),
                          ),
                        ),
                      ],
                    );
                  },
                ),
              ),
              SafeArea(
                top: false,
                bottom: false,
                child: Builder(
                  builder: (BuildContext context){
                    return CustomScrollView(
                      ///反弹效果
                      physics: BouncingScrollPhysics(),
                      slivers: <Widget>[
                        SliverOverlapInjector(handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context)),
                        SliverPadding(
                          padding: const EdgeInsets.symmetric(
                            vertical: 10.0,
                            horizontal: 0.0,
                          ),
                          sliver: SliverFixedExtentList(
                            itemExtent: 80,
                            delegate: SliverChildBuilderDelegate(
                                  (BuildContext context, int index){
                                final _RecentGet data = gett[index];
                                return Column(
                                  children: [
                                    Padding(
                                        padding: EdgeInsets.fromLTRB(20, 0, 10, 10),
                                        child: Row(
                                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                          children: [
                                            Column(
                                                crossAxisAlignment: CrossAxisAlignment.start,
                                                mainAxisAlignment: MainAxisAlignment.start,
                                                children:[
                                                  Text(
                                                    "${data.name}",
                                                    style: TextStyle(
                                                      color: Colors.grey,
                                                      fontSize: 16,
                                                    ),
                                                  ),
                                                  // Text(
                                                  //   "  ",
                                                  //   style: TextStyle(
                                                  //     height: 5,
                                                  //   ),
                                                  // ),
                                                  Text(
                                                    "${data.time}",
                                                    style: TextStyle(
                                                      color: Colors.grey,
                                                      fontSize: 14,
                                                    ),
                                                  ),
                                                ]
                                            ),
                                            Text(
                                              "${data.money}",
                                              style: TextStyle(
                                                color: Color.fromRGBO(3, 16, 96, 1.0),
                                                fontSize: 22,
                                              ),
                                            ),
                                          ],
                                        )
                                    ),
                                    Divider(
                                      color: Colors.grey.shade400,
                                      thickness: 1,
                                    ),
                                  ],
                                );
                              },
                              childCount: gett.length,
                            ),
                          ),
                        ),
                      ],
                    );
                  },
                ),
              )
            ],
          ),
      ),
    ),

  );

  
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(
      //   title: Text(
      //     "现金收益"
      //   ),
      // ),
      body: Center(
        child: Padding(
          padding: EdgeInsets.fromLTRB(30, 30, 30, 0),
          child: Column(
            children: [
              name_line,
              SizedBox(
                height: 10,
              ),
              moneyCard,
              Expanded(
                child:
                  tabbar,
              ),
            ],
          ),
        ),
      ),

    );
  }
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

铖铖的花嫁

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值