mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

* Update project.pbxproj files to say Flutter rather than Chromium Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright. * Update the copyright notice checker to require a standard notice on all files * Update copyrights on Dart files. (This was a mechanical commit.) * Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine. Some were already marked "The Flutter Authors", not clear why. Their dates have been normalized. Some were missing the blank line after the license. Some were randomly different in trivial ways for no apparent reason (e.g. missing the trailing period). * Clean up the copyrights in non-Dart files. (Manual edits.) Also, make sure templates don't have copyrights. * Fix some more ORGANIZATIONNAMEs
122 lines
2.9 KiB
Dart
122 lines
2.9 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
class ExpansionTileSample extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
home: Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('ExpansionTile'),
|
|
),
|
|
body: ListView.builder(
|
|
itemBuilder: (BuildContext context, int index) => EntryItem(data[index]),
|
|
itemCount: data.length,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
// One entry in the multilevel list displayed by this app.
|
|
class Entry {
|
|
Entry(this.title, [this.children = const <Entry>[]]);
|
|
final String title;
|
|
final List<Entry> children;
|
|
}
|
|
|
|
// The entire multilevel list displayed by this app.
|
|
final List<Entry> data = <Entry>[
|
|
Entry('Chapter A',
|
|
<Entry>[
|
|
Entry('Section A0',
|
|
<Entry>[
|
|
Entry('Item A0.1'),
|
|
Entry('Item A0.2'),
|
|
Entry('Item A0.3'),
|
|
],
|
|
),
|
|
Entry('Section A1'),
|
|
Entry('Section A2'),
|
|
],
|
|
),
|
|
Entry('Chapter B',
|
|
<Entry>[
|
|
Entry('Section B0'),
|
|
Entry('Section B1'),
|
|
],
|
|
),
|
|
Entry('Chapter C',
|
|
<Entry>[
|
|
Entry('Section C0'),
|
|
Entry('Section C1'),
|
|
Entry('Section C2',
|
|
<Entry>[
|
|
Entry('Item C2.0'),
|
|
Entry('Item C2.1'),
|
|
Entry('Item C2.2'),
|
|
Entry('Item C2.3'),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
];
|
|
|
|
// Displays one Entry. If the entry has children then it's displayed
|
|
// with an ExpansionTile.
|
|
class EntryItem extends StatelessWidget {
|
|
const EntryItem(this.entry);
|
|
|
|
final Entry entry;
|
|
|
|
Widget _buildTiles(Entry root) {
|
|
if (root.children.isEmpty)
|
|
return ListTile(title: Text(root.title));
|
|
return ExpansionTile(
|
|
key: PageStorageKey<Entry>(root),
|
|
title: Text(root.title),
|
|
children: root.children.map<Widget>(_buildTiles).toList(),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return _buildTiles(entry);
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
runApp(ExpansionTileSample());
|
|
}
|
|
|
|
/*
|
|
Sample Catalog
|
|
|
|
Title: ExpansionTile
|
|
|
|
Summary: An ExpansionTile for building nested lists, with two or more levels.
|
|
|
|
Description:
|
|
This app displays hierarchical data with ExpansionTiles. Tapping a tile
|
|
expands or collapses the view of its children. When a tile is collapsed
|
|
its children are disposed so that the widget footprint of the list only
|
|
reflects what's visible.
|
|
|
|
When displayed within a scrollable that creates its list items lazily,
|
|
like a scrollable list created with `ListView.builder()`, ExpansionTiles
|
|
can be quite efficient, particularly for material design "expand/collapse"
|
|
lists.
|
|
|
|
|
|
Classes: ExpansionTile, ListView
|
|
|
|
Sample: ExpansionTileSample
|
|
|
|
See also:
|
|
- The "expand/collapse" part of the material design specification:
|
|
<https://material.io/guidelines/components/lists-controls.html#lists-controls-types-of-list-controls>
|
|
*/
|