maintenance_banner 0.2.2 copy "maintenance_banner: ^0.2.2" to clipboard
maintenance_banner: ^0.2.2 copied to clipboard

A Flutter package for displaying maintenance banners in your app

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:maintenance_banner/maintenance_banner.dart';
import 'package:maintenance_banner_example/home_page.dart';

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

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

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

class _MyAppState extends State<MyApp> {
  bool isUnderMaintenance = true;
  String? _lastBannerEvent;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Maintenance Banner Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.deepPurple,
          brightness: Brightness.light,
        ),
        useMaterial3: true,
      ),
      home: MaintenanceWrapper(
        isUnderMaintenance: isUnderMaintenance,
        animationDuration: const Duration(milliseconds: 400),
        onBannerShown: () {
          setState(() {
            _lastBannerEvent = 'Banner shown at ${DateTime.now().toString().substring(11, 19)}';
          });
          debugPrint('Maintenance banner is now visible');
        },
        onBannerHidden: () {
          setState(() {
            _lastBannerEvent = 'Banner hidden at ${DateTime.now().toString().substring(11, 19)}';
          });
          debugPrint('Maintenance banner is now hidden');
        },
        banner: Container(
          height: 40,
          decoration: BoxDecoration(
            gradient: LinearGradient(
              colors: [
                Colors.orange.shade400,
                Colors.orange.shade600,
              ],
            ),
          ),
          child: const Center(
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Icon(
                  Icons.build_circle,
                  color: Colors.white,
                  size: 20,
                ),
                SizedBox(width: 8),
                Text(
                  'Application under maintenance',
                  style: TextStyle(
                    color: Colors.white,
                    fontWeight: FontWeight.w600,
                    fontSize: 14,
                  ),
                ),
              ],
            ),
          ),
        ),
        child: HomePage(
          isUnderMaintenance: isUnderMaintenance,
          onMaintenanceChanged: (value) {
            setState(() {
              isUnderMaintenance = value;
            });
          },
          lastBannerEvent: _lastBannerEvent,
        ),
      ),
    );
  }
}
1
likes
160
points
126
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for displaying maintenance banners in your app

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on maintenance_banner