Skip to content

SnowballFox/april_flutter_screen_adapter

 
 

Repository files navigation

Usage

  • 1、 Initialize by ScreenAdapter.
void main() {
  // over here !!!
  ScreenAdapter.ensureInitialized(designWidth: 400);
  runApp(const MyApp());
}
  • 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,
  );
}

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(),
    ),
  );
}

About

A Flutter version of the screen adaptation package.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 58.6%
  • CMake 10.3%
  • Swift 8.2%
  • Shell 7.4%
  • C 4.2%
  • Objective-C 4.2%
  • Other 7.1%