31 lines
958 B
Dart
31 lines
958 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// Keeps the navigator (including dialogs) usable in very narrow browser tabs.
|
|
/// The native Windows/Linux runners use the same minimum client width.
|
|
class ResponsiveViewport extends StatelessWidget {
|
|
const ResponsiveViewport({super.key, required this.child});
|
|
|
|
static const minimumWidth = 320.0;
|
|
final Widget child;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
if (constraints.maxWidth >= minimumWidth) return child;
|
|
final media = MediaQuery.of(context);
|
|
return SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
primary: false,
|
|
child: SizedBox(
|
|
width: minimumWidth,
|
|
height: constraints.maxHeight,
|
|
child: MediaQuery(
|
|
data: media.copyWith(size: Size(minimumWidth, media.size.height)),
|
|
child: child,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|