flutter_rebuildable 1.0.0 copy "flutter_rebuildable: ^1.0.0" to clipboard
flutter_rebuildable: ^1.0.0 copied to clipboard

This package that provides widgets to help rebuild all descendant widgets or all widgets in the entire application.

example/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_rebuildable/widgets/rebuildable_app.dart';

bool isDark = false;

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

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

  @override
  Widget build(BuildContext context) {
    return RebuildableApp(
      child: Builder(
        builder: (context) {
          return MaterialApp(
            theme: isDark ? ThemeData.dark() : ThemeData.light(),
            home: Scaffold(
              body: TestPage()
            ),
          );
        },
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Wrap(
        children: [
          TextButton(
            onPressed: () {
              isDark = false;
              RebuildableApp.rebuild(); // like this
            },
            child: Text("Light"),
          ),
          TextButton(
            onPressed: () {
              isDark = true;
              RebuildableApp.rebuild(); // like this
            },
            child: Text("Dark"),
          )
        ],
      ),
    );
  }
}
1
likes
0
points
75
downloads

Publisher

verified publisherttangkong.dev

Weekly Downloads

This package that provides widgets to help rebuild all descendant widgets or all widgets in the entire application.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_rebuildable