tuxin_tutorial_overlay2 0.6.1 copy "tuxin_tutorial_overlay2: ^0.6.1" to clipboard
tuxin_tutorial_overlay2: ^0.6.1 copied to clipboard

an overlay package that can be used for tutorials and walkthrough

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:tuxin_tutorial_overlay2/TutorialOverlayUtil.dart';
import 'package:tuxin_tutorial_overlay2/WidgetData.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Tux-In Tutorial Overlay Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Tutorial Overlay Example Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  final GlobalKey buttonKey = GlobalKey();
  final GlobalKey counterKey = GlobalKey();
  double _leftPosition = 0;
  @override
  void initState() {
    setTutorialShowOverlayHook((String tagName) => print('SHOWING $tagName'));
    SchedulerBinding.instance!.addPostFrameCallback(postFrameCallback);

    super.initState();
  }

  void postFrameCallback(Duration duration) {
    createTutorialOverlay(
      context: context,
      tagName: 'example',
      bgColor: Colors.green.withOpacity(
          0.4), // Optional. uses black color with 0.4 opacity by default
      onTap: () => print("TAP"),
      widgetsData: <WidgetData>[
        WidgetData(key: buttonKey, isEnabled: true, padding: 4),
        WidgetData(
          key: counterKey,
          isEnabled: false,
          shape: WidgetShape.Rect,
        )
      ],
      description: Text(
        'hello',
        textAlign: TextAlign.center,
        style: TextStyle(
          decoration: TextDecoration.none,
        ),
      ),
    );

    showOverlayEntry(tagName: 'example');
  }

  void _incrementCounter() {
    setState(() {
      _leftPosition += 10;
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Padding(
              padding: EdgeInsets.fromLTRB(_leftPosition, 0, 0, 0),
              child: Text(
                '$_counter',
                key: counterKey,
                style: Theme.of(context).textTheme.headline4,
              ),
            )
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        key: buttonKey,
        child: Icon(Icons.add),
      ),
    );
  }
}
2
likes
95
pub points
32%
popularity

Publisher

unverified uploader

an overlay package that can be used for tutorials and walkthrough

Repository (GitHub)
View/report issues

Documentation

API reference

License

GPL-3.0 (LICENSE)

Dependencies

collection, flutter, synchronized, uuid

More

Packages that depend on tuxin_tutorial_overlay2