forked from toly1994328/FlutterUnit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
215306b
commit e4b6123
Showing
60 changed files
with
531 additions
and
508 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class Toast { | ||
static toast(BuildContext context, String msg, | ||
{duration = const Duration(milliseconds: 600), | ||
Color? color, | ||
SnackBarAction? action}) { | ||
|
||
ScaffoldMessenger.of(context).showSnackBar(SnackBar( | ||
content: Text(msg), | ||
duration: duration, | ||
action: action, | ||
backgroundColor: color??Theme.of(context).primaryColor, | ||
)); | ||
} | ||
|
||
static void error(BuildContext context,String msg){ | ||
toast(context,msg, color:Colors.red, ); | ||
} | ||
|
||
static void warning(BuildContext context,String msg){ | ||
toast(context,msg, color:Colors.orange, ); | ||
} | ||
|
||
static void success(BuildContext context,String msg){ | ||
toast(context,msg, color:Theme.of(context).primaryColor, ); | ||
} | ||
|
||
static void green(BuildContext context,String msg){ | ||
toast(context,msg, color:Colors.green, ); | ||
} | ||
} | ||
// import 'package:flutter/material.dart'; | ||
// | ||
// class Toast { | ||
// static toast(BuildContext context, String msg, | ||
// {duration = const Duration(milliseconds: 600), | ||
// Color? color, | ||
// SnackBarAction? action}) { | ||
// | ||
// ScaffoldMessenger.of(context).showSnackBar(SnackBar( | ||
// content: Text(msg), | ||
// duration: duration, | ||
// action: action, | ||
// backgroundColor: color??Theme.of(context).primaryColor, | ||
// )); | ||
// } | ||
// | ||
// static void error(BuildContext context,String msg){ | ||
// toast(context,msg, color:Colors.red, ); | ||
// } | ||
// | ||
// static void warning(BuildContext context,String msg){ | ||
// toast(context,msg, color:Colors.orange, ); | ||
// } | ||
// | ||
// static void success(BuildContext context,String msg){ | ||
// toast(context,msg, color:Theme.of(context).primaryColor, ); | ||
// } | ||
// | ||
// static void green(BuildContext context,String msg){ | ||
// toast(context,msg, color:Colors.green, ); | ||
// } | ||
// } |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,32 @@ | ||
import 'package:app_config/app_config.dart'; | ||
import 'package:utils/utils.dart'; | ||
|
||
import 'package:flutter_unit/app/utils/http_utils/http_util.dart'; | ||
import 'package:flutter_unit/app/utils/http_utils/result_bean.dart'; | ||
|
||
/// create by 张风捷特烈 on 2021/2/24 | ||
/// contact me by email [email protected] | ||
/// 说明: | ||
class CategoryApi { | ||
static Future<ResultBean<bool>> uploadCategoryData( | ||
static Future<TaskResult<bool>> uploadCategoryData( | ||
{required String data, required String likeData}) async { | ||
String errorMsg = ""; | ||
|
||
var result = await HttpUtil.getInstance().client.post( | ||
var result = await HttpUtil.instance.client.post( | ||
PathUnit.categoryDataSync, | ||
data: {"data": data, "likeData": likeData}).catchError((err) { | ||
errorMsg = err.toString(); | ||
}); | ||
|
||
if (result.data != null) { | ||
return ResultBean.fromData<bool>(result.data); | ||
return TaskResult.success(data:result.data); | ||
} | ||
|
||
return ResultBean.error('请求错误: $errorMsg'); | ||
return TaskResult.error(msg: '请求错误: $errorMsg'); | ||
} | ||
|
||
static Future<ResultBean<CategoryData>> getCategoryData() async { | ||
static Future<TaskResult<CategoryData>> getCategoryData() async { | ||
String errorMsg = ""; | ||
var result = await HttpUtil.getInstance() | ||
var result = await HttpUtil.instance | ||
.client | ||
.get(PathUnit.categoryData) | ||
.catchError((err) { | ||
|
@@ -39,13 +38,13 @@ class CategoryApi { | |
if (result.data != null && result.data['status']) { | ||
// 说明有数据 | ||
if (result.data['data'] != null) { | ||
return ResultBean.ok<CategoryData>(CategoryData.fromJson(result.data['data'])); | ||
return TaskResult.success(data:CategoryData.fromJson(result.data['data'])); | ||
} else { | ||
return ResultBean.ok<CategoryData>(null); | ||
return const TaskResult.success(data:null); | ||
} | ||
} | ||
|
||
return ResultBean.error('请求错误: $errorMsg'); | ||
return TaskResult.error(msg: '请求错误: $errorMsg'); | ||
} | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.