Skip to content

Conversation

@tvolkert
Copy link
Contributor

Description

Based on a survey of usage, it appears that the ratio is about
3:1 of callers that create StreamBuilder without initial
data to callers that create StreamBuilder with initial data.
Given this, the updated API will break fewer callers if we swap
the semantics of the two constructors:

Before

StreamBuilder(
  @required T initialData,
  ...
)

StreamBuilder.withoutInitialData(
  ...
)

After

StreamBuilder(
  ...
)

StreamBuilder.withInitialData(
  @required T initialData,
  ...
)

This also allows us to provide a softer transition period by
deprecating the initialData argument to the default constructor.
During this deprecation period, null values will be interpreted as
"no initial data".

Related Issues

#34545

Tests

I updated the existing tests to reflect the switch.

Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Based on a survey of usage, it appears that the ratio is about
3:1 of callers that create `StreamBuilder` _without_ initial
data to callers that create `StreamBuilder` _with_ initial data.
Given this, the updated API will break fewer callers if we swap
the semantics of the two constructors:

**Before**
```dart
StreamBuilder(
  @required T initialData,
  ...
)

StreamBuilder.withoutInitialData(
  ...
)
```

**After**
```dart
StreamBuilder(
  ...
)

StreamBuilder.withInitialData(
  @required T initialData,
  ...
)
```

This also allows us to provide a softer transition period by
deprecating the `initialData` argument to the default constructor.
During this deprecation period, null values will be interpreted as
"no initial data".

#34545
@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label Jul 19, 2019
@tvolkert tvolkert requested a review from Hixie July 19, 2019 23:05
@Hixie
Copy link
Contributor

Hixie commented Jul 19, 2019

LGTM

@tvolkert
Copy link
Contributor Author

Closing since I reverted the original change.

@tvolkert tvolkert closed this Jul 22, 2019
@tvolkert tvolkert deleted the follow-on-stream-builder branch July 22, 2019 01:01
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants