How to create tiktok record Button Animation in flutter - flutter

I am create an app that allow users to record videos and want to create a record button similar to tiktok, I have already create the prerecord button but I don't know how to add the animation.
Widget recordbutton() {
return Container(
width: 80,
height: 80,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
width: 4, color: !isRecording ? Colors.white : Colors.red),
),
child: Container(
margin: EdgeInsets.all(8),
width: 40,
height: 40,
decoration: BoxDecoration(
color: !isRecording ? Colors.white : Colors.red,
borderRadius: BorderRadius.circular(30),
),
),
);}
On long press the button should animate like the gif below

you u can use rive for animations like that.
You can see the example https://www.youtube.com/watch?v=-m0elXGQPLo

Related

Container color in flutter

I want a colour for container but getting error while using colour.
My code:
Container(
color:Colors.red,
width: 50,
height: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50)
)
),
You can't use "color" and "decoration" at the same time. You need to pass the "color" parameter to the "BoxDecoration" widget like this:
Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color:Colors.red,
borderRadius: BorderRadius.circular(50)
)
),
You cannot add color to the container if you add decorations. The solution is to enter color into the decoration box as follows
Container(
width: 50,
height: 50,
decoration: BoxDecoration(color: Color.red)
)
Please use color in BoxDecoration like this
Container( width: 50, height: 50, decoration: BoxDecoration( borderRadius: BorderRadius.circular(50),color:Colors.red,)),
You can't give both colors and decoration to Container(). If you are looking to give color and decoration to Container, give color inside Boxdecoration
Container(
width: 50,
height: 50,
decoration: BoxDecoration(color: Color.red)
)
Use color inside container directly to set the background for the children. If you use any decoration then it will conflict with outside color. In those case you need to give color inside decoration.
FullCode : here
Column(
children: [
Container(
padding: EdgeInsets.all(10),
color: Colors.green,
child: Text('test'),
),
SizedBox(height: 10),
Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(10),
),
child: Text('test'),
)
],
)
Output for the above code is
The container does not accept the color parameter when there is a decoration parameter. This happens because the BoxDecoration has a color parameter. Just put the color inside the BoxDecoration and remove the color parameter from the Container and your problem will be solved.
Container(
width: 50,
height: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: Colors.red
)
),

Error flutter box decoration image no working with unexpected error

I'm getting the this error
error on a BoxDecoration saying "Cannot provide both a color and a decoration"
What should I do to resolve the issue? here is the file where it occurs:
...
child: Container(
height: 50,
width: 100,
color: Colors.blue,
decoration: BoxDecoration(
color: Color(0XFFEF6C00),
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(30),
bottomLeft: Radius.circular(50)
)
),
child: ...
)
As stated in the error you are getting you cannot use both color and decoration properties in a Container.
The correct way to provide a color when you also want to give different types of BoxDecoration is by adding the color options inside the BoxDecoration
DO
...
child: Container(
height: 50,
width: 100,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.only(...)
),
),
DON'T
...
child: Container(
height: 50,
width: 100,
color: Colors.blue,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.only(...)
),
),
The second method of adding color to a container will return the error you are getting.

How can I create this circles for my flutter UI?

I want to create those blue circles (you can see them on the picture), the app UI design was created with Figma.
I don't even know how to start, I'm new at flutter
Any ideas or tips?
You can start learning from flutter.dev.
There are many ways to do this. I am using Container with decoration
Container(
height: 70,
width: 70,
padding: EdgeInsets.all(10), //spacing using padding
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(width: 5, color: Colors.blue),
),
child: const Material( //inner circle
color: Colors.green,
shape: CircleBorder(),
),
)
More about Container.

I get an issue with borderRadius in flutter

Recently I update Flutter to the newest version, and I found an issue, when i try to add a borderRadius, the IDE indicates that i need to use borderRadiusGeometry, does somebody know how to fix it?
return Container(
child: Card(
child: Text('${myNumbers[index]}'),
color: Colors.black,
),
decoration: const BoxDecoration(
color: Colors.black,
borderRadius: BorderRadiusGeometry.lerp <<--- i need to replace this line
),
height: 100,
margin: const EdgeInsets.all(20),
alignment: Alignment.center,
);
Replace
borderRadius: BorderRadiusGeometry.lerp
with
borderRadius: BorderRadius.circular(10),

RectangleBox In Flutter

In my code, there is this CircleAvtar which I want to replace it with a big rectangular box. I am new to flutter I am finding it difficult to achieve this.
child: Card(
elevation: 3,
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
child: Container(
margin: EdgeInsets.all(5),
padding: EdgeInsets.all(5),
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(
10,
),
// border: Border.all(width: 0.5),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
color: whiteColor,
),
child: expertiseSearchModel.userImageURL.isEmpty
? CircleAvatar(
radius: 35,
child: SvgPicture.asset(
'assets/images/default_user_image.svg',
// height: screenUtil.setSp(80),
// width: screenUtil.setSp(80),
fit: BoxFit.contain,
),
)
: CircleAvatar(
radius: 35,
backgroundImage:
NetworkImage(expertiseSearchModel.userImageURL),
),
),
I want it to look like this :
If you can show us what your current code is giving the output maybe I can help you more. But As far as i understood this, you can simple use Image.Network() to show the image and remove the circular avatar
Try this, if it works if not lemme know I will edit it accordingly
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
color: whiteColor,
),
child: expertiseSearchModel.userImageURL.isEmpty
? CircleAvatar(
radius: 35,
child: SvgPicture.asset(
'assets/images/default_user_image.svg',
// height: screenUtil.setSp(80),
// width: screenUtil.setSp(80),
fit: BoxFit.contain,
),
)
: Image.network(expertiseSearchModel.userImageURL)
),
Inside your main container use the column as a child and put another container as a child and use the Image decoration property of the container to display pictures. You can change the border-radius of the child container to have those circular edges.