Last updated:
0 purchases
april flutter screen adapter
Usage #
1、 Initialize by ScreenAdapter.
void main() {
// over here !!!
ScreenAdapter.ensureInitialized(designWidth: 400);
runApp(const MyApp());
}
copied to clipboard
2、Transform MediaQueryData by ScreenAdapter.
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
// over here !!!
builder: ScreenAdapter.compatBuilder,
);
}
copied to clipboard
or
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
// over here !!!
builder: (context, child) => MediaQuery(
data: ScreenAdapter.compatMediaQueryData(context),
child: child ?? const SizedBox.shrink(),
),
);
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.