Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text is dissapearing #23

Open
efreibe opened this issue Mar 21, 2019 · 2 comments
Open

Text is dissapearing #23

efreibe opened this issue Mar 21, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@efreibe
Copy link

efreibe commented Mar 21, 2019

Hello, I've made a test using the last version of UnicornDialer and I cannot understand why the text is dissapearing after a couple of times of clicking into the dial.

It only happens in Android (tested both in simulator and my device).

Here is the flutter doctor output, the code I've used, and an animated .gif showing the problem.

The code is a default flutter project where I've replaced the floatingActionButton with the UnicornDialer. So far I've tracked the problem to any of the ScaleTransition widgets inside the main widget but I don't know the reason why the text dissapears, apparently the text is there but flutter is not drawing it.

problem

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

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          // Column is also layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          //
          // Invoke "debug painting" (press "p" in the console, choose the
          // "Toggle Debug Paint" action from the Flutter Inspector in Android
          // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
          // to see the wireframe for each widget.
          //
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: UnicornDialer(
        backgroundColor: Color.fromRGBO(255, 255, 255, 0.6),
        parentButtonBackground: Colors.redAccent,
        orientation: UnicornOrientation.VERTICAL,
        parentButton: Icon(Icons.settings),
        childButtons: <UnicornButton>[
          UnicornButton(
            hasLabel: true,
            labelText: 'Option1',
            currentButton: FloatingActionButton(
              heroTag: 'Option1',
              mini: true,
              onPressed: () => _incrementCounter(),
            ),
          ),
        ],
      ),
    );
  }
}
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.3.14-pre.21, on Mac OS X 10.14.3 18D109, locale en-AR)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.2)
[✓] VS Code (version 1.32.3)
[✓] Connected device (1 available)

• No issues found!
@elgansayer
Copy link

Same, did you work it out?

@efreibe
Copy link
Author

efreibe commented Mar 26, 2019

The only thing that I've tested so far and it's working is replacing the ScaleTransition widget with another transition widget, in my case I replaced it with a SizeTransition widget and it worked.

Unfortunately the effect it's not as nice as ScaleTransition but at least it's a decent one.

I don't understand why ScaleTransition won't work, inspecting the screen shows the placeholders but nothing is drawn.

These are the changes so far

var childButtonsList = widget.childButtons == null || widget.childButtons.isEmpty
          ? List<Widget>()
          : List.generate(widget.childButtons.length, (index) {
              var intervalValue =
                  index == 0 ? 0.9 : ((widget.childButtons.length - index) / widget.childButtons.length) - 0.2;

              intervalValue = intervalValue < 0.0 ? (1 / index) * 0.5 : intervalValue;

              var childFAB = FloatingActionButton(
                  onPressed: () {
                    if (widget.childButtons[index].currentButton.onPressed != null) {
                      widget.childButtons[index].currentButton.onPressed();
                    }

                    this._animationController.reverse();
                  },
                  child: widget.childButtons[index].currentButton.child,
                  heroTag: widget.childButtons[index].currentButton.heroTag,
                  backgroundColor: widget.childButtons[index].currentButton.backgroundColor,
                  mini: widget.childButtons[index].currentButton.mini,
                  tooltip: widget.childButtons[index].currentButton.tooltip,
                  key: widget.childButtons[index].currentButton.key,
                  elevation: widget.childButtons[index].currentButton.elevation,
                  foregroundColor: widget.childButtons[index].currentButton.foregroundColor,
                  highlightElevation: widget.childButtons[index].currentButton.highlightElevation,
                  isExtended: widget.childButtons[index].currentButton.isExtended,
                  shape: widget.childButtons[index].currentButton.shape);

              var scale = CurvedAnimation(
                parent: this._animationController,
                curve: Interval(intervalValue, 1.0, curve: Curves.linear),
              );

              var textLabel =
                  (!widget.childButtons[index].hasLabel) || widget.orientation == UnicornOrientation.HORIZONTAL
                      ? Container()
                      : Container(
                          padding: EdgeInsets.only(right: widget.childPadding),
                          child: widget.childButtons[index].returnLabel());

              return Positioned(
                right: widget.orientation == UnicornOrientation.VERTICAL
                    ? widget.childButtons[index].currentButton.mini ? 4.0 : 0.0
                    : ((widget.childButtons.length - index) * 55.0) + 15,
                bottom: widget.orientation == UnicornOrientation.VERTICAL
                    ? ((widget.childButtons.length - index) * 55.0) + 15
                    : 8.0,
                child: Row(
                  children: [
                    SizeTransition(
                        axis: Axis.vertical,
                        axisAlignment: 1.0,
                        sizeFactor: scale,
                        child: textLabel),
                    SizeTransition(
                      axis: Axis.vertical,
                      axisAlignment: 1.0,
                      sizeFactor: scale,
                      child: childFAB,
                    ),
/*
                    ScaleTransition(
                        scale: scale,
                        alignment: FractionalOffset.center,
                        child: textLabel),
                    ScaleTransition(
                      scale: scale,
                      alignment: FractionalOffset.center,
                      child: childFAB,
                    ),
*/
                  ],
                ),
              );
            });

@tiagojencmartins tiagojencmartins added the bug Something isn't working label Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants