博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LayoutBuilder 构建一个窗口大小的widget树。 并可以获取widget 的狂宽高
阅读量:6908 次
发布时间:2019-06-27

本文共 3170 字,大约阅读时间需要 10 分钟。

  hot3.png

import 'package:flutter/material.dart';import 'package:flutter/cupertino.dart';import 'package:carousel_pro/carousel_pro.dart';import '../plug/wlist.dart';class BodyPage extends StatefulWidget {  final int tid;  BodyPage({Key key, this.tid}) : super(key: key);  @override  State
createState() => new BodyPageState();}class BodyPageState extends State
{ final PageController _pageController=new PageController(); double _currentPage = 0.0; @override void initState() { // TODO: implement initState super.initState(); _pageController.addListener((){ print(_pageController); print(_pageController.offset); }); } @override void dispose() { // TODO: implement dispose super.dispose(); _pageController.dispose(); }// new PageView(// physics: const PageScrollPhysics(parent: const BouncingScrollPhysics()),// onPageChanged: (index){// print(index);// },// controller: _pageController,// children:
[// new Container(// height: 200.0,// color: Colors.blue,// child: new Text('11')),// new Container(// height: 200.0,// color: Colors.purple,// child: new Text('22')),// new Container(// height: 200.0,// color: Colors.deepPurpleAccent,// child: new Text('3')),// ],// ) final String data; final double parallaxOffset=0.0; dom({data:"",parallaxOffset:0.0}){ return new Center( child: new Column( mainAxisSize: MainAxisSize.min, children: [ new Text( data, style: const TextStyle(fontSize: 60.0), ), new SizedBox(height: 40.0), new Transform( transform: new Matrix4.translationValues(parallaxOffset, 0.0, 0.0), child: const Text('Yet another line of text'), ), ], ), ); } @override Widget build(BuildContext context) { print(MediaQuery.of(context).size.width - 30); return new ListView( padding: EdgeInsets.only(top: 0.0), children:
[ new Container( margin: EdgeInsets.all(15.0), height: 200.0, child: new SizedBox( height: 200.0, child:new LayoutBuilder(builder: (context, constraints) => new NotificationListener( onNotification: (ScrollNotification note) { setState(() { _currentPage = _pageController.page; }); }, child: new PageView.custom( physics: const PageScrollPhysics(parent: const BouncingScrollPhysics()), controller: _pageController, childrenDelegate: new SliverChildBuilderDelegate( //生成widget (context, index){ print("当前距离:${_currentPage}"); //当前widget 的狂傲 return dom(data:"ww{$index}",parallaxOffset:constraints.maxWidth / 1.0 * (index - _currentPage)); }, childCount: 2,//个数 ), ), )), ), ), new Divider(), new WlistPage(), ], ); }}

转载于:https://my.oschina.net/woddp/blog/1932100

你可能感兴趣的文章
OSGi规范概要
查看>>
关系数据库的末日是否已经来临(转载)
查看>>
第二人生 我的成长
查看>>
硬编码写RadioGroup的时候要注意RadioButton的id重复问题
查看>>
周三 全身心的工作
查看>>
angularJS 1.0.6 tutorial 对应的github commit
查看>>
ldap的搭建
查看>>
利用percona-toolkit工具检查MySQL数据库主从一致性并修复
查看>>
Filter-全站GZIP压缩
查看>>
Windows自带的文件加密方法揭秘
查看>>
单页应用开发
查看>>
【Scrapy学习】 scrapyd 文件配置
查看>>
作业-week-2
查看>>
我的友情链接
查看>>
TCP链接
查看>>
Exchange Server 2007迁移Exchange Server 2010 (2) ---前期准备之二
查看>>
翻译:Fast dynamic extracted honeypots in cloud computing --5.CONCLUSION
查看>>
Effective C++: constexpr(during compilation).
查看>>
TCP/IP协议三次握手流程
查看>>
了解Oracle内核代码层的作用
查看>>