Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HansMuller/f35aeae7ac44225d8b831f5e4749c0e1 to your computer and use it in GitHub Desktop.
Save HansMuller/f35aeae7ac44225d8b831f5e4749c0e1 to your computer and use it in GitHub Desktop.
// listview in alert dialog error
// https://github.com/flutter/flutter/issues/18108
import 'package:flutter/material.dart';
void main() {
runApp(
new MaterialApp(
theme: new ThemeData(
brightness: Brightness.dark,
primaryColor: Colors.amber,
accentColor: Colors.red),
home: new Test(),
),
);
}
class Test extends StatelessWidget {
final List<String> values = ["1", "2", "3"];
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Center(
child: const Text('TEST', style: const TextStyle(color: Colors.white)),
),
),
body: new FloatingActionButton(
child: new Icon(Icons.cancel),
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return new AlertDialog(
title: new Text("test"),
content: new ListView.builder(
itemCount: values.length,
itemBuilder: (BuildContext buildContext, int index) => new Text(values[index]),
shrinkWrap: true,
),
);
},
);
},
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment