Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

放到ListView中,swiper自动回到第一个! #178

Open
clong1995 opened this issue Jan 31, 2020 · 0 comments
Open

放到ListView中,swiper自动回到第一个! #178

clong1995 opened this issue Jan 31, 2020 · 0 comments

Comments

@clong1995
Copy link

1、放到ListView中,把swiper滑动到非首个。
2、把ListView滑动到底部。
3、然后把ListView滑到顶部查看swiper。
现象:swiper自动回到第一个!
期望:保持swiper用户滑动的位置。

import 'package:flutter/material.dart';

import 'package:flutter_swiper/flutter_swiper.dart';

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

class MyApp extends StatelessWidget {
  @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> {

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body:  ListView(
        children: <Widget>[
          Container(
            width: double.infinity,
            height: 400,
            decoration: BoxDecoration(
              color: Colors.green,
            ),
            child: new Swiper(
              itemBuilder: (BuildContext context,int index){
                return new Image.network("http://via.placeholder.com/350x150",fit: BoxFit.fill,);
              },
              itemCount: 3,
              pagination: new SwiperPagination(),
              control: new SwiperControl(),
            ),
          ),
          Container(
            width: double.infinity,
            height: 1500,
            decoration: BoxDecoration(
              color: Colors.blue,
            ),
          ),
        ],
      )
    );
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant