how to set 16:9 screen aspect ratio in flutter?

Viewed 39

I need to set 16:9 screen aspect ratio on galaxy z fold just like instagram on z fold

I have checked app setting about screen aspect ratio. most of app is set full screen but instagram is 16:9 enter image description here

so I have added android:resizeableActivity="false" in manifest but it didn't work at all

is there any way to implement 16:9 screen size on galaxy z fold in flutter?

1 Answers
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

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

  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: const MyStatelessWidget(),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.blue,
      alignment: Alignment.center,
      width: double.infinity,
      height: 250,
      child: AspectRatio(
        aspectRatio: 16 / 9,
        child: Container(
          color: Colors.green,
        ),
      ),
    );
  }
}

OutPut:

enter image description here

Related