<commit_before>import 'package:flutter/material.dart';

class CardContainer extends StatelessWidget {
  const CardContainer(
      {Key key,
      @required this.title,
      @required this.isLoading,
      @required this.reload,
      @required this.errorText,
      @required this.child,
      @required this.hidden,
      this.overFlowMenu,
      this.actionButtons})
      : super(key: key);

  /// required parameters
  final Widget title;
  final bool isLoading;
  final bool hidden;
  final Function reload;
  final Widget child;
  final String errorText;

  /// optional parameters
  final Map<String, Function> overFlowMenu;
  final List<Widget> actionButtons;

  @override
  Widget build(BuildContext context) {
    if (!hidden) {
      return Card(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            ListTile(
              title: title,
              trailing: ButtonTheme.bar(
                // make buttons use the appropriate styles for cards
                child: ButtonBar(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    buildMenu({
                      'reload': reload,
                      'hide': () {/* insert hide function*/}
                    }),
                  ],
                ),
              ),
            ),
            buildBody(),
            actionButtons != null
                ? Row(
                    children: actionButtons,
                  )
                : Container()
          ],
        ),
      );
    }
    return Container();
  }

  Widget buildBody() {
    if (errorText != null) {
      return Text(errorText);
    } else if (isLoading) {
      return CircularProgressIndicator();
    } else {
      return Container(
        constraints: BoxConstraints(maxHeight: 224),
        child: child,
      );
    }
  }

  Widget buildMenu(Map<String, Function> menuOptions) {
    List<DropdownMenuItem<String>> menu = List<DropdownMenuItem<String>>();
    menuOptions.forEach((menuOption, func) {
      Widget item = DropdownMenuItem<String>(
        value: menuOption,
        child: Text(
          menuOption,
          textAlign: TextAlign.center,
        ),
      );
      menu.add(item);
    });
    return DropdownButton(
      items: menu,
      icon: Flexible(
        child: Center(
          child: Icon(Icons.more_vert),
        ),
      ),
      onChanged: (String selectedMenuItem) =>
          onMenuItemPressed(selectedMenuItem),
    );
  }

  void onMenuItemPressed(String selectedMenuItem) {
    switch (selectedMenuItem) {
      case 'reload':
        {<commit_msg>update card constraints and fix dropdown menu button ui<commit_after>import 'package:flutter/material.dart';

class CardContainer extends StatelessWidget {
  const CardContainer(
      {Key key,
      @required this.title,
      @required this.isLoading,
      @required this.reload,
      @required this.errorText,
      @required this.child,
      @required this.hidden,
      this.overFlowMenu,
      this.actionButtons})
      : super(key: key);

  /// required parameters
  final Widget title;
  final bool isLoading;
  final bool hidden;
  final Function reload;
  final Widget child;
  final String errorText;

  /// optional parameters
  final Map<String, Function> overFlowMenu;
  final List<Widget> actionButtons;

  @override
  Widget build(BuildContext context) {
    if (!hidden) {
      return Card(
        semanticContainer: false,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            ListTile(
              title: title,
              trailing: ButtonTheme.bar(
                // make buttons use the appropriate styles for cards
                child: ButtonBar(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    buildMenu({
                      'reload': reload,
                      'hide': () {/* insert hide function*/}
                    }),
                  ],
                ),
              ),
            ),
            buildBody(),
            actionButtons != null
                ? Row(
                    children: actionButtons,
                  )
                : Container()
          ],
        ),
      );
    }
    return Container();
  }

  Widget buildBody() {
    if (errorText != null) {
      return Text(errorText);
    } else if (isLoading) {
      return Container(
          height: 224, width: 224, child: CircularProgressIndicator());
    } else {
      return Container(
        constraints: BoxConstraints(maxHeight: 224, maxWidth: 406),
        child: child,
      );
    }
  }

  Widget buildMenu(Map<String, Function> menuOptions) {
    List<DropdownMenuItem<String>> menu = List<DropdownMenuItem<String>>();
    menuOptions.forEach((menuOption, func) {
      Widget item = DropdownMenuItem<String>(
        value: menuOption,
        child: Text(
          menuOption,
          textAlign: TextAlign.center,
        ),
      );
      menu.add(item);
    });
    return DropdownButton(
      items: menu,
      underline: Container(),
      icon: Icon(Icons.more_vert),
      onChanged: (String selectedMenuItem) =>
          onMenuItemPressed(selectedMenuItem),
    );
  }

  void onMenuItemPressed(String selectedMenuItem) {
    switch (selectedMenuItem) {
      case 'reload':
        {
{'fraction_non_alphanumeric': 0.0972963031083318, 'fraction_numerical': 0.0027588743792532648, 'mean_word_length': 1.7759060745278203, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, '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': '6188746', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1384, 'n_words': 344}