Download flutter/examples/api/lib/material/input_chip/input_chip.0.dart from luom2645/agent-workspace: direct link, hf CLI and curl.
- Browser
- Download file 2.39 kB
-
https://huggingface.co/luom2645/agent-workspace/resolve/7d4c5ffdb4518a5d7456ef06ab77458fcf42663a/flutter/examples/api/lib/material/input_chip/input_chip.0.dart
- Command line
-
hf download hf://luom2645/agent-workspace@7d4c5ffdb4518a5d7456ef06ab77458fcf42663a/flutter/examples/api/lib/material/input_chip/input_chip.0.dart
-
curl -L -o input_chip.0.dart https://huggingface.co/luom2645/agent-workspace/resolve/7d4c5ffdb4518a5d7456ef06ab77458fcf42663a/flutter/examples/api/lib/material/input_chip/input_chip.0.dart
2.39 kB
| // 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. | |
| // Flutter code sample InputChip. | |
| import 'package:flutter/material.dart'; | |
| void main() => runApp(const ChipApp()); | |
| class ChipApp extends StatelessWidget { | |
| const ChipApp({super.key}); | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true), | |
| home: const InputChipExample(), | |
| ); | |
| } | |
| } | |
| class InputChipExample extends StatefulWidget { | |
| const InputChipExample({super.key}); | |
| State<InputChipExample> createState() => _InputChipExampleState(); | |
| } | |
| class _InputChipExampleState extends State<InputChipExample> { | |
| int inputs = 3; | |
| int? selectedIndex; | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: const Text('InputChip Sample'), | |
| ), | |
| body: Center( | |
| child: Column( | |
| mainAxisSize: MainAxisSize.min, | |
| mainAxisAlignment: MainAxisAlignment.center, | |
| children: <Widget>[ | |
| Wrap( | |
| alignment: WrapAlignment.center, | |
| spacing: 5.0, | |
| children: List<Widget>.generate( | |
| inputs, | |
| (int index) { | |
| return InputChip( | |
| label: Text('Person ${index + 1}'), | |
| selected: selectedIndex == index, | |
| onSelected: (bool selected) { | |
| setState(() { | |
| if (selectedIndex == index) { | |
| selectedIndex = null; | |
| } else { | |
| selectedIndex = index; | |
| } | |
| }); | |
| }, | |
| onDeleted: () { | |
| setState(() { | |
| inputs = inputs - 1; | |
| }); | |
| }, | |
| ); | |
| }, | |
| ).toList(), | |
| ), | |
| const SizedBox(height: 10), | |
| ElevatedButton( | |
| onPressed: () { | |
| setState(() { | |
| inputs = 3; | |
| }); | |
| }, | |
| child: const Text('Reset'), | |
| ) | |
| ], | |
| ), | |
| ), | |
| ); | |
| } | |
| } | |