go_responsive_generator 0.2.0 copy "go_responsive_generator: ^0.2.0" to clipboard
go_responsive_generator: ^0.2.0 copied to clipboard

A code generator for GoResponsive which generate useful extension methods and widget.

GoResponsive MIT #

A simple but expressive responsive framework inspired by responsive_framework conitinal logics and context based responsive data & responsive_builder responsive widget with all supported breakpoint as parameters which will genrated by code generation.

Preview

Features #

GoResponsive makes responsive design easy by:

  • Generate GoResponsiveWidget with all defined breakpoint as optional parameters with and a required defaultWidget parameter.
  • Generating .is{breakpoint_name} extension methods on BuildContext so can be used with condition.
  • Generate goResponsiveValue<T> extension method on BuildContext so can be used set dynamic value.

Getting started #

Package Version
go_responsive pub pakage
go_responsive_annotation pub pakage
go_responsive_generator pub pakage
dependencies:
  ...
  go_responsive: <version>
  go_responsive_annotation: <version>

dev_dependencies:
  ...
  build_runner: <version>
  go_responsive_generator: <version>

Uasage #

  • Define breakepoints as top level list of GoResponsiveBreakpoint and annotate it with @GoResponsive():

    @GoResponsive()
    const breakpoints = [
      GoResponsiveBreakpoint(size: 600, name: 'compact'),
      GoResponsiveBreakpoint(size: 840, name: 'medium'),
      GoResponsiveBreakpoint(size: double.maxFinite, name: 'expanded'),
    ];
    
  • return GoResponsiveBuilder from MaterialApp builder function and set breakpoint to already defined breakpoints list:

    class App extends StatelessWidget {
      const App({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: const Home(),
          builder: (context, child) {
            return GoResponsiveBuilder(
              breakpoints: breakpoints,
              child: child!,
            );
          },
        );
      }
    }
    
  • now run dart run build_runner build in console which will generate <file_name>.name.go_responsive.dart

  • then import <file_name>.name.go_responsive.dart in which GoResponsiveWidget is Defined and can be used like this:

    class Home extends StatelessWidget {
      const Home({super.key});
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: GoResponsiveWidget(
            compact: Container(
              color: Colors.red,
            ),
            medium: Container(
              color: Colors.green,
            ),
            expanded: Container(
              color: Colors.blue,
            ),
            defaultWidget: Container(
              color: Colors.black,
            ),
          ),
        );
      }
    }
    

Please see example for complete understanding.

My other packages #

Time Picker Wheel Time Picker inspired by Oppo Clock app set alram time screen with full customization

Contributors #

Contributors

0
likes
0
points
49
downloads

Publisher

unverified uploader

Weekly Downloads

A code generator for GoResponsive which generate useful extension methods and widget.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, build, built_collection, code_builder, dart_style, go_responsive_annotation, source_gen

More

Packages that depend on go_responsive_generator