Coder Social home page Coder Social logo

Comments (2)

fmtjava avatar fmtjava commented on August 27, 2024 1

1.banner每次切换的时候,回调中改变了currentIndex,调用了notifyListeners,首页并不会重新build一次,首页会多build一次,是因为AppBar加了actions属性导致,你可以测试一下
2.底部导航每次切换的时候,首页也会build一次的原因是因为下标改变时,原先的代码代码使用了setState导致,这块已做了优化

from flutter_eyepetizer.

EvanEvil avatar EvanEvil commented on August 27, 2024

1.banner每次切换的时候,回调中改变了currentIndex,调用了notifyListeners,首页并不会重新build一次,首页会多build一次,是因为AppBar加了actions属性导致,你可以测试一下
2.底部导航每次切换的时候,首页也会build一次的原因是因为下标改变时,原先的代码代码使用了setState导致,这块已做了优化

第二个问题已经确认了下,没问题了,第一个问题应该不是actions属性的问题,我现在是这样做的,将banner的文字部分也放到banner的itemBuilder里,onIndexChanged回调就不需要了
Swiper(
autoplay: true,
pagination: SwiperPagination(alignment: Alignment.bottomRight),
itemCount: model.bannerList.length,
// onIndexChanged: (index) {
// model.changeBanner(index);
// },
onTap: (index) {
NavigatorManager.to(VideoDetailPage(data: model.bannerList[index].data,));
},
itemBuilder: (BuildContext context, int index) {
return Stack(
children: [
Container(
width: MediaQuery.of(context).size.width,
child: CachedNetworkImage(
imageUrl: model.bannerList[index].data.cover.feed,
fit: BoxFit.cover,
),
),
Positioned(
width: MediaQuery.of(context).size.width - 30,
bottom: 0,
child: Container(
padding: EdgeInsets.fromLTRB(15, 10, 0, 15),
child: Text(
model.bannerList[index].data.title,
style: TextStyle(fontSize: 12, color: Colors.white),
),
decoration: BoxDecoration(
color: Colors.black12,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(8),
bottomRight: Radius.circular(8))),
))
],

        );
      },
    ),

from flutter_eyepetizer.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.