2

I want to run a tag animation horizontal one time only when user want to see detail of product there is a Tag of sale but nothing happen. I've looked all solutions but couldn't solve myself.

This is the GIF,

This is the gif how I want to move.

and this is image of stack I want to move like in gif a line is moving

enter image description here

return SafeArea(
  child: Scaffold(
    backgroundColor: fBackgroundColor,
    appBar: PreferredSize(
        preferredSize: const Size.fromHeight(50),
        child: subAppBarMain(context)),
    body: Column(
      children: [
        Expanded(
          child: ListView(
            children: [
              Padding(
                padding: const EdgeInsets.symmetric(
                    horizontal: 10.0, vertical: 10.0),
                child: Container(
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(10.0)),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      SizedBox(
                        height: 10.0,
                      ),
                      Center(
                        child: Image.asset(
                          widget.listModel.image!,
                        ),
                      ),
                      TweenAnimationBuilder(
                          tween: Tween<double>(
                              begin: 0.0,
                              end: MediaQuery.of(context).size.width),
                          duration: const Duration(milliseconds: 4000),
                          builder: (context, double i, _) {
                            return Stack(
                              children: [
                                SizedBox(
                                  height: 20,
                                  width: 115,
                                  child: CustomPaint(
                                    painter: PriceTagPaint(),
                                    child: Center(
                                      child: Padding(
                                        padding: const EdgeInsets.only(
                                            right: 16.0),
                                        child: Align(
                                          alignment: Alignment.centerRight,
                                          child: Text(
                                            widget.listModel.sale!,
                                            textAlign: TextAlign.center,
                                            style: const TextStyle(
                                                fontSize: 10,
                                                fontWeight: FontWeight.bold,
                                                color: Colors.white),
                                          ),
                                        ),
                                      ),
                                    ),
                                  ),
                                ),
                                Container(
                                  width: 50,
                                  height: 20,
                                  color: Colors.black,
                                  child: const Center(
                                    child: Text(
                                      "SALE",
                                      style: TextStyle(
                                          fontSize: 10,
                                          fontWeight: FontWeight.w500,
                                          color: Colors.white),
                                    ),
                                  ),
                                ),
                              ],
                            );
                          }),
                      SizedBox(
                        height: 20,
                        width: 65,
                        child: CustomPaint(
                          painter: ExpressPaint(),
                          child: Center(
                            child: Text(
                              widget.listModel.express!,
                              style: const TextStyle(
                                  fontSize: 10,
                                  fontWeight: FontWeight.bold,
                                  color: Colors.black),
                            ),
                          ),
                        ),
                      ),

Where I'm making mistake?

1 Answers1

0

You can use Tween<Alignment> and use it on Stack

SizedBox(
  width: double.maxFinite,
  child: TweenAnimationBuilder(
      tween: Tween<Alignment>(
          begin: Alignment.centerLeft,
          end: Alignment.centerRight),
      duration:
          const Duration(milliseconds: 4000),
      builder: (context, Alignment i, _) {
        return Stack(
          alignment: i,
          children: [
Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56