Skip to content

gspencergoog/density_sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

density_sample

A sample of using the new Material density support in Flutter.

Usage

$ flutter packages get $ flutter run

Sample Code

Flutter v1.13 added support for a visualDensity property of the Theme, which allows you to set the density of widgets that choose to support it (checkbox, radio, chip and button as of this writing). You can change the density by setting the theme's visualDensity to an instance of type VisualDensity, e.g.

...
List<VisualDensity> densitySelected = <VisualDensity>[
  VisualDensity.standard,
  const VisualDensity(horizontal: -1.5, vertical: -1.5),
  const VisualDensity(horizontal: -3.0, vertical: -3.0),
];
...
AnimatedTheme(data: Theme.of(context).copyWith(visualDensity: densitySelected[i]),
...

You can see the details in main.dart.

Screen Shot