简体   繁体   中英

Flutter: How to use widgets with abstract constructors

I've created a Drawer widget in flutter, but the DrawerHeader widget I've listed as one of its children takes up more vertical space than I want.

From DrawerHeader's properties here , it looks like the margin property might be responsible for size, but I'm stuck on how to use the EdgeInsetsGeometry widget since its constructor is abstract.

I've included code that is similar to mine below:

return Scaffold(
    drawer: Drawer(
        child: ListView(
          padding: EdgeInsets.zero,
          children: <Widget>[
              // want to use margin property in DrawerHeader widget
              DrawerHeader(child: Text("Header"))
          ],
        )
    )
    ...
);

EdgeInsetsGeometry is just an abstract class.

One concrete implementation is EdgeInsets :

DrawerHeader(
  margin: const EdgeInsets.all(8.0),
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM