future_or_builder 1.0.3 copy "future_or_builder: ^1.0.3" to clipboard
future_or_builder: ^1.0.3 copied to clipboard

discontinued

Builds FutureOrs immediately and otherwise delegates to a FutureBuilder

example/main.dart

// Copyright (C) 2019  Wilko Manger
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import 'dart:async';

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

FutureOr<bool> doThatThing() {
  // Could either return a Future<bool> or a FutureOr<bool>
  return true;
}

class SomeWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return FutureOrBuilder<bool>(
      futureOr: doThatThing(),
      builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
        final didThatThing = snapshot.data;

        if (didThatThing) {
          return Text('Cool!');
        }

        return Container();
      },
    );
  }
}
0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

Builds FutureOrs immediately and otherwise delegates to a FutureBuilder

Repository
View/report issues

License

MPL-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on future_or_builder