update dependence

This commit is contained in:
quantulr
2023-02-10 00:07:41 +08:00
parent 2aa59649a8
commit bd259d8303
9 changed files with 58 additions and 58 deletions

View File

@ -53,8 +53,9 @@ class _GalleryState extends ConsumerState<Gallery> {
@override
Widget build(BuildContext context) {
print("build");
return GridView.builder(
// controller: ,
itemCount: imageList.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: MediaQuery.of(context).size.width > 640 ? 5 : 3),

View File

@ -19,12 +19,16 @@ class _HomePageState extends ConsumerState<HomePage> {
int selectedIndex = 0;
final tabList = [
{"path": "/", "title": "相册"},
{"path": "/profile", "title": "用户"}
{"path": "/profile", "title": "用户资料"},
{"path": "/detail", "title": "图片详情"}
];
int key = 0;
@override
Widget build(BuildContext context) {
print(
widget.content.toString(),
);
print("123");
return Scaffold(
appBar: AppBar(
leading: ["/", "/profile"].contains(GoRouterState.of(context).location)
@ -36,7 +40,10 @@ class _HomePageState extends ConsumerState<HomePage> {
},
),
title: Text(
tabList[selectedIndex]["title"] ?? "",
tabList.firstWhere((element) =>
element["path"] ==
GoRouterState.of(context).fullpath)["title"] ??
"",
style: const TextStyle(fontWeight: FontWeight.bold),
),
elevation: 10,
@ -60,6 +67,8 @@ class _HomePageState extends ConsumerState<HomePage> {
mimeType.split("/").last))
});
await dio.post("/image/upload", data: data).then((value) {
// widget.content.key = GlobalKey();
// widget.content
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Row(
crossAxisAlignment: CrossAxisAlignment.center,

View File

@ -3,6 +3,7 @@ import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:momo/models/login_resp.dart';
import 'package:momo/provider/token.dart';
import 'package:momo/request/http_client.dart';
@ -90,6 +91,7 @@ class _LoginFormState extends ConsumerState<LoginForm> {
}
} catch (e) {
if (e is DioError) {
print(e.response);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(e.response?.data["msg"] ?? "请求错误")));
}

View File

@ -8,9 +8,12 @@ import 'package:momo/material/profile.dart';
class MyMaterialRouterConfig {
late GoRouter router;
final GlobalKey<NavigatorState> _rootNavigatorKey =
GlobalKey<NavigatorState>();
MyMaterialRouterConfig(String? token) {
router = GoRouter(
navigatorKey: _rootNavigatorKey,
initialLocation: "/",
routes: <RouteBase>[
ShellRoute(
@ -19,29 +22,38 @@ class MyMaterialRouterConfig {
content: child,
);
},
routes: [
routes: <RouteBase>[
GoRoute(
path: "/",
name: "相册",
pageBuilder: (BuildContext context, GoRouterState state) =>
const NoTransitionPage(child: Gallery()),
const NoTransitionPage(
child: Gallery(),
),
redirect: (BuildContext context, GoRouterState state) {
if (token == null || token.isEmpty) {
return '/login';
}
return null;
}),
},
routes: <RouteBase>[
GoRoute(
path: "detail",
name: "图片详情",
pageBuilder:
(BuildContext context, GoRouterState state) =>
const NoTransitionPage(child: ImageDetail())),
]),
GoRoute(
path: "/profile",
name: "个人资料",
pageBuilder: (BuildContext context, GoRouterState state) =>
const NoTransitionPage(child: Profile())),
GoRoute(
path: "/detail",
pageBuilder: (BuildContext context, GoRouterState state) =>
const NoTransitionPage(child: ImageDetail())),
],
),
GoRoute(
path: "/login",
name: "登录",
builder: (BuildContext context, GoRouterState state) {
return const LoginPage();
},