1.
Tap & Drag Gesture Example (BL: 2)
GestureDetector(
onTap: () => print("Tapped"),
onPanUpdate: (d) => setState(() => _pos += d.delta),
child: Positioned(left: _pos.dx, top: _pos.dy, child: Container(...)),
2. Form with Email & Password Validation (BL: 3)
TextFormField(
validator: (val) => val!.contains('@') ? null : 'Invalid Email',
),
TextFormField(
obscureText: true,
validator: (val) => val!.length >= 6 ? null : 'Short Password',
),
3. Route Generator Example (BL: 3)
onGenerateRoute: (settings) {
if (settings.name == '/second') return MaterialPageRoute(builder: (_) => Second());
return MaterialPageRoute(builder: (_) => NotFound());
Use case: Centralized route management.
4. Common Flutter Gestures (BL: 2)
GestureDetector(
onTap: () {}, onDoubleTap: () {}, onLongPress: () {}, onPanUpdate: (_) {},
5. Passing Data Between Pages (BL: 3)
Navigator.push(context, MaterialPageRoute(
builder: (_) => SecondPage(data: "Hi"),
));
In SecondPage:
final String data;
6. Animation Libraries Example (BL: 3)
AnimatedContainer(
duration: Duration(seconds: 1),
width: toggle ? 200 : 100,
color: toggle ? Colors.red : Colors.blue,
7. Custom Animation Code (BL: 3)
AnimationController _c = AnimationController(...);
Animation<double> _a = Tween(begin: 0, end: 300).animate(_c);
8. Named Routes in Navigation (BL: 3)
routes: {'/home': (_) => HomePage(), '/about': (_) => AboutPage()}
Benefits: Clean, maintainable navigation.
9. Sliding Animation Example (BL: 2)
SlideTransition(
position: Tween(begin: Offset(1, 0), end: Offset.zero).animate(_controller),
child: Container(...),
10. Implicit vs Explicit Animation (BL: 3)
- Implicit:
AnimatedContainer(duration: ..., width: toggle ? 100 : 200)
- Explicit:
AnimationController + Tween + AnimationBuilder