Skip to content

Accessing AsyncSnapshot.data should throw if there's an error #34545

@tvolkert

Description

@tvolkert

Steps to reproduce

Run the following app:

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  Stream<int> get stream async* {
    throw StateError('error');
  }

  @override
  Widget build(BuildContext context) {
    return Directionality(
      textDirection: TextDirection.ltr,
      child: StreamBuilder<int>(
        stream: stream,
        builder: (BuildContext context, AsyncSnapshot<int> snapshot) {
          return Text('${snapshot.data}');
        },
      ),
    );
  }
}

Expected behavior

You expect the StateError to show up in the console logs.

Actual behavior

The exception is swallowed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: API breakBackwards-incompatible API changesdependency: dartDart team may need to help usfound in release: 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions