talamaska / onboarding_overlay

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'no widget at all' focusnode strange behavior

Macacoazul01 opened this issue · comments

Your 'no widget at all' sample used to create an overlay on the center of the screen, but now it is on the top left:

Sample code:

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

void main() {
  runApp(App());
}

final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();

class App extends StatefulWidget {
  final GlobalKey<OnboardingState> onboardingKey = GlobalKey<OnboardingState>();

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

class _AppState extends State<App> {
  late List<FocusNode> focusNodes;

  @override
  void initState() {
    super.initState();

    focusNodes = List<FocusNode>.generate(
      18,
      (int i) => FocusNode(debugLabel: 'Onboarding Focus Node $i'),
      growable: false,
    );
  }

  @override
  Widget build(BuildContext context) => MaterialApp(
        home: Onboarding(
          key: widget.onboardingKey,
          autoSizeTexts: true,
          steps: <OnboardingStep>[
            OnboardingStep(
              focusNode: focusNodes[0],
              title: "Or no widget at all! You're all done!",
              bodyText: "Or no widget at all! You're all done!",
              margin: EdgeInsets.zero,
              labelBoxPadding: const EdgeInsets.all(8.0),
              shape: const CircleBorder(),
              fullscreen: false,
              overlayShape: const CircleBorder(),
            ),
          ],
          child: Home(
            focusNodes: focusNodes,
          ),
        ),
      );
}

class Home extends StatefulWidget {
  const Home({
    Key? key,
    required this.focusNodes,
  }) : super(key: key);

  final List<FocusNode> focusNodes;

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

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: scaffoldKey,
      body: const Center(child: Text('Oi')),
      floatingActionButton: Padding(
        padding: const EdgeInsets.only(left: 32),
        child: FloatingActionButton(
          focusNode: widget.focusNodes[1],
          onPressed: () {
            final OnboardingState? onboarding = Onboarding.of(context);
            if (onboarding != null) {
              onboarding.show();
            }
          },
          child: const Icon(Icons.add),
        ),
      ),
    );
  }
}

Screenshot_1636501091

onboarding_overlay: ^2.3.3

[√] Flutter (Channel master, 2.6.0-12.0.pre.665, on Microsoft Windows [versão 10.0.22000.282], locale pt-BR)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Chrome - develop for the web
[√] Android Studio (version 2020.3)
[√] VS Code (version 1.62.1)
[√] Connected device (3 available)

! Doctor found issues in 1 category.