Search
 
SCRIPT & CODE EXAMPLE
 

DART

Flutter next pageView with button click

void main() => runApp(new PageDemo());

class PageDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(title: 'Page Demo', home: SamplePage());
  }
}

class SamplePage extends StatefulWidget {
  @override
  _SamplePageState createState() => _SamplePageState();
}

class _SamplePageState extends State<SamplePage> {
  List<Widget> _samplePages = [
    Center(
      child: Text('Page 1'),
    ),
    Center(child: Text('Page 2'))
  ];
  final _controller = new PageController();
  static const _kDuration = const Duration(milliseconds: 300);
  static const _kCurve = Curves.ease;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Page Demo'),
      ),
      body: Column(
        children: <Widget>[
          Flexible(
            child: PageView.builder(
              controller: _controller,
              itemCount: _samplePages.length,
              itemBuilder: (BuildContext context, int index) {
                return _samplePages[index % _samplePages.length];
              },
            ),
          ),
          Container(
            color: Colors.lightBlueAccent,
            child: Row(
              mainAxisSize: MainAxisSize.max,
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                FlatButton(
                  child: Text('Prev'),
                  onPressed: () {
                    _controller.previousPage(
                        duration: _kDuration, curve: _kCurve);
                  },
                ),
                FlatButton(
                  child: Text('Next'),
                  onPressed: () {
                    _controller.nextPage(duration: _kDuration, curve: _kCurve);
                  },
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}
Comment

flutter pageview show next page

PageView(
  children: items,
  controller: PageController(
      viewportFraction: 0.8,
      initialPage: 0,
  )

)
Comment

PREVIOUS NEXT
Code Example
Dart :: timer class in flutter 
Dart :: heart shape container flutter 
Dart :: special characters flutter 
Dart :: AnimatedCrossFade 
Dart :: UserScrollNotification in flutter 
Dart :: flutter gray screen 
Dart :: add a button that changes the text in flutter 
Dart :: flutter logo text color 
Dart :: inkwell splash color not working flutter 
Dart :: dart async stream 
Dart :: how to replace string character in dart 
Dart :: late in dart 
Dart :: image not shoing when i use network image,flutter 
Dart :: callback after last frame flutter 
Dart :: onpressed flutter calculate 
Dart :: Flutter local asset run time path 
Dart :: creating a clas in dart 
Dart :: dart async map 
Dart :: dropdown flutter transparent 
Dart :: how to group data by date in a listview in flutter 
Dart :: flutter obfuscation 
Swift :: swift notifications mac 
Swift :: swift view float on keyboard show 
Swift :: random element from array swift 
Swift :: check when webview finish loading swift 
Swift :: navigationController.pushViewController 
Swift :: swift remove all duplicates from an array 
Swift :: post request in swift 
Swift :: navigation title bar color swftui 
Swift :: go to view controller programmatically swift 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =