0

I have some stateless scrollable widget like this

`class ProfileScreen extends StatelesslWidget {
final dataKey = new GlobalKey();

 @override
  Widget build(BuildContext context) {
    BlocProvider.of<StepsBloc>(context).add(CheckStatus());
    return Scaffold(
      backgroundColor: NorbuColors.darkGrey,
      body: CustomScrollView(
        slivers: [
          SliverToBoxAdapter(
            child: Padding(
              padding: const EdgeInsets.only(
                  left: 20, right: 20, top: 48, bottom: 15),
              child: _ProfileReg(),
            ),
          ),
          SliverToBoxAdapter(
            key: dataKey,
            child: _AchievementsStatistics(),
          ),
          SliverToBoxAdapter(
            child: _StepsStatistics(),
          ),
          SliverToBoxAdapter(
            child: _MyGoalsStatistics(),
          ),
          SliverToBoxAdapter(
            child: _GratefulTimerStatistics(),
          ),
          SliverToBoxAdapter(
            child: _WheelBalanceStatistics(),
          ),
        ],
      ),
    );
  }`

And my question is: what is a good way to scroll parent widget from child?

I know easy way is to use Scrollable.ensureVisible(dataKey.currentContext!); but it works only inside scrollable parent widget. Thanks!

0 Answers0