A flutter package that provide basic utils like Themes and Error Handler Widget

CI status

A package that provide basic utils like Themes, common BuildContext extension and simple Error Page widget.

Great for creating lots of flutter apps as a portfolio.

Features

  • Tired of defining themes manually? just use the default ThemeData from this package:
import 'package:core/core.dart' as core;

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: core.appName,
      theme: core.AppThemes.light,
      darkTheme: core.AppThemes.dark,
      ...
    );
  }
}
  • Need shorthand for the common use of context? Try the BuildContext extension from this package:
import 'package:core/core.dart';

class MyWidget extends StatelessWidget {
  const MyWidget({super.key});

  @override
  Widget build(BuildContext context) {
    // Shorthand for Theme.of(context)
    context.theme;

    // Shorthand for MediaQuery.of(context)
    context.mediaQuery;

    // Shorthand for Scaffold.of(context)
    context.scaffoldState;

    // Check "src/utils/extensions.dart" for more

    return Container();
  }
}
  • Need a simple page to display error info? try ErrorPages from the package:
import 'package:core/core.dart';

// Will display status code 400 with 'Bad Request' text below it.
ErrorPages.client.badRequest();

// Will display status code 500 with 'Internal Server Error' text below it.
ErrorPages.server.internalServerError();

// Will display page based on requested status code.
//
// The Example below will display status code 404 with
// 'Not Found' text below it.
ErrorPages.byCode(404);

// You can also add custom message to the page
// (Default message is 'Sorry for the inconvenience').
//
// The message displayed below statusCode and name.
ErrorPages.client.notFound(message: 'The Page You Requested Not Found');
ErrorPages.byCode(403, message: 'You are not allowed to access this');

// See preview below for page visual.

ErrorPages previews:

  • ErrorPages preview (403 -  Forbidden)

Getting started

  1. Add the package to your dependencies:
dependencies:
  core:
    git:
      url: https://github.com/KeidsID/flutter_app_core_package.git
  1. Then, you just need to call init() once in main():
import 'package:core/core.dart' as core;

void main() {
  core.init();
  ...
}
  1. You can also customize the Theme via init():
import 'package:flutter/material.dart';
import 'package:core/core.dart' as core;

void main() {
  core.init(
    appName: 'My App Name',
    appPrimaryColor: Colors.amber,
    useMaterial3: true,
  );
  ...
}

Now, you are ready to use this package’s utilities.

Usage

main.dart

import 'package:flutter/material.dart';
import 'package:core/core.dart' as core;

void main() {
  core.init(
    appName: 'Flutter Demo',
    useMaterial3: true,
  );

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: core.appName, // "Flutter Demo"
      // Both theme used material 3
      theme: core.AppThemes.light, 
      darkTheme: core.AppThemes.dark,
      themeMode: ThemeMode.system,
      // Simple page to display 404 Not Found
      home: core.ErrorPages.client.notFound(), 
    );
  }
}

GitHub

View Github

Related Posts

Recent Posts

ഇടുക്കിയിലെ മലയോര മേഖലകളിൽ രാത്രിയാത്ര നിരോധിച്ചു. രാത്രി ഏഴു മുതൽ രാവിലെ ആറു വരെയാണ് നിരോധനം

ഏന്തയാർ ഈസ്റ്റിൽ പ്രളയത്തിൽ തകർന്ന പാലത്തിന് പകരം പുതിയ പാലം നിർമ്മിക്കുവാൻ താത്ക്കാലിക പാലം പൊളിച്ച് നീക്കി

Explore the Investment Opportunities: A Comprehensive Guide to Different Types of Mutual Funds

Title: Understanding Mutual Funds: A Beginner's Guide to Investing

തീവ്രമഴ മുന്നറിയിപ്പിന്റെ പശ്ചാതലത്തിൽ സംസ്ഥാനം ജാഗ്രതയിൽ

250,000 അപേക്ഷകൾ വർദ്ധിച്ചതിനാൽ ട്രാൻസ്‌പോർട്ട് കമ്മീഷണർ പരിശോധന പുനരാരംഭിക്കും

ഏലക്കയിൽ കീടനാശിനി സാന്നിധ്യം; ആറര ലക്ഷത്തിലധികം ടിൻ അരവണ നശിപ്പിക്കാൻ ടെൻഡർ ക്ഷണിച്ച് ദേവസ്വം ബോർഡ്‌

ഭീമൻ പാറക്കഷണങ്ങൾ അടർന്ന് ദേശീയ പാതയിലേക്ക് വീഴുന്നത് പതിവാകുന്നു. കുട്ടിക്കാനത്തിനും മുണ്ടക്കയത്തിനുമിടയിൽ നിലനിൽക്കുന്നത് വൻ അപകട ഭീഷണി

ചക്രവാതച്ചുഴി:അതിശക്തമായ മഴ വരുന്നു

പ്ലസ് വൺ പ്രവേശനം. അക്ഷയയിൽ തിക്കി തിരക്കേണ്ട, നെറ്റിവിറ്റി/ജാതി തെളിയിക്കാൻ പത്താംതരം സർട്ടിഫിക്കറ്റ് മതി