File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -147,8 +147,7 @@ class MyPageState extends BasePersonState<MyPage> {
147147 }
148148
149149 @override
150- Widget build (BuildContext context) {
151- super .build (context); // See AutomaticKeepAliveClientMixin.
150+ Widget buildContainer (BuildContext context) {
152151 return StoreBuilder <GSYState >(
153152 builder: (context, store) {
154153 return GSYNestedPullLoadWidget (
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import 'dart:async';
22
33import 'package:flutter/material.dart' ;
44import 'package:flutter/rendering.dart' ;
5+ import 'package:flutter_riverpod/flutter_riverpod.dart' ;
56import 'package:gsy_github_app_flutter/common/repositories/user_repository.dart' ;
67import 'package:gsy_github_app_flutter/model/Event.dart' ;
78import 'package:gsy_github_app_flutter/model/User.dart' ;
@@ -71,6 +72,9 @@ abstract class BasePersonState<T extends StatefulWidget> extends State<T>
7172 @protected
7273 FetchHonorDataProvider get headerProvider;
7374
75+ @protected
76+ Widget buildContainer (BuildContext context);
77+
7478 @protected
7579 getUserOrg (String ? userName) {
7680 if (page <= 1 && userName != null ) {
@@ -188,6 +192,18 @@ abstract class BasePersonState<T extends StatefulWidget> extends State<T>
188192 ];
189193 }
190194
195+ @override
196+ Widget build (BuildContext context) {
197+ super .build (context);// See AutomaticKeepAliveClientMixin.
198+ ///局部 scoped 的 riverpod provider 方案
199+ ///配合 @Riverpod(dependencies: [] )
200+ return ProviderScope (
201+ /// 必要时还可以覆盖
202+ //overrides: [],
203+ child: buildContainer (context),
204+ );
205+ }
206+
191207 ///获取用户仓库前100个star统计数据
192208 getHonor () async {
193209 var _ = globalContainer.refresh (headerProvider);
Original file line number Diff line number Diff line change @@ -144,8 +144,7 @@ class PersonState extends BasePersonState<PersonPage> {
144144 bool get needHeader => false ;
145145
146146 @override
147- Widget build (BuildContext context) {
148- super .build (context);
147+ Widget buildContainer (BuildContext context) {
149148 return Scaffold (
150149 appBar: AppBar (
151150 title: GSYTitleBar (
You can’t perform that action at this time.
0 commit comments