Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you want to add a image to center of appBar, you can use this code ;

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()
          ],
        ),
      ),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading