<commit_before>// Copyright 2016 The Chromium 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/foundation.dart';

import 'basic.dart';
import 'framework.dart';
import 'layout_builder.dart';
import 'media_query.dart';

/// Signature for a function that builds a widget given an [Orientation].
///
/// Used by [OrientationBuilder.builder].
typedef Widget OrientationWidgetBuilder(BuildContext context, Orientation orientation);

/// Builds a widget tree that can depend on the parent widget's orientation.
///
/// See also:
///
/// * [LayoutBuilder], which exposes the complete constraints, not just the
///   orientation.
/// * [CustomSingleChildLayout], which positions its child during layout.
/// * [CustomMultiChildLayout], with which you can define the precise layout
///   of a list of children during the layout phase.
class OrientationBuilder extends StatelessWidget {
  /// Creates an orientation builder.
  ///
  /// The [builder] argument must not be null.
  const OrientationBuilder({
    Key key,
    @required this.builder,
  }) : assert(builder != null),
       super(key: key);

  /// Builds the widgets below this widget given this widget's orientation.
  final OrientationWidgetBuilder builder;

  Widget _buildWithConstraints(BuildContext context, BoxConstraints constraints) {
    // If the constraints are fully unbounded (i.e., maxWidth and maxHeight are
    // both infinite), we prefer Orientation.portrait because its more common to
    // scroll vertially than horizontally.
    final Orientation orientation = constraints.maxWidth > constraints.maxHeight ? Orientation.landscape : Orientation.portrait;
    return builder(context, orientation);
  }

  @override
  Widget build(BuildContext context) {
    return new LayoutBuilder(builder: _buildWithConstraints);
  }
}
<commit_msg>Add more docs to `OrientationBuilder` (#11233)<commit_after>// Copyright 2016 The Chromium 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/foundation.dart';

import 'basic.dart';
import 'framework.dart';
import 'layout_builder.dart';
import 'media_query.dart';

/// Signature for a function that builds a widget given an [Orientation].
///
/// Used by [OrientationBuilder.builder].
typedef Widget OrientationWidgetBuilder(BuildContext context, Orientation orientation);

/// Builds a widget tree that can depend on the parent widget's orientation
/// (distinct from the device orientation).
///
/// See also:
///
/// * [LayoutBuilder], which exposes the complete constraints, not just the
///   orientation.
/// * [CustomSingleChildLayout], which positions its child during layout.
/// * [CustomMultiChildLayout], with which you can define the precise layout
///   of a list of children during the layout phase.
class OrientationBuilder extends StatelessWidget {
  /// Creates an orientation builder.
  ///
  /// The [builder] argument must not be null.
  const OrientationBuilder({
    Key key,
    @required this.builder,
  }) : assert(builder != null),
       super(key: key);

  /// Builds the widgets below this widget given this widget's orientation.
  ///
  /// A widget's orientation is simply a factor of its width relative to its
  /// height. For example, a [Column] widget will have a landscape orientation
  /// if its width exceeds its height, even though it displays its children in
  /// a vertical array.
  final OrientationWidgetBuilder builder;

  Widget _buildWithConstraints(BuildContext context, BoxConstraints constraints) {
    // If the constraints are fully unbounded (i.e., maxWidth and maxHeight are
    // both infinite), we prefer Orientation.portrait because its more common to
    // scroll vertially than horizontally.
    final Orientation orientation = constraints.maxWidth > constraints.maxHeight ? Orientation.landscape : Orientation.portrait;
    return builder(context, orientation);
  }

  @override
  Widget build(BuildContext context) {
    return new LayoutBuilder(builder: _buildWithConstraints);
  }
}

{'fraction_non_alphanumeric': 0.09437125748502995, 'fraction_numerical': 0.0031137724550898203, 'mean_word_length': 3.783505154639175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7586929', 'n_tokens_mistral': 1095, 'n_tokens_neox': 1029, 'n_words': 436}