Skip to content

Add documentation for how to use annotated region - #24989

Merged
jonahwilliams merged 14 commits into
flutter:masterfrom
jonahwilliams:system_chrome_doc
Jan 17, 2019
Merged

jonahwilliams merged 14 commits into
flutter:masterfrom
jonahwilliams:system_chrome_doc

Conversation

@jonahwilliams

@jonahwilliams jonahwilliams commented Dec 5, 2018 •

Copy link
Copy Markdown
Contributor

Adds sample code section for annotated region controlled status bar color

@zoechi zoechi added the framework flutter/packages/flutter repository. See also f: labels. label Dec 5, 2018
/// be short-circuted by passing `sized: false` to a single annotated region
/// widget.
///
/// ## Sample Code

@gspencergoog gspencergoog Dec 10, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I add imports? This doesn't know about dart:math or SystemUiOverlayStyle

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the split out PR: #25184

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I place imports into the "code-imports" section?

@gspencergoog gspencergoog Jan 7, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?).

@gspencergoog

Copy link
Copy Markdown
Contributor

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

@zoechi zoechi added the d: api docs Issues with https://api.flutter.dev/ label Dec 11, 2018
@jonahwilliams

Copy link
Copy Markdown
Contributor Author

cc @gspencergoog, it seems I'm not able to use a flutter/* import. Tried relative imports too.

dart ./dev/bots/analyze.dart
⏩ RUNNING: cd examples/hello_world; ../../bin/flutter inject-plugins
🕐 ELAPSED TIME: 0:00:00.969990 for ../../bin/flutter inject-plugins in examples/hello_world:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
An error was detected when looking at import dependencies within the Flutter package:

One of the files in the services package imports that package recursively.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

@gspencergoog

Copy link
Copy Markdown
Contributor

Ooh, exciting. OK, let me take a look.

@gspencergoog

Copy link
Copy Markdown
Contributor

This is a result of an overly broad RegExp in flutter's analysis bot script.

I created a PR to fix it: #26539

@jonahwilliams
jonahwilliams merged commit fb2467d into flutter:master Jan 17, 2019
@jonahwilliams
jonahwilliams deleted the system_chrome_doc branch January 17, 2019 17:30
kangwang1988 pushed a commit to XianyuTech/flutter that referenced this pull request Feb 12, 2019
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

d: api docs Issues with https://api.flutter.dev/ framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants