Repository navigation
Add documentation for how to use annotated region - #24989
Conversation
| /// be short-circuted by passing `sized: false` to a single annotated region | ||
| /// widget. | ||
| /// | ||
| /// ## Sample Code |
There was a problem hiding this comment.
Please use {@tool snippet --template=stateful_widget}...{@end-tool} instead of "## Sample code" for this kind of sample. You'll leave out everything except for the contents of the State object, like so:
/// {@tool snippet --template=stateful_widget}
/// The following example creates a widget that changes the status bar color
/// to a random value on Android.
///
/// ```dart
/// final _random = math.Random();
/// SystemUiOverlayStyle _currentStyle = SystemUiOverlayStyle.light;
///
/// void _changeColor() {
/// final color = Color.fromRGBO(
/// _random.nextInt(255),
/// _random.nextInt(255),
/// _random.nextInt(255),
/// 1.0,
/// );
/// setState(() {
/// _currentStyle = SystemUiOverlayStyle.dark.copyWith(
/// statusBarColor: color,
/// );
/// });
/// }
///
/// @override
/// Widget build(BuildContext context) {
/// return Scaffold(
/// body: AnnotatedRegion(
/// sized: false,
/// value: _currentStyle,
/// child: Center(
/// child: RaisedButton(
/// child: const Text('Change Color'),
/// onPressed: _changeColor,
/// ),
/// ),
/// ),
/// );
/// }
/// {@end-tool}There was a problem hiding this comment.
How do I add imports? This doesn't know about dart:math or SystemUiOverlayStyle
There was a problem hiding this comment.
Oh. You review and approve this PR: #24830 :-)
I ran into the same problem in that PR and fixed it. I'm happy to split that out into a separate PR since you need it.
There was a problem hiding this comment.
It's not critical to land this now, so I'm happy to wait. I will take a look at the PR as well tho!
There was a problem hiding this comment.
How do I place imports into the "code-imports" section?
There was a problem hiding this comment.
Add a section that looks like this:
```dart imports
import 'package:foo/foo.dart';
```
| /// it can be hit-tested by the framework. On every frame, the framework will | ||
| /// select the first annotated region it finds under the status and | ||
| /// navigation bar and synthesize them into a single style. This process can | ||
| /// be short-circuted by passing `sized: false` to a single annotated region |
There was a problem hiding this comment.
Maybe you can explain more what way you mean by "short-circuited"? Passing sized: false just makes it "hit" if it's on top of the layer tree, regardless of the location passed (At least I think so: is that right?).
|
cc @gspencergoog, it seems I'm not able to use a flutter/* import. Tried relative imports too. dart ./dev/bots/analyze.dart One of the files in the services package imports that package recursively. |
|
Ooh, exciting. OK, let me take a look. |
|
This is a result of an overly broad RegExp in flutter's analysis bot script. I created a PR to fix it: #26539 |

Adds sample code section for annotated region controlled status bar color