Add an adaptive visual density static function, and add it to… (#51921)

Adds a VisualDensity.adaptivePlatformDensity static function that returns different values for visual density based on the defaultTargetPlatform. Returns compact for desktop platforms, and a default visual density for other platforms.
This commit is contained in:
Greg Spencer
2020-03-31 16:16:25 -07:00
committed by GitHub
parent b2cf417863
commit 2a649b16e2
3 changed files with 37 additions and 0 deletions

View File

@@ -36,6 +36,10 @@ class MyApp extends StatelessWidget {
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
// This makes the visual density adapt to the platform that you run
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);