content: import 'dart:math';
  
  import 'package:adaptive_master_detail_layouts/item.dart';
  import 'package:adaptive_master_detail_layouts/item_details.dart';
  import 'package:adaptive_master_detail_layouts/item_listing.dart';
  import 'package:flutter/material.dart';
  
  class MasterDetailContainer extends StatefulWidget {
    @override
    _ItemMasterDetailContainerState createState() =>
        _ItemMasterDetailContainerState();
  }
  
  class _ItemMasterDetailContainerState extends State<MasterDetailContainer> {
    static const int kTabletBreakpoint = 600;
  
    Item _selectedItem;
  
    Widget _buildMobileLayout() {
      return ItemListing(
        itemSelectedCallback: (item) {
          Navigator.push(
            context,
            MaterialPageRoute(
              builder: (BuildContext context) {
                return ItemDetails(
                  isInTabletLayout: false,
                  item: item,
                );
              },
            ),
          );
        },
      );
    }
  
    Widget _buildTabletLayout() {
      return Row(
        children: <Widget>[
          Flexible(
            flex: 1,
            child: Material(
              elevation: 4.0,
              child: ItemListing(
                itemSelectedCallback: (item) {
                  setState(() {
                    _selectedItem = item;
                  });
                },
                selectedItem: _selectedItem,
              ),
            ),
          ),
          Flexible(
            flex: 3,
            child: ItemDetails(
              isInTabletLayout: true,
              item: _selectedItem,
            ),
          ),
        ],
      );
    }
  
    @override
    Widget build(BuildContext context) {
      Widget content;
      var shortestSide = MediaQuery.of(context).size.shortestSide;
  
      if (shortestSide < kTabletBreakpoint) {
        content = _buildMobileLayout();
      } else {
        content = _buildTabletLayout();
      }
  
      return Scaffold(
        appBar: AppBar(
          title: Text('Master-detail flow sample'),
        ),
        body: content,
      );
    }
  }
  