第一次提交
This commit is contained in:
40
lib/routes/root_pages/home.dart
Normal file
40
lib/routes/root_pages/home.dart
Normal file
@@ -0,0 +1,40 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:styled_widget/styled_widget.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../providers/api.dart';
|
||||
import '../../api/capatcha.dart';
|
||||
|
||||
class HomePage extends HookConsumerWidget {
|
||||
const HomePage({super.key});
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final cookies = ref.watch(cookieHeaderProvider);
|
||||
|
||||
final future = useMemoized(() async {
|
||||
final client = ref.read(apiClientProvider);
|
||||
final res = await client.get('');
|
||||
return res.bodyBytes;
|
||||
}, []);
|
||||
final snapshot = useFuture(future);
|
||||
|
||||
return ListView(
|
||||
padding: EdgeInsets.all(16),
|
||||
children:[
|
||||
// if (snapshot.hasData) Text('${utf8.decode(snapshot.data!)}'),
|
||||
const Text('HTTP API Client 状态:'),
|
||||
const Gap(16),
|
||||
Text('Cookies: ${cookies}'),
|
||||
if (snapshot.hasData) ...[
|
||||
const Gap(16),
|
||||
Text('${utf8.decode(snapshot.data!)}')
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user