responsive_value 1.0.0
responsive_value: ^1.0.0 copied to clipboard
Flutter plugin to help building responsive UI's easy.
import 'package:flutter/material.dart';
import 'package:responsive_value/responsive_value.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Responsive Value',
theme: ThemeData(
colorSchemeSeed: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
final textSize = Responsive<double>(18, lg: 24).getValue(context);
final width = Responsive<double>(100, md: 140, lg: 200).getValue(context);
final boxColor =
Responsive<Color>(Colors.red, lg: Colors.blue).getValue(context);
final borderRadius = Responsive<double>(0, lg: 10).getValue(context);
return Scaffold(
appBar: AppBar(
title: const Text('Responsive Value'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Responsive Text Size ($textSize px)',
style: TextStyle(fontSize: textSize),
),
const SizedBox(height: 20),
Container(
width: width,
height: 80,
decoration: BoxDecoration(
color: boxColor,
borderRadius: BorderRadius.circular(borderRadius),
),
child: const Center(
child: Text(
'Responsive Color',
),
),
),
],
),
),
);
}
}