bootstrap_breakpoints 0.0.1-dev.2 bootstrap_breakpoints: ^0.0.1-dev.2 copied to clipboard
A Flutter package to implement responsive layout based on Bootstrap 4.0+ breakpoints.
import 'package:bootstrap_breakpoints/bootstrap_breakpoints.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
double containerWidth = Breakpoints().getMaxWidth(context);
debugPrint(containerWidth.toString());
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
const SizedBox(
height: 5,
),
Container(
height: 100,
width: containerWidth,
decoration: BoxDecoration(
border: Border.all(color: Colors.black54),
),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Current breakpoint: ${Breakpoints().getScreenSize(context).toString()}",
),
const SizedBox(
height: 10,
),
Text(
"Max width: ${Breakpoints().getMaxWidth(context).toString()}",
),
],
),
),
),
],
),
),
);
}
}