@@ -2,34 +2,31 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [CustomScrollView].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [CustomScrollView].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const CustomScrollViewExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class CustomScrollViewExampleApp extends StatelessWidget {
|
||||
const CustomScrollViewExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: CustomScrollViewExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class CustomScrollViewExample extends StatefulWidget {
|
||||
const CustomScrollViewExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<CustomScrollViewExample> createState() => _CustomScrollViewExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _CustomScrollViewExampleState extends State<CustomScrollViewExample> {
|
||||
List<int> top = <int>[];
|
||||
List<int> bottom = <int>[0];
|
||||
|
||||
|
||||
@@ -2,22 +2,18 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [ListTile] selection in a ListView or GridView.
|
||||
// Long press any ListTile to enable selection mode.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [ListTile] selection in a [ListView] or [GridView].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const ListViewExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class ListViewExampleApp extends StatelessWidget {
|
||||
const ListViewExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: ListTileSelectExample(),
|
||||
);
|
||||
}
|
||||
@@ -104,8 +100,7 @@ class ListTileSelectExampleState extends State<ListTileSelectExample> {
|
||||
onPressed: () {
|
||||
_selectAll = !_selectAll;
|
||||
setState(() {
|
||||
_selected =
|
||||
List<bool>.generate(listLength, (_) => _selectAll);
|
||||
_selected = List<bool>.generate(listLength, (_) => _selectAll);
|
||||
});
|
||||
}),
|
||||
],
|
||||
@@ -161,8 +156,7 @@ class GridBuilderState extends State<GridBuilder> {
|
||||
Widget build(BuildContext context) {
|
||||
return GridView.builder(
|
||||
itemCount: widget.selectedList.length,
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
|
||||
itemBuilder: (_, int index) {
|
||||
return InkWell(
|
||||
onTap: () => _toggle(index),
|
||||
@@ -177,9 +171,7 @@ class GridBuilderState extends State<GridBuilder> {
|
||||
child: GridTile(
|
||||
child: Container(
|
||||
child: widget.isSelectionMode
|
||||
? Checkbox(
|
||||
onChanged: (bool? x) => _toggle(index),
|
||||
value: widget.selectedList[index])
|
||||
? Checkbox(onChanged: (bool? x) => _toggle(index), value: widget.selectedList[index])
|
||||
: const Icon(Icons.image),
|
||||
)),
|
||||
);
|
||||
Reference in New Issue
Block a user