Skip to content

Instantly share code, notes, and snippets.

@Maistho
Last active May 7, 2022 22:01
Show Gist options
  • Save Maistho/b22671df77b681e72f6ec8b3d193c42c to your computer and use it in GitHub Desktop.
Save Maistho/b22671df77b681e72f6ec8b3d193c42c to your computer and use it in GitHub Desktop.
Crash reproduction for flutter bug
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('It will crash after 5 seconds')),
body: CustomScrollView(
slivers: [
FutureBuilder<String>(
future: Future.delayed(const Duration(seconds: 5), () => "Crash"),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const SliverToBoxAdapter(
child: SizedBox(),
);
}
return SliverList(
delegate: SliverChildListDelegate.fixed([
Text(snapshot.data!),
]),
);
},
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment