New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create CupertinoRadio Widget #123296
Create CupertinoRadio Widget #123296
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of the examples will need tests. See some of the other tests under examples/api/test
to see how they're written. They're pretty simple tests just to make sure that the example displays the expected components of the example.
class MyApp extends StatelessWidget { | ||
const MyApp({super.key}); | ||
|
||
static const String _title = 'Flutter Code Sample'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should give this a more specific name: (e.g. 'CuptertinoRadio Example').
|
||
void main() => runApp(const MyApp()); | ||
|
||
class MyApp extends StatelessWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try naming the app something like "CupertinoRadioApp" or something to make it match the example.
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// Flutter code sample for [CupertinoRadio]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Flutter code sample for [CupertinoRadio]. | |
/// Flutter code sample for [CupertinoRadio]. |
This should be a doc comment so that IDE users can click on the link to get back to the class the example is attached to.
You might need to move this below the import if the analyzer complains.
@override | ||
Widget build(BuildContext context) { | ||
return const CupertinoApp( | ||
title: _title, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably get rid of this. The title is not really used on iOS, I don't think. On Android it's used when you pull down the window shade, but that's all.
|
||
enum SingingCharacter { lafayette, jefferson } | ||
|
||
class MyStatefulWidget extends StatefulWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name this something specific to this example: CupertinoRadioExample
or something.
/// | ||
/// The radio button passes [value] as a parameter to this callback. The radio | ||
/// button does not actually change state until the parent widget rebuilds the | ||
/// radio button with the new [groupValue]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// radio button with the new [groupValue]. | |
/// radio button with a new [groupValue]. |
/// This example shows how to enable deselecting a radio button by setting the | ||
/// [toggleable] attribute. | ||
/// | ||
/// ** See code in examples/api/lib/cupertino/radio/radio.toggleable.0.dart ** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// ** See code in examples/api/lib/cupertino/radio/radio.toggleable.0.dart ** | |
/// ** See code in examples/api/lib/cupertino/radio/cupertino_radio.toggleable.0.dart ** |
/// Defaults to [CupertinoColors.white]. | ||
final Color? fillColor; | ||
|
||
/// The color for the radio's border shadow when it has the input focus. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really a "shadow"? I think I'd call it just a border.
|
||
@override | ||
Widget build(BuildContext context) { | ||
const Size size = Size(18.0, 18.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might move this to a named constant at the top of the file.
29f8af3
to
783cf86
Compare
783cf86
to
815fbe3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create CupertinoRadio Widget
Addresses #102813. Adds a radio widget to Cupertino. Like the checkbox, this will be made adaptable with the Material radio widget.
Here's the radio buttons in the macOS settings:
And here's the Cupertino version in action, including keyboard focus/ interaction:
Screen.Recording.2023-03-22.at.3.49.57.PM.mov
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.