screen_corners_ffi 1.0.2 copy "screen_corners_ffi: ^1.0.2" to clipboard
screen_corners_ffi: ^1.0.2 copied to clipboard

PlatformAndroid

A Flutter FFI-based plugin to obtain the screen corner radius on mobile platforms.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:screen_corners_ffi/screen_corners_ffi.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatefulWidget {
  const MainApp({super.key});

  @override
  State<MainApp> createState() => _MainAppState();
}

class _MainAppState extends State<MainApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: "Screen corners",
      themeMode: ThemeMode.system,
      theme: ThemeData.light(),
      darkTheme: ThemeData.dark(),
      home: MainPage(),
    );
  }
}

class MainPage extends StatefulWidget {
  const MainPage({super.key});

  @override
  State<MainPage> createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  // @override
  // void initState() {
  //   super.initState();
  //   SchedulerBinding.instance.addPostFrameCallback((timeStamp) {
  //     setState(() {});
  //   });
  // }

  @override
  Widget build(BuildContext context) {
    final colorScheme = ColorScheme.of(context);
    final textTheme = TextTheme.of(context);
    final screenCorners = ScreenCorners.maybeOf(context);
    // final screenCorners = null;
    debugPrint("$screenCorners ${MediaQuery.maybeDevicePixelRatioOf(context)}");
    return Scaffold(
      backgroundColor: colorScheme.surfaceContainer,
      body: SafeArea(
        top: false,
        child: CustomScrollView(
          slivers: [
            SliverAppBar.large(
              elevation: 0.0,
              scrolledUnderElevation: 0.0,
              surfaceTintColor: Colors.transparent,
              backgroundColor: colorScheme.surfaceContainer,
              title: Text("Screen corners"),
            ),
            SliverFillRemaining(
              hasScrollBody: false,
              fillOverscroll: false,
              child: Padding(
                padding: EdgeInsets.all(16.0),
                child: Material(
                  animationDuration: Duration.zero,
                  clipBehavior: Clip.antiAlias,
                  color: colorScheme.primaryContainer,
                  shape: RoundedRectangleBorder(
                    borderRadius:
                        screenCorners?.toBorderRadius() ??
                        BorderRadius.all(Radius.circular(9999.0)),
                  ),
                  child: Padding(
                    padding: const EdgeInsets.all(32.0),
                    child: Column(
                      children: [
                        FilledButton(
                          onPressed: () {
                            setState(() {});
                          },
                          child: const Text("Rebuild"),
                        ),
                        Text(
                          "$screenCorners",
                          style: textTheme.titleMedium!.copyWith(
                            fontWeight: FontWeight.w500,
                            color: colorScheme.onPrimaryContainer,
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
150
points
173
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter FFI-based plugin to obtain the screen corner radius on mobile platforms.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, jni, meta, plugin_platform_interface

More

Packages that depend on screen_corners_ffi

Packages that implement screen_corners_ffi