简体   繁体   English

如何在 appbar 中调整 image.network 的大小

[英]How can i resize image.network in appbar

I want image at center in appbar and resize to bigger.我希望图像在应用栏的中心并调整为更大。 I tried use width and height but it's death code.我尝试使用宽度和高度,但它是死亡代码。

class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    //ใช้ context
    return MaterialApp(
      //ใช้ MaterialApp
      home: Scaffold(
        //ใช้ Scaffold
        appBar: BuildAppBar(),
        //สร้าง AppBar
        body: Center(child: Text('Hi')), //ใช้ Text แสดงข้อความตรงกลางจอ
      ),
    );
  }

  AppBar BuildAppBar() {
    return AppBar(
      leading: Container(
        padding: const EdgeInsets.all(0),
        child: Image.network(
            'http://www.sr...i can't open this url to pubic'),
        width: 100,
        height: 100,
      ),
    );
  }
}

This's result in debug mode right now.这导致现在处于调试模式。

If you want to add a image to center of appBar, you can use this code;如果要在 appBar 的中心添加图像,可以使用此代码;

appBar: AppBar(
        title: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Image.network(
              'https://picsum.photos/250?image=9',
              fit: BoxFit.contain,
              height: 60,
              errorBuilder: (context, error, stackTrace) =>
                  const Icon(Icons.error_outline_outlined),
            ),
            Container()
          ],
        ),
      ),

Try this:尝试这个:

 return AppBar(
  centerTitle: true,
  toolbarHeight: 100,
  title: Image.network(
    imageUrl,
    width: 100,
    height: 100,
  ),
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 flutter Image.network 不适用于发布 apk - flutter Image.network not working on release apk Flutter - Image.network 失败时的默认图像 - Flutter - Default image to Image.network when it fails 即使在 Flutter 中定义了 errorBuilder 之后,Image.network 也会抛出错误 - Image.network throw error even after defining errorBuilder in Flutter 如何在Kotlin中调整图像文件的大小 - How can I resize a image file in Kotlin 如何在 flutter 中实现此 appbar 设计,其中我将 Navigation 插入 appbar 而不是 bottomNavigationBar - How can I achieve this appbar design in flutter in which I insert Navigation inside appbar rather than bottomNavigationBar 如何在同一活动中移动图像并缩放或调整其大小 - How can I move an image and scale or resize it in the same activity 如何根据屏幕分辨率调整图像大小? - How can I resize the image according to screen resolution? 如何在android中调整图像大小以在扩展通知中使用它? - How can I resize an image in android to use it in an expanded notification? 如何防止在调整大小时应用模糊滤镜图像? - How can I prevent from applying blur Filter Image on resize? Android:如何调整图片大小以自动适合View - Android: How can I resize an image to be automatically fitted with the View
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM