Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add length and Type judgment #41

Closed
wants to merge 1 commit into from

Conversation

shang1219178163
Copy link

No description provided.

@shang1219178163
Copy link
Author

add length and Type judgment

@devoncarew
Copy link
Collaborator

Thanks for the PR! Can you provide your use case(s) and or examples of how these would be used? Additionally, these changes are logically two separate things, and should be each in their own PRs.

@devoncarew
Copy link
Collaborator

And FYI, this package will almost certainly soon go into a maintence mode, as we're about to ship 1st class support for records in Dart.

https://github.com/dart-lang/language/blob/master/accepted/future-releases/records/records-feature-specification.md

https://medium.com/dartlang/dart-3-alpha-f1458fb9d232

@shang1219178163
Copy link
Author

shang1219178163 commented Mar 7, 2023

Like this, dynamic use Tuple2, Tuple3, Tuple4, Tuple5, Tuple6, Tuple7;
attention to tips variable and items variable;

class _MediaQueryDemoState extends State<MediaQueryDemo> {

  final tips = [
    Tuple3("", “hide keyborad”, “show keyborad"),
    Tuple3("viewInsets", "EdgeInsets.zero", "EdgeInsets(0.0, 0.0, 0.0, 336.0)"),
    Tuple3("viewPadding", "EdgeInsets(0.0, 47.0, 0.0, 34.0)", "EdgeInsets(0.0, 47.0, 0.0, 34.0)"),
    Tuple3("padding", "EdgeInsets(0.0, 47.0, 0.0, 34.0)", "EdgeInsets(0.0, 47.0, 0.0, 0.0)"),
  ];

  final items = [
    Tuple2(“property, “tip”),
    Tuple2("size", "逻辑像素,并不是物理像素,类似于Android中的dp,逻辑像素会在不同大小的手机上显示的大小基本一样,物理像素 = size*devicePixelRatio。"),
    Tuple2("devicePixelRatio", "单位逻辑像素的物理像素数量,即设备像素比。"),
    Tuple2("textScaleFactor", "单位逻辑像素字体像素数,如果设置为1.5则比指定的字体大50%。"),
  ];

…

      body: SafeArea(
        child: CustomScrollView(
          slivers: [
            buildTable(rows: _renderTuples(items: tips)),
            Divider(),
            buildTable(rows: _renderTuples(items: items)),
          ].map((e) => e.toSliverToBoxAdapter()).toList(),
        ),
      )
    );
  }


  Widget buildTable({required List<TableRow> rows}) {
    return Table(
      columnWidths: <int, TableColumnWidth>{
        0: IntrinsicColumnWidth(),
        1: FlexColumnWidth(80),
        2: FlexColumnWidth(80),
      },
      defaultVerticalAlignment: TableCellVerticalAlignment.middle,
      border: TableBorder.all(
        color: Colors.green,
        width: 1,
        style: BorderStyle.solid,
      ),
      children: rows,
    );
  }

  List<TableRow> _renderTuples({List items = const []}) {
    if (items.length == 0 || !isTuple(items[0])) {
      return [];
    }

    return items.map((e) => TableRow(
      children: List.generate(e.length, (index) => Container(
        padding: EdgeInsets.all(8),
        child: Text(e.toList()[index]),
      )).toList(),
    )).toList();
  }

}

@devoncarew
Copy link
Collaborator

Thanks for the contribution and the description of use cases in the PR.

However, with the recent release of Dart 3.0 and its support for Records, we plan to move this package into maintenance mode; not take any enhancements to it, and just maintain it from the POV of bug fixes / CI updates to keep it working. There's more detail in the related issue: #47; feel free to follow up there with any questions or comments.

@devoncarew devoncarew closed this Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants