簡體   English   中英

flutter 小部件 InteractiveViewer inside Scaffold body

[英]flutter widget InteractiveViewer inside Scaffold body

我在 Scaffold 中有InteractiveViewer ,其中一次我有橫向圖像,另一次是縱向圖像。 但是InteractiveViewer的尺寸總是有頁面啟動時的尺寸。 如何允許在InteractiveViewer內顯示全身圖像? 這是代碼:

import 'package:flutter/material.dart';

const Color darkBlue = Color.fromARGB(255, 18, 32, 47);

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(
        scaffoldBackgroundColor: darkBlue,
      ),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body:Center( child: InteractiveViewer(
          boundaryMargin: const EdgeInsets.all(20.0),
          maxScale: 5.0,
          child: FlutterLogo(size: 100),
        ),),)
      
    );
  }
}

output 當我用手指在InteractiveViewer中調整 object 的大小時: 在此處輸入圖像描述 但我希望: 在此處輸入圖像描述

您可以使用clipBehavior: Clip.none,但視圖取決於內部大小。 也可以在constrained: false

 InteractiveViewer(
    boundaryMargin: const EdgeInsets.all(2.0),
    clipBehavior: Clip.none,
    maxScale: 5.0,
    child: FlutterLogo(size: 100)),

但是對於InteractiveViewer ,孩子必須更大

body: Center(
  child: InteractiveViewer(
    boundaryMargin: const EdgeInsets.all(2.0),
    maxScale: 5.0,
    minScale: 1,
    child: SizedBox(
      width: 500, // this
      height: 500,
      child: Center(child: FlutterLogo(size: 100)),
    ),
  ),
),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM