Skip to content
Snippets Groups Projects
Select Git revision
  • 763b8858f1bc2731111c4190db89fb4e43f14e65
  • master default protected
  • 100-upgrade-framework-and-dependencies
  • 65-improve-app-metadata
  • Release_1.8.0_80 protected
  • Release_1.7.2_79 protected
  • Release_1.7.1_78 protected
  • Release_1.7.0_77 protected
  • Release_1.6.0_76 protected
  • Release_1.5.0_75 protected
  • Release_1.4.0_74 protected
  • Release_1.3.2_73 protected
  • Release_1.3.1_72 protected
  • Release_1.3.0_71 protected
  • Release_1.2.1_70 protected
  • Release_1.2.0_69 protected
  • Release_1.1.3_68 protected
  • Release_1.1.2_67 protected
  • Release_1.1.1_66 protected
  • Release_1.1.0_65 protected
  • Release_1.0.63_64 protected
  • Release_1.0.62_63 protected
  • Release_1.0.61_62 protected
  • Release_1.0.60_61 protected
24 results

api_state.dart

Blame
  • graph_page.dart 2.15 KiB
    import 'package:flutter/material.dart';
    
    import 'package:random/ui/painters/graph_painter.dart';
    import 'package:random/utils/tools.dart';
    
    class GraphPage extends StatefulWidget {
      const GraphPage({super.key});
    
      @override
      State<GraphPage> createState() => _GraphPageState();
    }
    
    class _GraphPageState extends State<GraphPage> {
      double _currentSliderValue = 20;
    
      @override
      Widget build(BuildContext context) {
        double boardWidth = MediaQuery.of(context).size.width;
    
        return SizedBox.expand(
          child: FittedBox(
            fit: BoxFit.contain,
            alignment: Alignment.center,
            child: SizedBox(
              height: (MediaQuery.of(context).size.height),
              width: (MediaQuery.of(context).size.width),
              child: SafeArea(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Center(
                      child: GestureDetector(
                        onTapUp: (details) {
                          double xTap = details.localPosition.dx;
                          double yTap = details.localPosition.dy;
                          printlog('[$xTap,$yTap]');
                        },
                        child: Container(
                          margin: const EdgeInsets.all(4),
                          padding: const EdgeInsets.all(4),
                          child: CustomPaint(
                            size: Size(boardWidth, boardWidth),
                            willChange: false,
                            painter: GraphPainter(linesCount: _currentSliderValue.toInt()),
                          ),
                        ),
                      ),
                    ),
                    Slider(
                      value: _currentSliderValue,
                      min: 10,
                      max: 50,
                      divisions: 5,
                      label: _currentSliderValue.round().toString(),
                      onChanged: (double value) {
                        setState(() {
                          _currentSliderValue = value;
                        });
                      },
                    ),
                  ],
                ),
              ),
            ),
          ),
        );
      }
    }