Download flutter/examples/api/lib/material/icon_button/icon_button.3.dart from luom2645/agent-workspace: direct link, hf CLI and curl.
- Browser
- Download file 4.28 kB
-
https://huggingface.co/luom2645/agent-workspace/resolve/7d4c5ffdb4518a5d7456ef06ab77458fcf42663a/flutter/examples/api/lib/material/icon_button/icon_button.3.dart
- Command line
-
hf download hf://luom2645/agent-workspace@7d4c5ffdb4518a5d7456ef06ab77458fcf42663a/flutter/examples/api/lib/material/icon_button/icon_button.3.dart
-
curl -L -o icon_button.3.dart https://huggingface.co/luom2645/agent-workspace/resolve/7d4c5ffdb4518a5d7456ef06ab77458fcf42663a/flutter/examples/api/lib/material/icon_button/icon_button.3.dart
4.28 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. | |
| import 'package:flutter/material.dart'; | |
| /// Flutter code sample for [IconButton] with toggle feature. | |
| void main() { | |
| runApp(const IconButtonToggleApp()); | |
| } | |
| class IconButtonToggleApp extends StatelessWidget { | |
| const IconButtonToggleApp({super.key}); | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| theme: ThemeData( | |
| colorSchemeSeed: const Color(0xff6750a4), | |
| useMaterial3: true, | |
| ), | |
| title: 'Icon Button Types', | |
| home: const Scaffold( | |
| body: DemoIconToggleButtons(), | |
| ), | |
| ); | |
| } | |
| } | |
| class DemoIconToggleButtons extends StatefulWidget { | |
| const DemoIconToggleButtons({super.key}); | |
| State<DemoIconToggleButtons> createState() => _DemoIconToggleButtonsState(); | |
| } | |
| class _DemoIconToggleButtonsState extends State<DemoIconToggleButtons> { | |
| bool standardSelected = false; | |
| bool filledSelected = false; | |
| bool tonalSelected = false; | |
| bool outlinedSelected = false; | |
| Widget build(BuildContext context) { | |
| return Column( | |
| mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
| children: <Widget>[ | |
| Row( | |
| mainAxisAlignment: MainAxisAlignment.center, | |
| children: <Widget>[ | |
| IconButton( | |
| isSelected: standardSelected, | |
| icon: const Icon(Icons.settings_outlined), | |
| selectedIcon: const Icon(Icons.settings), | |
| onPressed: () { | |
| setState(() { | |
| standardSelected = !standardSelected; | |
| }); | |
| }, | |
| ), | |
| const SizedBox(width: 10), | |
| IconButton( | |
| isSelected: standardSelected, | |
| icon: const Icon(Icons.settings_outlined), | |
| selectedIcon: const Icon(Icons.settings), | |
| onPressed: null, | |
| ), | |
| ], | |
| ), | |
| Row( | |
| mainAxisAlignment: MainAxisAlignment.center, | |
| children: <Widget>[ | |
| IconButton.filled( | |
| isSelected: filledSelected, | |
| icon: const Icon(Icons.settings_outlined), | |
| selectedIcon: const Icon(Icons.settings), | |
| onPressed: () { | |
| setState(() { | |
| filledSelected = !filledSelected; | |
| }); | |
| }, | |
| ), | |
| const SizedBox(width: 10), | |
| IconButton.filled( | |
| isSelected: filledSelected, | |
| icon: const Icon(Icons.settings_outlined), | |
| selectedIcon: const Icon(Icons.settings), | |
| onPressed: null, | |
| ), | |
| ], | |
| ), | |
| Row( | |
| mainAxisAlignment: MainAxisAlignment.center, | |
| children: <Widget>[ | |
| IconButton.filledTonal( | |
| isSelected: tonalSelected, | |
| icon: const Icon(Icons.settings_outlined), | |
| selectedIcon: const Icon(Icons.settings), | |
| onPressed: () { | |
| setState(() { | |
| tonalSelected = !tonalSelected; | |
| }); | |
| }, | |
| ), | |
| const SizedBox(width: 10), | |
| IconButton.filledTonal( | |
| isSelected: tonalSelected, | |
| icon: const Icon(Icons.settings_outlined), | |
| selectedIcon: const Icon(Icons.settings), | |
| onPressed: null, | |
| ), | |
| ], | |
| ), | |
| Row( | |
| mainAxisAlignment: MainAxisAlignment.center, | |
| children: <Widget>[ | |
| IconButton.outlined( | |
| isSelected: outlinedSelected, | |
| icon: const Icon(Icons.settings_outlined), | |
| selectedIcon: const Icon(Icons.settings), | |
| onPressed: () { | |
| setState(() { | |
| outlinedSelected = !outlinedSelected; | |
| }); | |
| }, | |
| ), | |
| const SizedBox(width: 10), | |
| IconButton.outlined( | |
| isSelected: outlinedSelected, | |
| icon: const Icon(Icons.settings_outlined), | |
| selectedIcon: const Icon(Icons.settings), | |
| onPressed: null, | |
| ), | |
| ], | |
| ), | |
| ], | |
| ); | |
| } | |
| } | |