Skip to content
An example of VisualDensity usage.
Dart Makefile C++ Swift C HTML Objective-C
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
android
ios
lib
linux
macos
readme
test
web
.gitignore
.metadata
README.md
pubspec.lock
pubspec.yaml

README.md

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

You can’t perform that action at this time.