Created
October 24, 2019 10:54
-
-
Save iapicca/008b307d71f9027ee813079dd93d6d34 to your computer and use it in GitHub Desktop.
Axis change bug
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:flutter/material.dart'; | |
void main() => runApp(MaterialApp(home: MyApp())); | |
class MyApp extends StatefulWidget { | |
@override | |
_MyAppState createState() => _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { | |
static bool _slider = true; | |
static List<Widget> _widgets = [ | |
Container(color: Colors.red,), | |
Container(color: Colors.blue,), | |
Container(color: Colors.green,), | |
]; | |
@override | |
Widget build(BuildContext context)=> Scaffold( | |
body: Center( | |
child: PageView.builder( | |
scrollDirection: _slider ? Axis.vertical : Axis.horizontal, | |
itemCount: _widgets.length, | |
itemBuilder: (BuildContext context, int index)=> | |
_widgets[index],), | |
), | |
floatingActionButton: FloatingActionButton( | |
onPressed: ()=> setState(()=> _slider = _slider ? false : true,) | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment