scabld_safe_area_insets 1.0.0
scabld_safe_area_insets: ^1.0.0 copied to clipboard
Scabld safe area insets
import 'package:flutter/material.dart';
import 'package:scabld_safe_area_insets/scabld_safe_area_insets.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
setupViewportFit();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: const HomePage(),
builder: (context, child) {
return WebSafeAreaInsets(
child: child ?? const SizedBox(),
);
},
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.green,
appBar: AppBar(
backgroundColor: Colors.red,
title: const Text('Example app'),
),
body: SafeArea(
child: Column(
children: <Widget>[
const Text('Top'),
Expanded(child: Text('Count $_counter')),
const Text('Bottom'),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}