有一个数据表的页面在Flutter 动,我想放大和缩小这个表格或页面用两个手指.有谁能提供解决方案吗? 我在这里的主要目标只是放大和缩小.有没有小工具可以实现这一点?我找不到办法,我能做什么?你能帮帮我吗?

There is a video in the link

我已经在下面指定了我的所有表代码.您可以查看并了解详细信息 here are my codes

ListView(children: <Widget>[
              SizedBox(
                width: double.infinity,
                child: Padding(
                  padding: EdgeInsets.fromLTRB(size.width * 0.03,
                      size.width * 0.1, size.width * 0.03, size.width * 0.00),
                  child: TextField(
                    cursorColor: BaseData.vadenHomeSiyah,
                    controller: txtPaletNo,
                    // focusNode: unitCodeCtrlFocusNode,
                    textAlign: TextAlign.center,
                    decoration: InputDecoration(
                        focusedBorder: OutlineInputBorder(
                          borderSide: const BorderSide(
                              color: Color.fromARGB(255, 0, 0, 0), width: 2.0),
                          borderRadius: BorderRadius.circular(25.0),
                        ),
                        border: UnderlineInputBorder(),
                        labelText: 'Palet No',
                        labelStyle: TextStyle(
                            color: Colors.black, fontSize: size.width * 0.05),
                        filled: true,
                        isDense: true,
                        fillColor: Colors.white.withOpacity(0.2)),

                    //işlemler
                    onSubmitted: (value) {
                      setState(() {
                        paletRaporYuklendimi = true;
                      });
                      seciliPaletRaporGetir();
                    },
                    onChanged: (text) {},
                  ),
                  // TextField(
                  //   controller: searchController,
                  //   decoration: const InputDecoration(
                  //     hintText: 'Ara...',
                  //     border: OutlineInputBorder(),
                  //   ),
                  //   onChanged: _onSearchTextChanged,
                  // ),
                ),
              ),
              Padding(
                padding: EdgeInsets.fromLTRB(size.width * 0.00,
                    size.width * 0.08, size.width * 0.00, size.width * 0.00),
                child: SizedBox(
                  width: MediaQuery.of(context).size.width,
                  child: FittedBox(
                    child: paletRaporYuklendimi
                        ? Center(
                            child: Padding(
                              padding: EdgeInsets.all(size.width * 0.2),
                              child: const CircularProgressIndicator(
                                color: Colors.black,
                              ),
                            ),
                          )
                        : DataTable(
                            dataRowHeight: size.width * 0.4,
                            columns: const <DataColumn>[
                              DataColumn(
                                label: Text(
                                  'Palet No',
                                  style: TextStyle(
                                      fontWeight: FontWeight.w900,
                                      fontSize: 30),
                                ),
                              ),
                              DataColumn(
                                label: Text(
                                  'Paket No',
                                  style: TextStyle(
                                      fontWeight: FontWeight.w900,
                                      fontSize: 30),
                                ),
                              ),
                              DataColumn(
                                label: Text(
                                  'Tarih',
                                  style: TextStyle(
                                      fontWeight: FontWeight.w900,
                                      fontSize: 30),
                                ),
                              ),
                              DataColumn(
                                label: Text(
                                  'Hareket Tip',
                                  style: TextStyle(
                                      fontWeight: FontWeight.w900,
                                      fontSize: 30),
                                ),
                              ),
                              DataColumn(
                                label: Text(
                                  'Hücre Kodu',
                                  style: TextStyle(
                                      fontWeight: FontWeight.w900,
                                      fontSize: 30),
                                ),
                              ),
                              DataColumn(
                                label: Text(
                                  'Hareket Turu',
                                  style: TextStyle(
                                      fontWeight: FontWeight.w900,
                                      fontSize: 30),
                                ),
                              ),
                              DataColumn(
                                label: Text(
                                  'Cari Isim',
                                  style: TextStyle(
                                      fontWeight: FontWeight.w900,
                                      fontSize: 30),
                                ),
                              ),
                            ],
                            rows: List.generate(filterList.length, (index) {
                              final item = filterList[index];
                              return DataRow(
                                cells: [
                                  DataCell(Text(
                                    item.PALETNO ?? "",
                                    style: const TextStyle(
                                        fontWeight: FontWeight.w900,
                                        fontSize: 30),
                                  )),
                                  DataCell(Text(
                                    item.PAKETNO.toString(),
                                    style: const TextStyle(
                                        fontWeight: FontWeight.w900,
                                        fontSize: 30),
                                  )),
                                  DataCell(Text(
                                    item.TARIH ?? "",
                                    style: const TextStyle(
                                        fontWeight: FontWeight.w900,
                                        fontSize: 30),
                                  )),
                                  DataCell(item.HAREKETTIPI == "G"
                                      ? Text(
                                          item.HAREKETTIPI ?? "",
                                          style: const TextStyle(
                                              fontWeight: FontWeight.w900,
                                              fontSize: 30,
                                              color: Colors.green),
                                        )
                                      : Text(
                                          item.HAREKETTIPI ?? "",
                                          style: const TextStyle(
                                              fontWeight: FontWeight.w900,
                                              fontSize: 30,
                                              color: Colors.red),
                                        )),
                                  DataCell(Text(
                                    item.HUCREKODU ?? "",
                                    style: const TextStyle(
                                        fontWeight: FontWeight.w900,
                                        fontSize: 30),
                                  )),
                                  DataCell(Text(
                                    item.HAREKETTURU ?? "",
                                    style: const TextStyle(
                                        fontWeight: FontWeight.w900,
                                        fontSize: 30),
                                  )),
                                  DataCell(Text(
                                    item.CARIISIM ?? "",
                                    style: const TextStyle(
                                        fontWeight: FontWeight.w900,`your text`
                                        fontSize: 30),
                                  )),
                                ],
                              );
                            }),
                          ),
                  ),
                ),
              ),
               if (filterList.length > 0)
                  Padding(
                    padding:  EdgeInsets.all(size.width * 0.03),
                    child:  Text(
                     "Listelenen Kayıt Sayısı: " +
                          filterList.length.toString(),
                      textAlign: TextAlign.right,style: TextStyle(color: Colors.green,fontWeight: FontWeight.bold),
                    ),
                  )
                else
                  Text("")
            ]),
             

