Full height Container inside SingleChildScrollView

Perhaps

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final mq = MediaQueryData.fromWindow(WidgetsBinding.instance.window);
    return MaterialApp(
      title: 'MyApp',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
        fontFamily: 'OpenSans',
      ),
      home: SingleChildScrollView(
        child: ConstrainedBox(
          constraints: BoxConstraints.tightFor(
            height: mq.size.height,
          ),
          child: Container(
            height: double.infinity,
            decoration: BoxDecoration(
                color: Colors.red,
                border: Border.all(color: Colors.blue, width: 8)),
          ),
        ),
      ),
    );
  }
}

In my case just used a ListView instead of a SingleChildScrollView with a Container with height.


i had the same problem but the answer didn't work for me, so i had t to wrap the SingleChildScrollView() in container and give it height: double.infinity

Container(
    height: double.infinity,
    color: Colors.green,
    child: SingleChildScrollView()
 )

Tags:

Flutter