import 'package:flutter/material.dart';
void main() {
runApp(ResponsiveApp());
}
class ResponsiveApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Responsive Web App'),
),
body: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
if (constraints.maxWidth > 600) {
return _buildWideLayout();
} else {
return _buildNarrowLayout();
}
},
),
),
);
}
Widget _buildWideLayout() {
return Row(
children: [
Expanded(
flex: 1,
child: Container(
color: Colors.blue,
height: double.infinity,
child: Center(
child: Text(
'Sidebar',
style: TextStyle(color: Colors.white, fontSize: 30),
),
),
),
),
Expanded(
flex: 2,
child: Container(
color: Colors.white,
height: double.infinity,
child: Center(
child: Text(
'Main Content',
style: TextStyle(fontSize: 30),
),
),
),
),
],
);
}
Widget _buildNarrowLayout() {
return Column(
children: [
Container(
color: Colors.blue,
height: 100,
child: Center(
child: Text(
'Sidebar',
style: TextStyle(color: Colors.white, fontSize: 30),
),
),
),
Expanded(
child: Container(
color: Colors.white,
height: double.infinity,
child: Center(
child: Text(
'Main Content',
style: TextStyle(fontSize: 30),
),
),
),
),
],
);
}
}