sbdavid / flutter_page_tracker Goto Github PK
View Code? Open in Web Editor NEWflutter埋点、弹窗埋点、页面埋点事件捕获框架,支持普通页面的页面曝光事件(PageView),页面离开事件(PageExit)。支持在TabView和PageView组件中发送页面曝光和页面离开
License: BSD 2-Clause "Simplified" License
flutter埋点、弹窗埋点、页面埋点事件捕获框架,支持普通页面的页面曝光事件(PageView),页面离开事件(PageExit)。支持在TabView和PageView组件中发送页面曝光和页面离开
License: BSD 2-Clause "Simplified" License
RT,最近公司也在做 Flutter 无痕埋点,希望作者能够建一个群,让各位有志之士能够在一起研究,共同进步,最终克服 Flutter 全埋点方面所有问题,真正做到开源,同时建立这方面的领导地位和影响力。
如标题
应该怎么解决?
Offstage(
offstage: _tabIndex != 0,
child: TickerMode(
enabled: _tabIndex == 0,
child: MaterialApp(
theme: ThemeData(fontFamily: "Meiryo"),
home: HomeView(),
navigatorObservers: [TrackerRouteObserverProvider.of(context)],
)),
),
Offstage(
offstage: _tabIndex != 1,
child: TickerMode(
enabled: _tabIndex == 1,
child: MaterialApp(
theme: ThemeData(fontFamily: "Meiryo"),
home: LifelogView(),
navigatorObservers: [TrackerRouteObserverProvider.of(context)],
),
),
),
维持一个页面栈,直接在initState()和dispose()中,对这个栈进行操作;为什么还需要在didPush 和 didPop中操作这个栈,求教。
A页面push到B页面,B页面push到C页面,然后C页面直接pop到A页面,按照目前您这个框架,B页面的didPageView()和didPageExit()都会调用,实际上按照产品的定义,从C页面直接pop到A页面,B页面的两个的didPageView()和didPageExit()是不需要埋点的,怎么解决这个问题?
C页面pop到A页面的方法如下:
Navigator.of(context).popUntil((Route route){
if (route.settings.name == "/"){
return true;
}
return false;
});
唉
../../../flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_page_tracker-3.0.7/lib/src/page_view_listener_mixin.dart:106:20: Error: The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
return (context.inheritFromWidgetOfExactType(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
比如通过路由跳转到了 B 页面,那么如何在didpush里面获取 B 页面的信息呢,例如B页面的类名等
放在initState()是不是更专业一点?
`点击tabbar` 切换到我的页面 didPageView 不调用 ,请问是什么原因导致的?
首页代码如下:
class TabNavigator extends StatefulWidget {
final int index;
TabNavigator({Key key, this.index = 0}) : super(key: key);
@override
_TabNavigatorState createState() => _TabNavigatorState();
}
class _TabNavigatorState extends State<TabNavigator> {
final _defaultColor = Color(0xff979797); // icon默认颜色
TabsModel model = TabsModel();
final List<String> _appBarTitles = ['首页', '商品分类', '常用清单', '购物车', '个人中心'];
List<BottomNavigationBarItem> __buildDarkBottomNavigationBarItem() {
const _tabsItem = [
[
'assets/images/tabs/home_icon.png',
'assets/images/tabs/home_active_icon.png'
],
[
'assets/images/tabs/shopping_list_icon.png',
'assets/images/tabs/shopping_list_active_icon.png'
],
[
'assets/images/tabs/common_list_icon.png',
'assets/images/tabs/common_list_active_icon.png'
],
[
'assets/images/tabs/shop_card_icon.png',
'assets/images/tabs/shop_card_active_icon.png'
],
[
'assets/images/tabs/mine_icon.png',
'assets/images/tabs/mine_active_icon.png'
]
];
return List.generate(
_tabsItem.length,
(index) => BottomNavigationBarItem(
icon: BadgeItem(
index: index,
child: Image.asset(
_tabsItem[index][0],
width: 24.0.w,
height: 24.0.h,
color: _defaultColor,
)),
activeIcon: BadgeItem(
index: index,
child: Image.asset(_tabsItem[index][1],
width: 24.0.w, height: 24.0.h)),
title: Padding(
padding: EdgeInsets.only(top: 4.0),
child: Text(_appBarTitles[index]),
)));
}
@override
void initState() {
controller = PageController(initialPage: widget.index);
model.value = widget.index;
super.initState();
}
@override
void dispose() {
super.dispose();
controller.dispose();
}
@override
Widget build(BuildContext context) {
print(context);
// 设计基于iPhone6(iPhone6 750*1334)的大小
ScreenUtil.init(context, width: 375, height: 667, allowFontScaling: true);
return DoubleTapBackExitApp(
child: Scaffold(
body: PageViewWrapper(
changeDelegate: PageViewChangeDelegate(controller),
pageAmount: 4,
initialPage: controller.initialPage,
child: PageView(
controller: controller,
physics: NeverScrollableScrollPhysics(),
onPageChanged: (index) => model.value = index,
children: <Widget>[
HomePage(index: 0),
GoodsListPage(index: 1),
CommonMainPage(index: 2),
ShoppingCartPage(index: 3),
MinePage(index: 4)
],
)),
bottomNavigationBar: ProviderWidget<TabsModel>(
model: model,
builder: (_, model, __) {
return BottomNavigationBar(
currentIndex: model.value,
selectedFontSize: 10.0,
unselectedFontSize: 10.0,
unselectedItemColor: _defaultColor,
selectedItemColor: HmColors.colorMain,
onTap: (index) {
// 埋点
_eventTracking(index);
PageViewToPage.jumpToPage(index, context);
},
type: BottomNavigationBarType.fixed,
items: __buildDarkBottomNavigationBarItem());
},
)),
);
}
}
我的页面如下:
class MinePage extends StatefulWidget {
final int index;
MinePage({Key key, this.index}) : super(key: key);
@override
_MinePageState createState() => _MinePageState();
}
class _MinePageState extends State<MinePage>
with
AutomaticKeepAliveClientMixin<MinePage>,
PageTrackerAware,
PageViewListenerMixin {
int get pageViewIndex => widget.index;
MineModel model = MineModel();
EasyRefreshController refreshController;
@override
void didPageView() {
super.didPageView();
PageViewEventTracking.pageEnter();
model.load();
}
@override
void didPageExit() {
super.didPageExit();
PageViewEventTracking.pageLeave(widget.index);
}
@override
void initState() {
super.initState();
refreshController = EasyRefreshController();
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
Global.appPrecacheImage.precacheMineImages(context);
}
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
super.build(context);
double _mediaQueryTop = MediaQuery.of(context).padding.top; // padding高度
return AnnotatedRegion(
value: SystemUiOverlayStyle.dark,
child: Scaffold(
body: EasyRefresh(
enableControlFinishRefresh: true,
controller: refreshController,
header: HmCustomHeader(
bgColor: Colors.transparent,
textColor: Colors.black87,
extent: _mediaQueryTop + 60,
triggerDistance: _mediaQueryTop + 70,
showInfo: false),
onRefresh: () async {
await model.load();
refreshController.finishRefresh();
},
child: Container(
child: Column(
children: <Widget>[
ProviderWidget<MineModel>(
model: model,
onModelReady: (MineModel model) => model.load(),
type: BaseType.NORMAL,
child: Column(
children: <Widget>[
MineHeaderView(model: model),
MineOrderView(model: model),
CommonFunctionView(model: model),
],
),
),
],
),
),
)),
);
}
}
放在initState()里是不是更好一些?
我看输出基本是一样的,能说明一下吗?
Because no versions of flutter_bloc match >5.0.1 <6.0.0 and flutter_bloc 5.0.1 depends on provider ^4.0.5, flutter_bloc ^5.0.1 requires provider ^4.0.5.
And because flutter_page_tracker ^1.1.1 depends on provider ^3.2.0, flutter_bloc ^5.0.1 is incompatible with flutter_page_tracker ^1.1.1.
So, because flutter_module depends on both flutter_bloc ^5.0.1 and flutter_page_tracker ^1.2.2, version solving failed.
如题
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.