123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- 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<DemoController>(builder: (controller) {
- return Text(obtainTextStr(controller.status) ?? "-");
- }),
- //第一个按钮
- TextButton(
- style: ButtonStyle(
- minimumSize: MaterialStateProperty.all<Size>(const Size(200, 45)), // 设置最小宽度和高度
- backgroundColor: MaterialStateProperty.all<Color>(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 "";
- }
- }
|