Câu hỏi phỏng vấn Flutter
Câu hỏi

Làm sao để tạo animation đơn giản với AnimatedContainer?

Câu trả lời

markdown Copy
Để tạo animation đơn giản với `AnimatedContainer`, bạn cần chú ý các bước chính: **khởi tạo** `AnimatedContainer` với các thuộc tính như `width`, `height`, `color`, vv. mà bạn muốn thay đổi. **Thay đổi giá trị** các thuộc tính thông qua hàm setState để kích hoạt animation. **Chọn duration** phù hợp để animation diễn ra mượt mà. 

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('AnimatedContainer Demo')),
        body: Center(child: AnimatedContainerDemo()),
      ),
    );
  }
}

class AnimatedContainerDemo extends StatefulWidget {
  @override
  _AnimatedContainerDemoState createState() => _AnimatedContainerDemoState();
}

class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
  double _width = 200.0;
  ...
middle

middle

Gợi ý câu hỏi phỏng vấn

middle

Làm thế nào để tạo HTTP Requests trong Flutter?

expert

Chế độ debug và chế độ profile khác nhau như thế nào?

junior

So sánh 3 kiểu khai báo biến dynamic, varfinal trong Flutter?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào