Skip to content

Adds a Listview tile select example#99165

Merged
fluttergithubbot merged 16 commits into
flutter:masterfrom
maheshj01:listview_sample
Mar 8, 2022
Merged

Adds a Listview tile select example#99165
fluttergithubbot merged 16 commits into
flutter:masterfrom
maheshj01:listview_sample

Conversation

@maheshj01

@maheshj01 maheshj01 commented Feb 25, 2022

Copy link
Copy Markdown
Member

This PR fixes #12882 and adds a listview tile example which shows a List of ListTile

  • long press and select a listTile
  • switch between grid view and listView (while persisting state)
  • select all ListTiles of list
  • unselect all ListTiles of list

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@Piinks Piinks left a comment

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.

Thanks for writing this - and including a test! :)

Looks like the file names need a number according to the the other example files.

Also, this won't show up in the api docs if it is not included somewhere, maybe in ListTile?

Here is an example:

/// ** See code in examples/api/lib/widgets/scroll_view/custom_scroll_view.1.dart **

@flutter-dashboard flutter-dashboard Bot added d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos documentation f: scrolling Viewports, list views, slivers, etc. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Feb 28, 2022
@maheshj01

Copy link
Copy Markdown
Member Author

Thanks for the review @Piinks I have renamed the file and linked the example in the comments here.

/// ## Selection of list items
///
/// `ListView` has no built-in notion of a selected item or items. For a small
/// example of how a caller might wire up basic item selection, see
/// [ListTile.selected].
///

I thought this was the right place Since this section already talks about selecting ListItems. Let me know if you think this should be included somewhere else.

Thanks

@Piinks Piinks left a comment

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.

Thanks for the update!

Comment on lines 1012 to 1013

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.

This should be included in a {@tool dartpad... like the other example. :)
That is what makes the sample in the api docs interactive.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure thing !
Done.

Comment thread packages/flutter/lib/src/widgets/scroll_view.dart Outdated

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.

Suggested change
// Flutter code sample for ListView
// Flutter code sample for ListTile selection.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

Comment on lines 90 to 91

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.

Does this get clipped, or does the text all fit in the app bar?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The text fits in appBar the title has ellipses

image

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.

The clipping of the title is not ideal, can you update to something shorter?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure, Changed to "ListTile selection"

image

Comment on lines 126 to 130

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.

Nit: Is this dart format? It looks a bit off.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I guess yes, I am using vs code which uses the default formatter which formats the code on save.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Probably this is resolved now

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.

Can we avoid using ignores in sample code? We consider ignores in code as technical debt, things that need to be fixed. Since this is meant to be instructive it probably should not have an ignore.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If I remove that the linter warns

This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: GridBuilder.isSelectionMode

to fix this warning if I make isSelectionMode as final then I get a syntax error on line 167, since I am reassiging the value

widget.isSelectionMode = true;

if I mark isSelectionMode as late I get a warning to make GrIdBuilder const if I mark it as const I get syntax error to remove late

Can't have a late final field in a class with a generative const constructor.
Try removing the 'late' modifier, or don't declare 'const' constructors.

and this continues in a cycle. This is same for ListBuilder as the widgets are Identical.

if this is necessary to get rid of the ignores I can fix that by toggling isSelectionMode out of the widget.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

updated code sample

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.

Same here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is fixed now

@Piinks Piinks left a comment

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.

Flutter_LGTM

Thank you!

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 9, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 9, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 9, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 9, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 9, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 10, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 10, 2022
ditman added a commit to ditman/flutter-packages that referenced this pull request Mar 10, 2022
Roll Flutter from 38dbbb1 to 0dfb656 (135 revisions)

flutter/flutter@38dbbb1...0dfb656

2022-03-10 engine-flutter-autoroll@skia.org Roll Engine from bf2bf3a3fd2b to 6b1a24b1a108 (10 revisions) (flutter/flutter#99917)
2022-03-10 engine-flutter-autoroll@skia.org Roll Plugins from eb6ad34 to 20e231b (8 revisions) (flutter/flutter#99913)
2022-03-10 engine-flutter-autoroll@skia.org Roll Engine from 2c1816b39127 to bf2bf3a3fd2b (3 revisions) (flutter/flutter#99887)
2022-03-10 darrenaustin@google.com Migrate NavigationRail to Material 3. (flutter/flutter#99171)
2022-03-10 katelovett@google.com Remove expired ThemeData deprecations (flutter/flutter#98578)
2022-03-09 engine-flutter-autoroll@skia.org Roll Engine from 09a11d137953 to 2c1816b39127 (3 revisions) (flutter/flutter#99878)
2022-03-09 chillers@google.com [ci.yaml] Remove unused benchmark property (flutter/flutter#99843)
2022-03-09 591699+clocksmith@users.noreply.github.com [Material] Create an InkSparkle splash effect that matches the Material 3 ripple effect (flutter/flutter#99731)
2022-03-09 katelovett@google.com Remove deprecated RenderEditable.onSelectionChanged (flutter/flutter#98582)
2022-03-09 fluttergithubbot@gmail.com Marks Mac_ios post_backdrop_filter_perf_ios__timeline_summary to be flaky (flutter/flutter#99856)
2022-03-09 engine-flutter-autoroll@skia.org Roll Engine from 6d7bcc9e577c to 09a11d137953 (3 revisions) (flutter/flutter#99870)
2022-03-09 ychris@google.com [tool] Add CADisableMinimumFrameDurationOnPhone to iOS templates (flutter/flutter#94509)
2022-03-09 jeff@fuzzybinary.com First pass at using platform abstraction for plugins (flutter/flutter#92672)
2022-03-09 darrenaustin@google.com Fix `ColorScheme.shadow` to default to black even for dark themes. (flutter/flutter#99722)
2022-03-09 engine-flutter-autoroll@skia.org Roll Engine from a0963f14b67d to 6d7bcc9e577c (3 revisions) (flutter/flutter#99847)
2022-03-09 darrenaustin@google.com Updated tokens to v0.90. (flutter/flutter#99782)
2022-03-09 fluttergithubbot@gmail.com Marks Mac_ios backdrop_filter_perf_ios__timeline_summary to be unflaky (flutter/flutter#99836)
2022-03-09 jmccandless@google.com updateEditingValueWithDeltas snippet docs fix (flutter/flutter#99570)
2022-03-09 engine-flutter-autoroll@skia.org Roll Engine from 9362061fbb79 to a0963f14b67d (1 revision) (flutter/flutter#99838)
2022-03-09 engine-flutter-autoroll@skia.org Roll Plugins from b906ea5 to eb6ad34 (9 revisions) (flutter/flutter#99828)
2022-03-09 6655696+guidezpl@users.noreply.github.com Update visibility of methods for internal use (flutter/flutter#98124)
2022-03-09 engine-flutter-autoroll@skia.org Roll Engine from 621c88dc2d13 to 9362061fbb79 (6 revisions) (flutter/flutter#99809)
2022-03-09 engine-flutter-autoroll@skia.org Roll Engine from 5c760759feca to 621c88dc2d13 (2 revisions) (flutter/flutter#99792)
2022-03-09 chingjun@google.com Pass 'assume-initialize-from-dill-up-to-date' flag to the frontend server (flutter/flutter#99791)
2022-03-09 alexandre.ardhuin@gmail.com remove unnecessary null check (flutter/flutter#99507)
2022-03-09 31859944+LongCatIsLooong@users.noreply.github.com Avoid calling `performLayout` when only the relayout boundary is different (flutter/flutter#99056)
2022-03-09 zanderso@users.noreply.github.com Revert "Add the refresh rate fields to perf_test (#99710)" (flutter/flutter#99801)
2022-03-09 katelovett@google.com Re-land removal of maxLengthEnforced deprecation (flutter/flutter#99787)
2022-03-09 ychris@google.com Add the refresh rate fields to perf_test (flutter/flutter#99710)
2022-03-09 magder@google.com Remove tool crash git.io link shortener (flutter/flutter#99574)
2022-03-09 brunotacca@gmail.com 95533 min sdk error msgs enhancements (flutter/flutter#99550)
2022-03-08 katelovett@google.com Remove deprecated OutlineButton (flutter/flutter#98546)
2022-03-08 Phelicks@users.noreply.github.com [flutter_tools] Fix Typo in tool error message (flutter/flutter#97793)
2022-03-08 magder@google.com Handle hidden dot files in iOS framework bundles (flutter/flutter#99771)
2022-03-08 darrenaustin@google.com Updated tokens to v0.88. (flutter/flutter#99568)
2022-03-08 katelovett@google.com Revert "Remove deprecated CupertinoTextField, TextField, TextFormField maxLengthEnforced" (flutter/flutter#99768)
2022-03-08 andreidiaconu@users.noreply.github.com Add Foldable support for modal routes (flutter/flutter#92909)
2022-03-08 engine-flutter-autoroll@skia.org Roll Plugins from 675f91b to b906ea5 (4 revisions) (flutter/flutter#99765)
2022-03-08 engine-flutter-autoroll@skia.org Roll Engine from 0fed94d050b1 to 5c760759feca (1 revision) (flutter/flutter#99751)
2022-03-08 31410839+maheshmnj@users.noreply.github.com Fix: Date picker interactive sample not loading  (flutter/flutter#99401)
2022-03-08 chris@bracken.jp Check string size before Win32 MultiByte <-> WideChar conversions (flutter/flutter#99729)
2022-03-08 engine-flutter-autoroll@skia.org Roll Engine from 9c3f73864029 to 0fed94d050b1 (6 revisions) (flutter/flutter#99728)
2022-03-08 31410839+maheshmnj@users.noreply.github.com Adds a Listview tile select example (flutter/flutter#99165)
2022-03-08 katelovett@google.com Remove deprecated CupertinoTextField, TextField, TextFormField maxLengthEnforced (flutter/flutter#98539)
2022-03-08 engine-flutter-autoroll@skia.org Roll Engine from 9e1594bd741f to 9c3f73864029 (2 revisions) (flutter/flutter#99721)
2022-03-08 49699333+dependabot[bot]@users.noreply.github.com Bump debian from bullseye-20220125-slim to bullseye-20220228-slim in /dev/ci/docker_linux (flutter/flutter#99708)
...
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: scrolling Viewports, list views, slivers, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a ListTile selection-mode example

3 participants