推荐答案

使用InteractiveViewer并包装您想要放大或缩小的小部件,您可以使用字段minScale和MaxScale指定最大和最小zoom ,而且,还有一个非常好的地方,您可以使用101,例如,如下所示,并将其应用于您的Interactive Viewer小部件,并启用通过控件进行放大和缩小:

final zoomTransformationController = TransformationController();

 void _zoomIn(){
   zoomTransformationController.value.scale(2);
 }
 void _zoomOut(){
   zoomTransformationController.value.scale(0.9);
 }


class InteractiveViewerExampleApp extends StatelessWidget {
  const InteractiveViewerExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: const InteractiveViewerExample(),
      ),
    );
  }
}

class InteractiveViewerExample extends StatelessWidget {
  const InteractiveViewerExample({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: InteractiveViewer(
        boundaryMargin: const EdgeInsets.all(20.0),
        minScale: 0.1,
        maxScale: 2,
 transformationController: zoomTransformationController,
        child: Container(
          ...
        ),
      ),
    );
  }
}

Flutter相关问答推荐

获取屏幕大小的滚动视图与动态大小?

如何从外部控制有状态窗口小部件本身?

在Flutter中,有没有一种方法可以点击页面到后面的页面?

MobX Build_Runner问题:不生成.G文件(Flutter )

在Flutter TextField中计算子字符串位置

如何在Flutter 中共享选定文本

为什么我的页面控制器在使用Riverpod时没有更改我的页面视图?

我怎样才能在Ffltter中显示html布局链接?

如何将小部件代码移动到另一个文件以获得更好的可读性

谷歌 map 在 flutter 应用程序中显示错误的当前位置

Flutter 构建 Web 分段故障 - 无法启动事件处理程序线程

显示图像的放大部分

Flutter firebase_auth 和 firebase_core 依赖错误

如何在Flutter中显示ListView Builder区域外的列表数据?

如何让小部件根据小部件的大小构建不同的布局?

如何在 flutter 中同时使用 ButtonStyle() 和 ElevatedButton.styleFrom() ?

按下 Command+W 时关闭窗口

Flutter RawMaterialButton 常量相对大小

Firestore:缓存和读取数据

Flutter audioplayers错误-单击音频按钮时不播放音频