Skip to content

CircularProgressIndicator does not disposed when used in the CaouselSlider #216

@emrszr

Description

@emrszr

When i use CircularProgressIndicator in the CarouselSlider, a new instance created in each loop. I tried with different carousel widgets. But same issue occurred.

To reproduce issue, just create a new project, add CarouselSlider and CircularProgressIndicator, explore widget tree.

pubspec.yaml
`name: carousel
description: "A new Flutter project."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment:
sdk: '>=3.4.4 <4.0.0'
dependencies:
flutter:
sdk: flutter

cupertino_icons: ^1.0.6
percent_indicator: ^4.2.3

carousel_slider_plus: ^7.0.1

flutter_carousel_slider: ^1.1.0
flutter_carousel_slider: ^1.1.0

dev_dependencies:
flutter_test:
sdk: flutter

flutter_lints: ^3.0.0

flutter:
uses-material-design: true
main.dartimport 'package:flutter/material.dart';
import 'package:flutter_carousel_slider/carousel_slider.dart';
import 'package:percent_indicator/circular_percent_indicator.dart';

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

class MyApp extends StatelessWidget {
const MyApp({super.key});

@OverRide
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Carousel with CircularPercentIndicator')),
body: const CarouselDemo(),
),
);
}
}

class CarouselDemo extends StatefulWidget {
const CarouselDemo({super.key});

@OverRide
State createState() => _CarouselDemoState();
}

class _CarouselDemoState extends State {
final GlobalKey<_CarouselDemoState> _sliderKey = GlobalKey();

@OverRide
Widget build(BuildContext context) {
final items = List.generate(
7,
(index) => CircularPercentIndicator(
startAngle: 0,
radius: 100.0,
lineWidth: 18.0,
animation: true,
percent: (((index + 1) % 3) * 0.2),
backgroundColor: Colors.transparent,
animateFromLastPercent: true,
circularStrokeCap: CircularStrokeCap.round,
progressColor: Colors.red,
),
);
return Scaffold(
body: ListView(
children: [
SizedBox(
height: 500,
child: CarouselSlider.builder(
key: _sliderKey,
unlimitedMode: true,
slideBuilder: (index) {
return items[index];
},
slideTransform: const CubeTransform(),
slideIndicator: CircularSlideIndicator(
padding: const EdgeInsets.only(bottom: 32),
),
itemCount: items.length),
),
],
),
);
}
}
flutter doctor -v[✓] Flutter (Channel stable, 3.22.3, on macOS 14.6.1 23G93 darwin-x64, locale en-TR)
• Flutter version 3.22.3 on channel stable at /Users/macpro/Development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b0850beeb2 (9 weeks ago), 2024-07-16 21:43:41 -0700
• Engine revision 235db911ba
• Dart version 3.4.4
• DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/macpro/Development/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.14.3

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• android-studio-dir = /Applications/Android Studio.app
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.93.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.96.0

[✓] Connected device (3 available)
• iPhone 15 Pro Max (mobile) • A6879F5B-BF86-471C-837E-36ADB7196B93 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
• macOS (desktop) • macos • darwin-x64 • macOS 14.6.1 23G93 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 128.0.6613.138

[✓] Network resources
• All expected network resources are available.

• No issues found!`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions