Created
September 14, 2018 23:44
-
-
Save dnfield/3a524bbbd4ebf4652c3379008469d096 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import 'package:bottom_sheet/viewport_scroll_controller.dart'; | |
import 'package:flutter/material.dart'; | |
import 'bottom_material.dart'; | |
void main() => runApp(new MyApp()); | |
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return new MaterialApp( | |
title: 'Flutter Demo', | |
theme: new ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: new MyHomePage(title: 'Flutter Demo Home Page'), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_MyHomePageState createState() => new _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> | |
with SingleTickerProviderStateMixin { | |
List<String> items = List.generate(15, (idx) => 'Item $idx'); | |
final colorColumn = new List<Widget>() | |
..addAll(Colors.primaries.map( | |
(color) => new SizedBox(height: 50.0, child: Container(color: color)))) | |
..addAll(Colors.accents.map( | |
(color) => new SizedBox(height: 50.0, child: Container(color: color)))); | |
@override | |
Widget build(BuildContext context) { | |
var simpleCol = new Container( | |
color: Colors.blue, | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: items | |
.map( | |
(String item) => Text(item), | |
) | |
.toList(), | |
), | |
); | |
var col = new SingleChildScrollView( | |
primary: true, | |
child: new Container( | |
color: Colors.red, | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: items | |
.map( | |
(String item) => Text(item), | |
) | |
.toList(), | |
), | |
), | |
); | |
var list = Container( | |
decoration: BoxDecoration(border: Border.all()), | |
child: new ListView.builder( | |
primary: true, | |
itemExtent: 50.0, | |
itemCount: items.length, | |
itemBuilder: (context, index) => Text( | |
items[index], | |
), | |
), | |
); | |
return new Scaffold( | |
persistentFooterButtons: <Widget>[], | |
appBar: new AppBar( | |
title: new Text(widget.title), | |
), | |
bottomSheet: col, | |
body: | |
new Builder( | |
builder: (BuildContext context) => new Center( | |
child: new Column( | |
mainAxisAlignment: MainAxisAlignment.start, | |
children: <Widget>[ | |
new Text( | |
'You have pushed the button this many times:', | |
), | |
RaisedButton( | |
child: Text('NO SCROLL'), | |
onPressed: () => showModalBottomSheet( | |
context: context, | |
builder: (BuildContext context) => simpleCol, | |
), | |
), | |
RaisedButton( | |
child: Text('SHOW SHEET (col)'), | |
onPressed: () => showModalBottomSheet( | |
context: context, | |
builder: (BuildContext context) => col, | |
clampTop: true, | |
initialTop: 500.0, | |
), | |
), | |
RaisedButton( | |
child: Text('SHOW LIST'), | |
onPressed: () => showBottomSheet( | |
context: context, | |
builder: (BuildContext context) => list, | |
)) | |
], | |
), | |
), | |
), | |
floatingActionButton: new FloatingActionButton( | |
child: Icon(Icons.add), | |
onPressed: () => print('pressed'), | |
elevation: 0.0, | |
), | |
); | |
} | |
} | |
// return new Directionality( | |
// textDirection: TextDirection.ltr, | |
// child: new Stack( | |
// children: <Widget>[ | |
// new Padding( | |
// padding: EdgeInsets.all(50.0), | |
// child: new RaisedButton( | |
// child: Text('HELO'), | |
// onPressed: () => print('hi'), | |
// ), | |
// ), | |
// new AnimatedBuilder( | |
// animation: _animationController, | |
// builder: (BuildContext context, Widget child) { | |
// final MediaQueryData query = MediaQuery.of(context); | |
// // print(child is ScrollView); | |
// // print(_scrollController.top); | |
// return new Positioned( | |
// left: 0.0, | |
// right: 100.0, | |
// // top: _animationController.value, | |
// top: _scrollController.top, | |
// height: 500.0, | |
// child: new PrimaryScrollController( | |
// controller: _scrollController, | |
// // child: new SingleChildScrollView( | |
// // controller: _scrollController, | |
// // primary: true, | |
// child: child, | |
// // ), | |
// ), | |
// ); | |
// }, | |
// // child: new SizedBox.expand( | |
// // child: new Column( | |
// // children: colorColumn, | |
// // ), | |
// child: new ListView( | |
// // reverse: true, | |
// primary: true, | |
// // child: new Column( | |
// children: colorColumn, | |
// ), | |
// ), | |
// // ), | |
// // ), | |
// ], | |
// ), | |
// ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment