import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:ftrecruiter/comm/constants/color_constants.dart'; import 'package:ftrecruiter/comm/utils/dark_theme_util.dart'; import 'package:ftrecruiter/comm/utils/log_utils.dart'; import 'package:ftrecruiter/comm/widget/common_widget.dart'; import 'package:ftrecruiter/comm/widget/my_button.dart'; import 'package:ftrecruiter/modules/zdemo/demo_controller.dart'; import 'package:get/get.dart'; class DemoPage extends StatelessWidget { DemoPage({Key? key}) : super(key: key); final controller = Get.put(DemoController(apiRepository: Get.find())); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: DarkThemeUtil.multiColors(ColorConstants.white), appBar: CommonWidget.appBar(context, "Demo"), body: Container( width: double.infinity, height: double.infinity, child: ListView( shrinkWrap: true, padding: const EdgeInsets.symmetric(horizontal: 30.0), children: [ CommonWidget.rowHeight(height: 15), GetBuilder(builder: (controller) { return Text(obtainTextStr(controller.status) ?? "-"); }), //第一个按钮 TextButton( style: ButtonStyle( minimumSize: MaterialStateProperty.all(const Size(200, 45)), // 设置最小宽度和高度 backgroundColor: MaterialStateProperty.all(Colors.redAccent), ), onPressed: () { controller.increase(); // controller.getServerTime2(); // controller.getIndustry2(); // controller.complicatedFetch(); controller.getUserInfo(); }, child: Obx(() { return Text( "当前数量:${controller.count}", style: const TextStyle(fontSize: 16, color: Colors.white), ); })), CommonWidget.rowHeight(height: 15), MyButton( fontSize: 16, textColor: Colors.black, text: "My Button的封装按钮", backgroundColor: ColorConstants.gray, onPressed: () { controller.getLocalFile('test_avatar.jpeg').then((File file) { // 在此处处理文件对象 var list = file.readAsBytesSync(); SmartDialog.compatible.showToast("file:${file.parent}"); Log.e("file:${file.path} list:$list"); }); }, radius: 15, enableOverlay: false, //禁用水波纹 side: BorderSide(color: Colors.black, width: 1.0), ), CommonWidget.rowHeight(height: 15), MyButton( text: "顺序调用接口,先登录后获取", backgroundColor: DarkThemeUtil.multiColors(ColorConstants.dividerColor, darkColor: Colors.deepOrange), radius: 20, elevation: 5.0, onPressed: () { controller.getUserInfo(); }, ), ], )), ); } String? obtainTextStr(RxStatus status) { if (status.isLoading) { return "Loading..."; } else if (status.isSuccess) { return "Success"; } else if (status.isEmpty) { return "Empty"; } else if (status.isError) { return status.errorMessage; } return ""; } }