form_factor_builder 0.6.0 copy "form_factor_builder: ^0.6.0" to clipboard
form_factor_builder: ^0.6.0 copied to clipboard

A Flutter package for checking and building building widgets by form factor (desktop, tablet, mobile).

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:form_factor_builder/form_factor_builder.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final GlobalKey<NavigatorState> _navigatorKey = GlobalKey();

  @override
  initState() {
    super.initState();

    FormFactor.init(
      navigatorKey: _navigatorKey,
      breakpoints: FormFactorBreakpoints(
        tablet: 760,
        desktop: 1200,
      ),
    );

    FormFactor.instance.changes.listen((values) {
      // ignore: avoid_print
      print('Form factor changed from ${values.current} to ${values.previous}');
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: _navigatorKey,
      home: FormFactorChangeListener(
        child: Scaffold(
          body: Center(
            child: FormFactorBuilder(
              mobileBuilder: (_context) => const Text('mobile form factor'),
              tabletBuilder: (_context) => const Text('tablet form factor'),
              desktopBuilder: (_context) => const Text('desktop form factor'),
            ),
          ),
        ),
      ),
    );
  }
}
3
likes
150
points
37
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for checking and building building widgets by form factor (desktop, tablet, mobile).

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, restate

More

Packages that depend on form_factor_builder