Skip to content

Instantly share code, notes, and snippets.

@iapicca
Created October 24, 2019 10:54
Show Gist options
  • Save iapicca/008b307d71f9027ee813079dd93d6d34 to your computer and use it in GitHub Desktop.
Save iapicca/008b307d71f9027ee813079dd93d6d34 to your computer and use it in GitHub Desktop.
Axis change bug
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