1

在下面的代码中,我只是在容器中添加了一个图像,我使用交互式查看器进行缩放

 import 'package:flutter/material.dart';
void main()
{
  runApp(MyApp());
}
class MyApp extends StatelessWidget {
  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: Zoom(),
      ),
    );
  }
}
class Zoom extends StatefulWidget
{
  @override
  MyStatelessWidget createState()=> MyStatelessWidget();
}
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends State<Zoom> {


  @override
  Widget build(BuildContext context) {
    return Container(height: 1500,
            child: InteractiveViewer(
                child:Container( child:Image.asset('assets/pdfpage.png',fit: BoxFit.fitWidth)),
       )
    );
  }
}

在此处输入图像描述

在最大缩放级别

在此处输入图像描述

在最小缩放级别

需要单独缩放一个容器小部件,我使用 ctrl+mousewheelscroll 在flutter web中缩放图像,appbar和整个网页都被缩放。

4

0 回答 0