How to create car start/stop button in flutter?

51 Views Asked by At

I want to create car selling app. I want use car start/stop button on onboarding screen & on tap play car engine start sound? Could you help for creating this widget?

Car start/stop button widget

enter image description here

Creating car start/stop button

1

There are 1 best solutions below

1
Milan Labus On

You could do something like:

import 'package:flutter/material.dart';

class CarButton extends StatelessWidget {
  const CarButton({super.key});

  @override
  Widget build(BuildContext context) {
    bool isPressed = false;
    return GestureDetector(
      onTap: () {
        isPressed = !isPressed;
      },
      child: Column(
        children: [
          isPressed
              ? Container(
                  height: 10,
                  width: 30,
                  color: Colors.green,
                )
              : Container(
                  height: 10,
                  width: 30,
                  color: Colors.grey,
                ),
          Text('Start'),
          Text('Stop')
        ],
      ),
    );
  }
}