The argument type 'Container Function(int, dynamic)' can't be assigned to the parameter type 'dynamic Function(int)'

Viewed 76
import 'dart:ffi';

import 'package:flutter/material.dart';

import 'package:concentric_transition/concentric_transition.dart';

class ConcentricTransition extends StatefulWidget {
  const ConcentricTransition({Key? key}) : super(key: key);

  @override
  State<ConcentricTransition> createState() => _ConcentricTransitionState();
}

class _ConcentricTransitionState extends State<ConcentricTransition> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ConcentricPageView(
        colors: [Colors.white, Colors.blueAccent, Colors.pinkAccent],
        itemBuilder: (index, value) {
          return Container();

The argument type 'Container Function(int, dynamic)' can't be assigned to the parameter type 'dynamic Function(int)'. tam olarak burada sorunu alıyorum. }, ), ); } }

1 Answers

Your itemBuilder callback only takes one argument of type int (I'm guessing an index); however, your callback takes two arguments here.

Change the callback to take one argument, and it should resolve the issue:

itemBuilder: (index) {
  // If you need the value, you can get it this way
  final value = values[index];
  return Container();
}

If you need the value to be made available to the callback, you'll need to change the type of the callback in the definition of ConcentricPageView, for example:

class ConcentricPageView extends StatelessWidget {
  final Widget Function(int, dynamic) itemBuilder;

  ConcentricPageView({required this.itemBuilder});
}
Related