renderif 1.0.1 copy "renderif: ^1.0.1" to clipboard
renderif: ^1.0.1 copied to clipboard

RenderIf simplifies code and enhances readability in Flutter apps. It introduces a new approach to conditional rendering using a boolean parameter in commonly used widgets

example/example.dart

import 'package:flutter/material.dart';
import 'package:renderif/renderif.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    // We are defining a boolean variable here.
    // You can replace this with your own condition.
    const bool applyPadding = true;

    return Scaffold(
      appBar: AppBar(
        title: const Text("RenderIf Example"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: const <Widget>[
            // Use PaddingIf just like you would use a regular Padding,
            // but with an additional 'condition' parameter.
            PaddingIf(
              condition:
                  applyPadding, // If this condition is true, PaddingIf will apply the padding.
              padding: EdgeInsets.all(10.0),
              child: Text(
                'Hello World',
              ),
            ),
            // If 'applyPadding' is false, PaddingIf will render the child directly,
            // effectively skipping the padding.
          ],
        ),
      ),
    );
  }
}
0
likes
140
points
32
downloads

Publisher

verified publishermartinfenocchio.tech

Weekly Downloads

RenderIf simplifies code and enhances readability in Flutter apps. It introduces a new approach to conditional rendering using a boolean parameter in commonly used widgets

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on renderif