Flutterの勉強がてらTwitterのアプリもどきを作っています。
Flutterのリストビューの中で長過ぎるテキストの場合、折返しまたは...にしたいです。
添付の画像で黄色い警告になってる箇所はtweetObject['full_text'] の表示箇所です。
添付の画像のソースは一部除いてますが以下の通りです。
Dart
1class _HomeTimelineState extends State<HomeTimeline> 2{ 3 final List<Widget> _tweets = []; 4 // initState()から呼ばれる関数 5 Future<void> _displayHomeTimeline() async 6 { 7 // DBからツィートを読み込む 8 final List<Map<String, dynamic>> tweets = await database.rawQuery(sql); 9 setState(() { 10 for (int i = 0; i < tweets.length; ++i) { 11 // webからユーザ画像を取る関数.ローカルに保存したパスを返す 12 Imager.load(userObject['profile_image_url_https'] as String, (String path) { 13 Card( 14 child: Row( 15 children: [ 16 // アイコン 17 Image.file(File(path)), 18 Column( 19 children: <Widget>[ 20 // ツィート本文 21 Text(tweetObject['full_text'] as String), 22 ] 23 ) 24 ] 25 ) 26 ) 27 }); 28 } 29 }); 30 } 31 32 Widget build(BuildContext context) 33 { 34 return Scaffold( 35 appBar: const EmptyAppBar(), 36 body: NotificationListener<ScrollNotification> ( 37 child: ListView.builder( 38 shrinkWrap: true, 39 itemCount: _tweets.length, 40 itemBuilder: (context, index) { 41 return _tweets[index]; 42 }, 43 ), 44 onNotification: (ScrollNotification notification) { 45 if (notification is OverscrollNotification) { 46 _logger.e(notification); 47 } 48 return true; 49 } 50 ), 51 floatingActionButton: FloatingActionButton( 52 onPressed: () async { 53 }, 54 child: const Icon(Icons.add) 55 ) 56 ); 57 }
やってみたこととして、折り返したい箇所をFlexibleで囲めばいいと記事をみたので、
Text(tweetObject['full_text'] as String)を以下のようにFlexibleで囲ってみたのですが、
エラーがでて真っ白になってしまいました。
Dart
1Flexible(child: Text(tweetObject['full_text'] as String))
エラーメッセージの抜粋
When a column is in a parent that does not provide a finite height constraint, for example if it is in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining space in the vertical direction. These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child cannot simultaneously expand to fit its parent.
ListViewでテキストを折り返す方法と...にする方法を教えて頂けないでしょうか。

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。