12import'package:bidirectional_scroll_view/bidirectional_scroll_view.dart';3import'package:flutter/material.dart';45voidmain(){6runApp(newMyApp());7}89//動的コンテンツの設定10classMyAppextendsStatefulWidget{11@override12 _MyAppState createState()=>new_MyAppState();13}1415class_MyAppStateextendsState<MyApp>{16//「BidirectionalScrollViewPlugin」のプロパティ「plugin」17 BidirectionalScrollViewPlugin _plugin;1819@override20voidinitState(){21//アプリ起動時1回だけ呼び出される「initState」22super.initState();23 _plugin =newBidirectionalScrollViewPlugin(24 child:_buildWidgets(),//ここで「_buildWidgets()」が呼び出される25 velocityFactor:2.0,26 scrollListener:(offset){27print("----------");28print("new x and y scroll offset: "+29 offset.dx.toString()+30" "+31 offset.dy.toString());32print("x and y scroll offset getters: "+33 _plugin.x.toString()+34" "+35 _plugin.y.toString());36print("height and width of overscrolled widget: "+37 _plugin.height.toString()+38" "+39 _plugin.width.toString());40print("height and width of the container: "+41 _plugin.containerHeight.toString()+42" "+43 _plugin.containerWidth.toString());44print("----------");45},46);4748//_plugin.offset = new Offset(10.0, 10.0); // use this method to set a new offset where appropriate49}5051@override52 Widget build(BuildContext context){53//「initState」の次にこちらが呼び出される54//マテリアルデザインを使用55returnnewMaterialApp(56 home:newScaffold(57 appBar:newAppBar(58 title:newText('Bidirectional ScrollView Plugin'),59),60 body:newCenter(child: _plugin //ボディの中身は「_plugin」が呼び出される61),62),63);64}6566 Widget _buildWidgets(){67//何故か「ConstrainedBox」に入れないとリストが表示されない68returnConstrainedBox(69 constraints: BoxConstraints.expand(height:1000.0, width:1000.0),70 child:newListView.builder(71 itemBuilder:(BuildContext context, int x){72returnnewRow(73 mainAxisAlignment: MainAxisAlignment.spaceEvenly,74 children:newList.generate(5,(int y){75returnnewText("$x,$y", style: Theme.of(context).textTheme.display2);76}),77);78},79),80);81}82}838485
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。