gol_grid 0.1.9

  • Readme
  • Changelog
  • Example
  • Installing
  • 53

GolGrid #

Conway's Game of Life in a flutter widget.

A GolGrid is a rendering of a GridWorld controlled by a Thumper.

Example #

The example contains two alternatives.

One uses several relatively small widgets in a scrollable column, suitable for a browser:

movie web

The other does a media query to do a full screen demo with a complex world (four Gosper guns and an R-pentomino), more suitable for android:

movie android

To run the examples, install flutter (for demo-web demo, use beta channel flutter), then

# Confirm flutter installed and devices available.
flutter devices

# Get the code
git clone git@github.com:monopole/gol_grid.git
cd gol_grid

# then either
make demo-android # needs USB connected device
# or
make demo-web # needs chrome

0.1.9 #

  • upgrade to bloc 4.0.0

0.1.8 #

  • android movie

0.1.7 #

  • improve chrome demo.

0.1.6 #

  • Depend on thumper 2.0.0

0.1.5 #

  • Depend on thumper 1.0.0, grid_world 1.0.1

0.1.4 #

  • Upgrade to latest thumper, add screenshots.

0.1.3 #

  • Tweak example.

0.1.2 #

  • Tweak example.

0.1.1 #

  • Tweak example.

0.1.0 #

  • Initial package commit.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:gol_grid/gol_grid.dart';
import 'package:grid_world/grid_world.dart';
import 'package:thumper/thumper.dart';

// ignore_for_file: diagnostic_describe_all_properties
// ignore_for_file: use_key_in_widget_constructors

void main() => runApp(const DemoApp());

/// A GolGrid widget demo.
@immutable
class DemoApp extends StatelessWidget {
  /// Make an app instance.
  const DemoApp({this.isFullScreen = true});

  /// Full screen consumes lots of pixels/CPU - best for Android.
  final bool isFullScreen;

  static const _spacer = SizedBox(height: 3);

  @override
  Widget build(BuildContext context) => MaterialApp(
        title: 'Game of Life Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: Scaffold(
            backgroundColor: Colors.grey,
            appBar: AppBar(
              title: const Text('Game of Life Demo'),
              leading: Icon(Icons.menu),
            ),
            body: isFullScreen ? FullScreenWidget() : _widgetColumn()),
      );

  Widget _widgetColumn() => Center(
        child: ListView(children: <Widget>[
          _spacer,
          GolGrid(DimensionedWorld.make(ConwayEvolver.blinker.lrPadded(6),
              lineWidth: 10, cellWidth: 30)),
          _spacer,
          GolGrid(
              DimensionedWorld.make(ConwayEvolver.pentaDecathlon.clockwise90(),
                  lineWidth: 6, cellWidth: 18),
              foregroundColor: Colors.deepPurple),
          _spacer,
          GolGrid(DimensionedWorld.make(
              ConwayEvolver.lightweightSpaceship
                  .appendBottom(ConwayEvolver.lightweightSpaceship)
                  .appendBottom(ConwayEvolver.lightweightSpaceship)
                  .padRight(50),
              lineWidth: 3,
              cellWidth: 9)),
          _spacer,
          GolGrid(
              DimensionedWorld.make(
                  ConwayEvolver.gliderFleet().padRight(20).padBottom(30),
                  lineWidth: 3,
                  cellWidth: 9),
              foregroundColor: Colors.redAccent),
          _spacer,
          GolGrid(DimensionedWorld.make(
              ConwayEvolver.gosperGliderGun.padded(20),
              lineWidth: 3,
              cellWidth: 9)),
          _spacer,
          GolGrid(
              DimensionedWorld.make(
                  ConwayEvolver.rPentimino.lrPadded(70).tbPadded(60),
                  lineWidth: 1,
                  cellWidth: 3),
              foregroundColor: Colors.white),
          _spacer,
        ]),
      );
}

/// [FullScreenWidget] does a media query to expand a [DimensionedWorld]
/// to fill the media.
///
/// The query only works if this widget is below [MaterialApp] in the tree.
class FullScreenWidget extends StatelessWidget {
  /// A guess as to the media height (virtual pixels) consumed by the AppBar.
  /// TODO: Instead of guessing, look up the appbar via a key, e.g.
  /// medium.com/@diegoveloper/flutter-widget-size-and-position-b0a9ffed9407
  static double get _estimatedAppBarHeight => 80; // 80

  @override
  Widget build(BuildContext context) {
    final s = MediaQuery.of(context).size;
    final dw = DimensionedWorld.make(ConwayEvolver.gunFight()
        .appendBottom(ConwayEvolver.rPentimino.padLeft(30).tbPadded(27))
        .appendBottom(ConwayEvolver.gunFight())
        .lrPadded(6));
    return GolGrid(dw.expandToFit(
        s.width, s.height - _estimatedAppBarHeight - Thumper.height));
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  gol_grid: ^0.1.9

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:gol_grid/gol_grid.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
10
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
53
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • gol_grid that is a package requiring null.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (flutter_bloc).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_bloc ^4.0.0 4.0.1 5.0.1
grid_world ^1.0.1 1.0.1
test ^1.14.4 1.15.2
thumper ^2.1.1 2.1.1
Transitive dependencies
_fe_analyzer_shared 5.0.0
analyzer 0.39.12
args 1.6.0
async 2.4.2
bloc 4.0.0 5.0.1
boolean_selector 2.0.0
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
coverage 0.14.0
crypto 2.1.5
csslib 0.16.1
glob 1.2.0
html 0.14.0+3
http 0.12.1
http_multi_server 2.2.0
http_parser 3.1.4
io 0.3.4
js 0.6.2
logging 0.11.4
matcher 0.12.8
meta 1.1.8 1.2.1
mime 0.9.6+3
nested 0.0.4
node_interop 1.1.1
node_io 1.1.1
node_preamble 1.4.12
package_config 1.9.3
path 1.7.0
pedantic 1.9.0 1.9.1
pool 1.4.0
provider 4.3.0
pub_semver 1.4.4
quiver 2.1.3
shelf 0.7.7
shelf_packages_handler 2.0.0
shelf_static 0.2.8
shelf_web_socket 0.2.3
sky_engine 0.0.99
source_map_stack_trace 2.0.0
source_maps 0.10.9
source_span 1.7.0
stack_trace 1.9.5
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
test_api 0.2.17
test_core 0.3.10
tuple 1.0.3
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
vm_service 4.1.0
watcher 0.9.7+15
web_socket_channel 1.1.0
webkit_inspection_protocol 0.7.3
yaml 2.2.1
Dev dependencies
flutter_test