Home > Net >  "androidOverscrollIndicator" is deprecated and shouldn't be used
"androidOverscrollIndicator" is deprecated and shouldn't be used

Time:08-28

I am applying stretch effect to Listview , I use androidOverscrollIndicator

ScrollBehavior(
   androidOverscrollIndicator: AndroidOverscrollIndicator.stretch
),

I work perfectly but i see a warning at androidOverscrollIndicator

'androidOverscrollIndicator' is deprecated and shouldn't be used. Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. This feature was deprecated after v2.13.0-0.0.pre.. (Documentation) Try replacing the use of the deprecated member with the replacement.

How can i fix this?

This is my code:

ScrollConfiguration(
   behavior: const ScrollBehavior(
      androidOverscrollIndicator: AndroidOverscrollIndicator.stretch
   ),
   child: GlowingOverscrollIndicator(
       axisDirection: AxisDirection.down,
       color: Colors.white,
       child: ListView(
          physics: const ClampingScrollPhysics(),
          children: [ 
              //some widget
          ],
         ),
       ),
    ),

enter image description here

CodePudding user response:

I think you are looking from this

child: StretchingOverscrollIndicator(
  axisDirection: AxisDirection.down,
  child: ListView.builder(
    itemCount: 12,
    itemBuilder: (context, index) {
      return ListTile(
        title: Text("item $index"),
      );
    },
  ),
),

CodePudding user response:

For future readers: Simplest solution is to use Material3

      MaterialApp(
        home: HomePage(),
        theme: ThemeData(
          useMaterial3: true,
        ),
      ),

This is the default behavior.

  • Related