Skip to content

DaisukeNagata/wheel_expand_list

Repository files navigation

wheel_expand_list

https://pub.dev/packages/wheel_expand_list

Environment

  sdk: '>=2.18.1 <3.0.0'
  flutter: ">=2.5.0"

Example

Construction

Setting location of WheelExample

wheelWidget.loopWidget(
 context,
 wheelLogic.globalKeys,
  wheelLogic.textList,
  wheelLogic.margin,
  wheelLogic.fontSize,
),

Setting location of WheelExample2


wheelWidget.loopWidget(
  context,
  wheelLogic.globalKeysLists[i],
  wheelLogic.textLists[i],
  wheelLogic.margin,
  wheelLogic.fontSize,
),

Your favorite design will be reflected in the Widget.

class WheelWidget implements WheelPrimitiveWidget {
  const WheelWidget({
    required this.logic,
  });
  final WheelLogic logic;
  /*
 *You can set your favorite design.
 * */
  @override
  Widget primitiveWidget(
    BuildContext context,
    String text,
    double margin,
    double fontSize,
  ) {
    return Container(
      width: MediaQuery.of(context).size.width - logic.margin,
      color: Colors.green,

      /// same widget
      child: Card(
        child: ListTile(
          leading: const Icon(Icons.people),
          title: Text(
            text,
            style: TextStyle(
              fontSize: logic.fontSize,
            ),
          ),
        ),
      ),
    );
  }

  /*
  * Used to pre-size the Widget.
  * */
  @override
  Widget loopWidget(
    BuildContext context,
    List<GlobalKey> keys,
    List<String> textList,
    double margin,
    double fontSize,
  ) {
    return SingleChildScrollView(
      child: Column(
        children: [
          for (var i = 0; i < keys.length; i++) ...[
            setSizeWidget(
              context,
              keys[i],
              textList[i],
              margin,
              fontSize,
            ),
          ],
        ],
      ),
    );
  }

  /*
  * Used to pre-size the Widget.
  * */
  @override
  Widget setSizeWidget(
    BuildContext context,
    GlobalKey<State<StatefulWidget>> key,
    String text,
    double margin,
    double fontSize,
  ) {
    return IgnorePointer(
      ignoring: true,
      child: SafeArea(
        child: Container(
          key: key,
          alignment: Alignment.topLeft,
          width: MediaQuery.of(context).size.width - margin,
          child: AnimatedOpacity(
            duration: const Duration(milliseconds: 1),
            opacity: 0,

            /// same widget
            child: Card(
              child: ListTile(
                leading: const Icon(Icons.people),
                title: Text(
                  text,
                  style: TextStyle(
                    fontSize: logic.fontSize,
                  ),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}