1

Here is my code:

 class ListItems extends StatelessWidget {
final String child; const ListItems({super.key, required this.child});

@override Widget build(BuildContext context) { return Sizer(builder: ((context, orientation, deviceType) { return Padding( padding: const EdgeInsets.all(8.0), child: Container( color: Colors.blueGrey, height: 25.h, child: Text(child), ), ); })); } }
MendelG
  • 14,885
  • 4
  • 25
  • 52
Zeher
  • 15
  • 4
  • 1
    What is the child inside the 'Text' widget? Can you share the code for that? – NUACHE Apr 19 '23 at 09:05
  • 1
    PLEASE [Edit and update more code here](https://stackoverflow.com/posts/76052074/edit). – gretal Apr 21 '23 at 05:33
  • 1
    Also format you code by selecting all the code portion by [edit](https://stackoverflow.com/posts/76052074/edit) and `ctrl and press k`. – gretal Apr 21 '23 at 05:42

1 Answers1

0

Since the is deviceType is not being passed into the Sizer widget in the ListItems class. So try providing device type or remove the device parameter from Sizer widget.

class ListItems extends StatelessWidget {
  final String child;

  const ListItems({Key? key, required this.child}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Sizer(
      builder: ((context, orientation, [deviceType = DeviceType.mobile]) {
        return Padding(
          padding: const EdgeInsets.all(8.0),
          child: ConstrainedBox(
            constraints: const BoxConstraints(
              minHeight: 100,
              maxHeight: 100,
            ),
            child: Container(
              color: Colors.blueGrey,
              child: Center(child: Text(child)),
            ),
          ),
        );
      }),
    );
  }
}
gretal
  • 1,092
  • 6
  • 14