Appened info screen feature keys

This commit is contained in:
niuhuan 2022-06-03 11:19:29 +08:00
parent d71d3505ab
commit 1c63c5942c
2 changed files with 11 additions and 5 deletions

View File

@ -33,6 +33,7 @@ class ComicInfoScreen extends StatefulWidget {
class _ComicInfoScreenState extends State<ComicInfoScreen> with RouteAware {
late var _tabIndex = 0;
late Future<ComicInfo> _comicFuture = _loadComic();
late Key _comicFutureKey = UniqueKey();
late Future<ViewLog?> _viewFuture = _loadViewLog();
late Future<List<Ep>> _epListFuture = _loadEps();
@ -85,6 +86,7 @@ class _ComicInfoScreenState extends State<ComicInfoScreen> with RouteAware {
Widget buildScreen(BuildContext context) {
return FutureBuilder(
key: _comicFutureKey,
future: _comicFuture,
builder: (BuildContext context, AsyncSnapshot<ComicInfo> snapshot) {
if (snapshot.hasError) {
@ -96,6 +98,7 @@ class _ComicInfoScreenState extends State<ComicInfoScreen> with RouteAware {
onRefresh: () async {
setState(() {
_comicFuture = _loadComic();
_comicFutureKey = UniqueKey();
});
},
),

View File

@ -15,7 +15,7 @@ import 'components/RightClickPop.dart';
class GameInfoScreen extends StatefulWidget {
final String gameId;
const GameInfoScreen(this.gameId,{Key? key}):super(key: key);
const GameInfoScreen(this.gameId, {Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() => _GameInfoScreenState();
@ -23,9 +23,10 @@ class GameInfoScreen extends StatefulWidget {
class _GameInfoScreenState extends State<GameInfoScreen> {
late var _future = method.game(widget.gameId);
late var _key = UniqueKey();
@override
Widget build(BuildContext context){
Widget build(BuildContext context) {
return rightClickPop(
child: buildScreen(context),
context: context,
@ -35,6 +36,7 @@ class _GameInfoScreenState extends State<GameInfoScreen> {
Widget buildScreen(BuildContext context) {
return FutureBuilder(
key: _key,
future: _future,
builder: (BuildContext context, AsyncSnapshot<GameInfo> snapshot) {
if (snapshot.hasError) {
@ -48,6 +50,7 @@ class _GameInfoScreenState extends State<GameInfoScreen> {
onRefresh: () async {
setState(() {
_future = method.game(widget.gameId);
_key = UniqueKey();
});
}),
);
@ -86,7 +89,8 @@ class _GameInfoScreenState extends State<GameInfoScreen> {
bottom: 10,
),
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(5)),
borderRadius:
const BorderRadius.all(Radius.circular(5)),
child: MaterialButton(
color: Theme.of(context).colorScheme.secondary,
textColor: Colors.white,
@ -151,8 +155,7 @@ class _GameInfoScreenState extends State<GameInfoScreen> {
],
indicatorColor:
Theme.of(context).colorScheme.secondary,
labelColor:
Theme.of(context).colorScheme.secondary,
labelColor: Theme.of(context).colorScheme.secondary,
onTap: (val) async {
setState(() {
_tabIndex = val;