1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import 'package:flutter/material.dart';
- const colorNormal = Colors.black87;
- const colorNull = Colors.black12;
- const colorHighlight = Color(0xFF560000);
- class BrikSize extends InheritedWidget {
- const BrikSize({
- Key? key,
- required this.size,
- required Widget child,
- }) : super(key: key, child: child);
- final Size size;
- static BrikSize of(BuildContext context) {
- final brikSize = context.dependOnInheritedWidgetOfExactType<BrikSize>();
- assert(brikSize != null, "....");
- return brikSize!;
- }
- @override
- bool updateShouldNotify(BrikSize old) {
- return old.size != size;
- }
- }
- ///the basic brik for game panel
- class Brik extends StatelessWidget {
- final Color color;
- const Brik._({Key? key, required this.color}) : super(key: key);
- const Brik.normal() : this._(color: colorNormal);
- const Brik.empty() : this._(color: colorNull);
- const Brik.highlight() : this._(color: colorHighlight);
- @override
- Widget build(BuildContext context) {
- final width = BrikSize.of(context).size.width;
- return SizedBox.fromSize(
- size: BrikSize.of(context).size,
- child: Container(
- margin: EdgeInsets.all(0.05 * width),
- padding: EdgeInsets.all(0.1 * width),
- decoration: BoxDecoration(
- border: Border.all(width: 0.10 * width, color: color)),
- child: Container(
- color: color,
- ),
- ),
- );
- }
- }
|