登录验证使用通用函数

hmxc
小赖 4 years ago
parent 487a57ad9e
commit 40c2faa368

@ -1,4 +1,5 @@
// Flutter imports: // Flutter imports:
import 'package:akuCommunity/utils/login_util.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -33,7 +34,12 @@ class _AllApplicationPageState extends State<AllApplicationPage> {
return MaterialButton( return MaterialButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.w)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.w)),
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
onPressed: editMode ? null : () => Get.to(object.page), onPressed: editMode
? null
: () {
if (LoginUtil.isNotLogin) return;
Get.to(object.page);
},
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [

@ -1,4 +1,5 @@
// Flutter imports: // Flutter imports:
import 'package:akuCommunity/utils/login_util.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
@ -40,7 +41,10 @@ class _BeeSearchState extends State<BeeSearch> {
Widget _buildColumnIcon(AO e) { Widget _buildColumnIcon(AO e) {
return MaterialButton( return MaterialButton(
onPressed: () => Get.to(e.page), onPressed: () {
if (LoginUtil.isNotLogin) return;
Get.to(e.page);
},
shape: StadiumBorder(), shape: StadiumBorder(),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,

@ -1,4 +1,5 @@
// Flutter imports: // Flutter imports:
import 'package:akuCommunity/utils/login_util.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
@ -32,17 +33,12 @@ class ApplicationView extends StatefulWidget {
class _ApplicationViewState extends State<ApplicationView> { class _ApplicationViewState extends State<ApplicationView> {
_buildTile(AO object) { _buildTile(AO object) {
final userProvider = Provider.of<UserProvider>(context);
return MaterialButton( return MaterialButton(
shape: StadiumBorder(), shape: StadiumBorder(),
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
onPressed: () { onPressed: () {
if (userProvider.isLogin) if (LoginUtil.isNotLogin) return;
Get.to(object.page); Get.to(object.page);
else {
BotToast.showText(text: '请先登陆');
Get.to(SignInPage());
}
}, },
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,

Loading…
Cancel
Save