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

Two dimensional Skeletonizer with RefreshIndicator scroll glitch #44

Open
istornz opened this issue Sep 24, 2024 · 0 comments
Open

Two dimensional Skeletonizer with RefreshIndicator scroll glitch #44

istornz opened this issue Sep 24, 2024 · 0 comments

Comments

@istornz
Copy link

istornz commented Sep 24, 2024

Hello, first thanks for your amazing package!

I found an issue when using a two dimensional list using a RefreshIndicator widget. In fact, when you pull to reload, the single child scroll view automatically scroll to the bottom.

The glitch is not reproductible when removing the Skeletonizer widget, so I think the issue come with this package, do you have some clues about it?

Thanks :)

Simulator Screen Recording - iPhone 15 - 2024-09-24 at 17 34 22

Here is a sample reproductible code (only tried on iOS on both Simulator & physic device).

import 'package:flutter/material.dart';
import 'package:skeletonizer/skeletonizer.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Skeletonizer Demo',
      theme: ThemeData(
        extensions: const [
          SkeletonizerConfigData(),
        ],
      ),
      darkTheme: ThemeData(
        brightness: Brightness.dark,
        extensions: const [
          SkeletonizerConfigData.dark(),
        ],
      ),
      home: const SkeletonizerDemoPage(),
    );
  }
}

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

  @override
  State<SkeletonizerDemoPage> createState() => _SkeletonizerDemoPageState();
}

class _SkeletonizerDemoPageState extends State<SkeletonizerDemoPage> {
  bool _enabled = true;

  @override
  Widget build(BuildContext context) {
    const card = SizedBox(
      height: 100,
      width: 100,
      child: Card(
        child: ListTile(
          trailing: Icon(
            Icons.ac_unit,
            size: 32,
          ),
        ),
      ),
    );

    return Scaffold(
      appBar: AppBar(title: const Text('Skeletonizer Demo')),
      floatingActionButton: Padding(
        padding: const EdgeInsets.only(bottom: 0, right: 4),
        child: Padding(
          padding: const EdgeInsets.only(bottom: 110),
          child: FloatingActionButton(
            child: Icon(
              _enabled
                  ? Icons.hourglass_bottom_rounded
                  : Icons.hourglass_disabled_outlined,
            ),
            onPressed: () {
              setState(() {
                _enabled = !_enabled;
              });
            },
          ),
        ),
      ),
      body: RefreshIndicator.adaptive(
        onRefresh: () async {
          setState(() {
            _enabled = true;
          });
          await Future.delayed(const Duration(seconds: 2));
          setState(() {
            _enabled = false;
          });
        },
        child: SingleChildScrollView(
          physics: const AlwaysScrollableScrollPhysics(),
          child: Column(
            children: [
              Skeletonizer(
                enabled: _enabled,
                enableSwitchAnimation: true,
                child: SizedBox(
                  height: 700,
                  child: ListView.builder(
                    shrinkWrap: true,
                    itemCount: 20,
                    scrollDirection: Axis.horizontal,
                    padding: const EdgeInsets.all(16),
                    itemBuilder: (context, index) => card,
                  ),
                ),
              ),
              Skeletonizer(
                enabled: _enabled,
                enableSwitchAnimation: true,
                child: SizedBox(
                  height: 700,
                  child: ListView.builder(
                    itemCount: 20,
                    scrollDirection: Axis.horizontal,
                    shrinkWrap: true,
                    padding: const EdgeInsets.all(16),
                    itemBuilder: (context, index) => card,
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
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