Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
Docs for OptionCard
Browse files Browse the repository at this point in the history
  • Loading branch information
jpnurmi committed Jul 8, 2021
1 parent 6c4eb90 commit b93fe0c
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion packages/ubuntu_desktop_installer/lib/widgets/option_card.dart
@@ -1,6 +1,30 @@
import 'package:flutter/material.dart';

/// A card widget that presents a toggleable option.
///
/// For example:
/// ```dart
/// Row(
/// children: [
/// OptionCard(
/// imageAsset: 'assets/foo.png',
/// titleText: 'Foo',
/// bodyText: 'Description...',
/// selected: model.option == MyOption.foo,
/// onSelected: () => model.option = Option.foo,
/// ),
/// OptionCard(
/// imageAsset: 'assets/bar.png',
/// titleText: 'Bar',
/// bodyText: 'Description...',
/// selected: model.option == MyOption.bar,
/// onSelected: () => model.option = MyOption.bar,
/// ),
/// ],
/// )
/// ```
class OptionCard extends StatefulWidget {
/// Creates an option card with the given properties.
const OptionCard({
Key? key,
this.imageAsset,
Expand All @@ -10,19 +34,30 @@ class OptionCard extends StatefulWidget {
required this.onSelected,
}) : super(key: key);

/// An image asset that illustrates the option.
final String? imageAsset;

/// A short title below the image.
final String? titleText;

/// A longer descriptive body text below the title.
final String? bodyText;

/// Whether the option is currently selected.
final bool selected;

/// Called when the option is selected.
final VoidCallback onSelected;

@override
OptionCardState createState() => OptionCardState();
}

@visibleForTesting
// ignore: public_member_api_docs
class OptionCardState extends State<OptionCard> {
bool _hovered = false;
bool get hovered => _hovered;
bool get hovered => _hovered; // ignore: public_member_api_docs

void _setHovered(bool hovered) {
if (_hovered == hovered) return;
Expand Down

0 comments on commit b93fe0c

Please sign in to comment.