我找不到要折叠或展开子小部件的小部件

I can't find widget to fold or expand children widget

抱歉因为先注册无法上传img。所以我得到了 link

https://getbootstrap.com/docs/3.3/javascript/#collapse

喜欢这个功能,

我想在平时制作小部件,只有父小部件显示它们的形状, 但如果我按下父小部件,它的子小部件会在其形状下显示它们的形状。 但我找不到小部件来获得此功能。 你能告诉我小部件吗? 或者我可以用动画解决这个问题吗?

我找Whosebug,flutter文档。但我找不到

您可以为此使用 ExpansionTile 小部件。参考下面的代码希望对你有帮助。

ExpansionTile(
          title: Text('Collapsible Group Item #1'),
          children: <Widget>[
            ListTile(
              title: Text(
                'Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus'
                'terry richardson ad squid. 3 wolf moon officia aute,'
                'non cupidatat skateboard dolor brunch. Food truck quinoa'
                'nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put'
                'a bird on it squid single-origin coffee nulla assumenda shoreditch et.'
                'Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred'
                'nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo.'
                'Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt'
                'you probably havent heard of them accusamus labore sustainable VHS.',
              ),
            ),
          ],
        ),

完整代码:

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: const MyStatefulWidget(),
      ),
    );
  }
}

class MyStatefulWidget extends StatefulWidget {
  const MyStatefulWidget({Key? key}) : super(key: key);

  @override
  State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
  bool _customTileExpanded = false;

  @override
  Widget build(BuildContext context) {
    return const ExpansionTile(
      title: Text('Collapsible Group Item #1'),
      children: <Widget>[
        ListTile(
          title: Text(
            'Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus'
            'terry richardson ad squid. 3 wolf moon officia aute,'
            'non cupidatat skateboard dolor brunch. Food truck quinoa'
            'nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put'
            'a bird on it squid single-origin coffee nulla assumenda shoreditch et.'
            'Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred'
            'nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo.'
            'Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt'
            'you probably havent heard of them accusamus labore sustainable VHS.',
          ),
        ),
      ],
    );
  }
}

您可以在 Dartpad

上测试您的代码

您的结果屏幕->