nil 1.1.1 copy "nil: ^1.1.1" to clipboard
nil: ^1.1.1 copied to clipboard

A simple widget to add in the widget tree when you want to show nothing, with minimal impact on performance.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  const MyApp({
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Nil example')),
      body: Center(
        child: Builder(
          builder: (_) {
            if (DateTime.now().minute.isEven) {
              return const MyWidget();
            } else {
              return nil;
            }
          },
        ),
      ),
    );
  }
}

class MyWidget extends StatelessWidget {
  const MyWidget({
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 200,
      width: 200,
      color: Colors.red,
    );
  }
}
305
likes
120
pub points
95%
popularity

Publisher

unverified uploader

A simple widget to add in the widget tree when you want to show nothing, with minimal impact on performance.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on nil