Re: Help me. When add ListView.builder() hot restart/ hot reload take too long

247 views
Skip to first unread message

Souvik Dutta

unread,
Apr 14, 2020, 9:21:56 AM4/14/20
to Adam, Flutter Development (flutter-dev)
Have you ever built an app with your machine? If not then connect your machine to the internet. What is your machines configuration? 

On Tue, 14 Apr, 2020, 6:46 pm Adam, <anggaca...@gmail.com> wrote:
please review my code. i want to try ListView.builder. there are no error but can not run the app (still loading). my reference is here: https://flutter.dev/docs/get-started/codelab 

import 'package:english_words/english_words.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class testApp extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _testApp();
}
}

class _testApp extends State<testApp> {
final _suggestions = <WordPair>[];
final _biggerFont = const TextStyle(fontSize: 18.0);

Widget _buildRow(WordPair pair) {
return ListTile(
title: Text(
pair.asPascalCase,
style: _biggerFont,
),
);
}

Widget _buildSuggestions() {
return ListView.builder(
shrinkWrap: true,
padding: const EdgeInsets.all(16.0),
itemBuilder: /*1*/ (context, i) {
if (i.isOdd) return Divider();
/*2*/

final index = i ~/ 2; /*3*/
if (index >= _suggestions.length) {
_suggestions.addAll(generateWordPairs().take(10)); /*4*/
}
return _buildRow(_suggestions[index]);
});
}

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Aplikasi',
home: Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
textDirection: TextDirection.ltr,
children: <Widget>[
Text('Hello World'),
Padding(
padding: EdgeInsets.all(20),
child: Text('Hello World'),
),
Text('Hello World'),
Text('Hello World'),
Card(
color: Colors.yellow,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ListTile(
leading: Icon(Icons.fastfood),
title: Text('Angga Arya Saputra'),
subtitle: Text('Ini subtitle nya'),
),
ListTile(
leading: Icon(Icons.fastfood),
title: Text('Angga Arya Saputra'),
subtitle: Text('Ini subtitle nya'),
),
ListTile(
leading: Icon(Icons.fastfood),
title: Text('Angga Arya Saputra'),
subtitle: Text('Ini subtitle nya'),
),
],
)),
Padding(
padding: EdgeInsets.fromLTRB(8, 14, 8, 14),
child: Card(
color: Colors.blueGrey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ListTile(
leading: Icon(Icons.fastfood),
title: Text('Angga Arya Saputra'),
subtitle: Text('Ini subtitle nya'),
),
ListTile(
leading: Icon(Icons.fastfood),
title: Text('Angga Arya Saputra'),
subtitle: Text('Ini subtitle nya'),
),
],
)),
),
_buildSuggestions(), //i want to add ListView.builder()

])),
);
}}

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/87851f41-65d4-4012-91d4-5a92d48d11c2%40googlegroups.com.

Adam

unread,
Apr 14, 2020, 9:43:27 AM4/14/20
to Flutter Development (flutter-dev)
yes, i have connect to the internet. the build is complete now. but it just show blank white. no error message in Android studio too. may you try to run my code in your machine?

Suzuki Tomohiro

unread,
Apr 14, 2020, 9:49:55 AM4/14/20
to Flutter Development (flutter-dev)
(I don’t run other people’s code)

> blank white

No “Hello world” message in the column?
What happens if you remove _buildSuggestions from the column?

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

Adam

unread,
Apr 14, 2020, 9:53:44 AM4/14/20
to Flutter Development (flutter-dev)
if i remove  _buildSuggestions from the column, everything is OK. i dont know why


Pada Selasa, 14 April 2020 20.49.55 UTC+7, Suzuki Tomohiro menulis:
(I don’t run other people’s code)

> blank white

No “Hello world” message in the column?
What happens if you remove _buildSuggestions from the column?
On Tue, Apr 14, 2020 at 9:43 AM Adam <anggaca...@gmail.com> wrote:
yes, i have connect to the internet. the build is complete now. but it just show blank white. no error message in Android studio too. may you try to run my code in your machine?

Pada Selasa, 14 April 2020 20.21.56 UTC+7, Souvik Dutta menulis:
Have you ever built an app with your machine? If not then connect your machine to the internet. What is your machines configuration? 

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.

Souvik Dutta

unread,
Apr 14, 2020, 9:56:45 AM4/14/20
to Adam, Flutter Development (flutter-dev)
I understood!! Did you wrap the listview.builder in a container or similar? It is needed because without this your listview is stretching infinitely.

Souvik flutter dev

To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/36fdf4e1-3056-42ac-9058-6b45ac7df140%40googlegroups.com.

Suzuki Tomohiro

unread,
Apr 14, 2020, 9:57:52 AM4/14/20
to Flutter Development (flutter-dev)
I believe you’re hitting “ Horizontal viewport was given unbounded height. ” problem. But I’m not sure why you don’t see any error message.

To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/36fdf4e1-3056-42ac-9058-6b45ac7df140%40googlegroups.com.

Souvik Dutta

unread,
Apr 14, 2020, 9:58:01 AM4/14/20
to Adam, Flutter Development (flutter-dev)
You will also be needed to set a max height.

Adam

unread,
Apr 14, 2020, 10:00:21 AM4/14/20
to Flutter Development (flutter-dev)
i have simplyfy the code:

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Aplikasi',
home: Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
textDirection: TextDirection.ltr,
children: <Widget>[
Text('Hello World'),
              Text('Hello World 2'),
_buildSuggestions(),



and  _buildSuggestions(),
in the column make hot reload and hot restart take too long. if i remove that, everything is OK


Pada Selasa, 14 April 2020 20.21.56 UTC+7, Souvik Dutta menulis:
To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.

Adam

unread,
Apr 14, 2020, 10:02:39 AM4/14/20
to Flutter Development (flutter-dev)

flutter_listview.png


here is the preview when i am not adding ListView.builder()

Adam

unread,
Apr 14, 2020, 10:12:48 AM4/14/20
to Flutter Development (flutter-dev)

flutter_listview_solved.png

 
Ok guys, using
 Expanded()

solve the problem. I think we can just use
shrinkWrap: true

reference: https://stackoverflow.com/questions/54007073/what-does-the-shrink-wrap-property-do-in-flutter/54008230
 

 

 

Souvik Dutta

unread,
Apr 14, 2020, 11:00:52 AM4/14/20
to Adam, Flutter Development (flutter-dev)
Great!! You could have also used a container with a max height specified.

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages