Scaffold Factory

Pub

A Flutter plugin to build and customize the Flutter's scaffold widget with simple and flexible configurations. Also, this plugin provides various implementations of useful widgets that can be used in UI design. The scaffold is a class provides APIs for showing drawers, snack bars, and bottom sheets.

How to use

Import the package

To use this plugin, add scaffold_factory as a dependency in your pubspec.yaml file. Also, You can use Dart packages' install instruction for this package.

Use the plugin

1- Add the following import to your Dart code:

import 'package:scaffold_factory/scaffold_factory.dart';

2- Define these private variables inside your widget.

final _scaffoldKey = GlobalKey<ScaffoldState>();
ScaffoldFactory _scaffoldFactory;
MaterialPalette _sampleColorPalette = MaterialPalette(
  primaryColor: Colors.teal,
  accentColor: Colors.pinkAccent,
);

3- Your state class can Implements ScaffoldFactoryBehaviors interface:

class _ExampleScaffoldFactoryState extends State<ExampleScaffoldFactory> implements ScaffoldFactoryBehaviors {
  
  // body
 
  @override
  void onBackButtonPressed() {
    print("Scaffold Factory => onBackButtonPressed()");
  }

  @override
  void onFloatingActionButtonPressed() {
    print("Scaffold Factory => onFloatingActionButtonPressed()");
  }

  @override
  Future onEventBusMessageReceived(event) async {
    print("ScaffoldFactory: Event Received");
  }
}    

4- Initialize ScaffoldFactory with the scopes you want:

 @override
  void initState() {
    super.initState();
    _initScaffoldFactory();
  }
  
  void _initScaffoldFactory() {
    _scaffoldFactory = ScaffoldFactory(
      scaffoldKey: _scaffoldKey,
      materialPalette: _sampleColorPalette,
    );
    _scaffoldFactory.scaffoldFactoryBehavior = this;

    _scaffoldFactory.init(
      backgroundType: BackgroundType.normal,
      appBarVisibility: false,
      floatingActionButtonVisibility: false,
      drawerVisibility: false,
      nestedAppBarVisibility: false,
      bottomNavigationBarVisibility: false,
    );
  }

5- Pass the body widget to build method of your _scaffoldFactory object and define your theme of texts:

@override
Widget build(BuildContext context) {
  _scaffoldFactory.textTheme = Theme.of(context).textTheme;

  return _scaffoldFactory.build(_buildBody(context));
}

Widget _buildBody(BuildContext context) {
  // return your body widget    
}

Features

  • Easily create a material interface with simple configurations.
  • There is an implementation for each of scaffold's widget like the AppBar, BottomNavigationBar, FloatingActionButton, etc.
MethodOutput
buildAppBarAppBar widget
buildNestedScrollViewNestedScrollView widget
buildBottomNavigationBarBottomNavigationBar widget
buildBottomAppBarBottomAppBar widget
buildFloatingActionButtonFloatingActionButton widget
  • You can change the visibility of scaffold's widgets and pass your custom widget in the init method
 _scaffoldFactory.init(
      appBarVisibility: true,
      appBar: _scaffoldFactory.buildAppBar(
        titleVisibility: true,
        leadingVisibility: false,
        tabBarVisibility: false,
        titleWidget: Text('Scaffol Factory Example'),
        backgroundColor: _scaffoldFactory.colorPalette.primaryColor,
      ),
    );

or whenever you want in the build method of your state.

@override
Widget build(BuildContext context) {
  _scaffoldFactory.textTheme = Theme.of(context).textTheme;
  
  _scaffoldFactory.appBarVisibility = true;
  _scaffoldFactory.appBar = _scaffoldFactory.buildAppBar(
      titleVisibility: true,
      leadingVisibility: false,
      tabBarVisibility: false,
      titleWidget: Text('Scaffol Factory Example'),
      backgroundColor: _scaffoldFactory.colorPalette.primaryColor,
    );

  return _scaffoldFactory.build(_buildBody(context));
}

Example

There are two examples in the example application package.

Solid Solid Solid Solid

Libraries

scaffold_factory

Dart

dart:ui
Built-in types and core primitives for a Flutter application. [...]

Core

dart:async
Support for asynchronous programming, with classes such as Future and Stream. [...]
dart:collection
Classes and utilities that supplement the collection support in dart:core. [...]
dart:convert
Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
dart:core
Built-in types, collections, and other core functionality for every Dart program. [...]
dart:developer
Interact with developer tools such as the debugger and inspector. [...]
dart:math
Mathematical constants and functions, plus a random number generator. [...]
dart:typed_data
Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]

VM

dart:io
File, socket, HTTP, and other I/O support for non-web applications. [...]
dart:isolate
Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]