Achintha Isuru
Achintha Isuru

Reputation: 3347

How to remove the animation that comes when finished scrolling a ListView in Flutter?

I am new to Flutter, and I want to remove the animation that comes when I finished scrolling a ListView in a Flutter App. Here is my code snippet.

@override
Widget build(BuildContext context) {
return MaterialApp(
  home: Scaffold(
    appBar: AppBar(
      title: Text("My First App"),
    ),
    body: Column(
      children: <Widget>[
        Question(questions[tempIndex]["questionText"]),
        Expanded(
          child: Container(
            height: double.infinity,
            child: 
            ListView.builder(

              itemCount: questions[tempIndex]["answers"].length,
              itemBuilder: (context, position) {
                return Answer(this.answerQuestion,questions[tempIndex]["answers"][position]);
              },

            ),
          ),
        )
      ],
    ),
  ),
);

}

Upvotes: 1

Views: 1714

Answers (1)

Fatima Hossny
Fatima Hossny

Reputation: 1297

Based on Rémi Rousselet answer in this link How to remove scroll glow? . you need to add this MyBehavior class in any dart file or in the same file and wrap list view with ScrollConfiguration like this code .

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("My First App"),
        ),
        body: Column(
          children: <Widget>[
            Question(questions[tempIndex]["questionText"]),
            Expanded(
              child: Container(
                height: double.infinity,
                child: ScrollConfiguration(
                  behavior: MyBehavior(),
                  child: ListView.builder(
                    itemCount: questions[tempIndex]["answers"].length,
                    itemBuilder: (context, position) {
                      return Answer(this.answerQuestion,
                          questions[tempIndex]["answers"][position]);
                    },
                  ),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}

class MyBehavior extends ScrollBehavior {
  @override
  Widget buildViewportChrome(
      BuildContext context, Widget child, AxisDirection axisDirection) {
    return child;
  }
}

Upvotes: 4

Related Questions