🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / FLUTTER / OnboardingScreenPage açılış tanıtım sayfası

1-) FLUTTER - OnboardingScreenPage açılış tanıtım sayfası

 

flutter pub add lottie

 

açıklama : lottie animasyondur .json tipindedir.

 

 

import 'dart:math';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
import 'package:uuid/uuid.dart';

class OnboardingScreen extends StatefulWidget {
  
const OnboardingScreen({Key? key}) : super(key: key);

  
@override
  
State<OnboardingScreen> createState() => _OnboardingScreenState();
}

class _OnboardingScreenState extends State<OnboardingScreen> {
  
int _currentIndex = 0;
  
final PageController _pageController = PageController();

  
@override
  
Widget build(BuildContext context) {
    
var screenSize = MediaQuery.of(context).size;
    
return Scaffold(
      
backgroundColor: Colors.black,
      
body: Stack(
        
children: [
          
CustomPaint(
            
painter: ArcPainter(),
            
child: SizedBox(
              
height: screenSize.height / 1.29,
              
width: screenSize.width,
            ),
          ),
          
Positioned(
            
top: 130,
            
right: 5,
            
left: 5,
            
child: Lottie.asset(
              
tabs[_currentIndex].lottieFile,
              
key: Key('${Random().nextInt(999999999)}'),
              
width: 600,
              
alignment: Alignment.topCenter,
            ),
          ),
          
Align(
            
alignment: Alignment.bottomCenter,
            
child: SizedBox(
              
height: 270,
              
child: Column(
                
children: [
                  
Flexible(
                    
child: PageView.builder(
                      
controller: _pageController,
                      
itemCount: tabs.length,
                      
itemBuilder: (BuildContext context, int index) {
                        
OnboardingModel tab = tabs[index];
                        
return Column(
                          
mainAxisSize: MainAxisSize.min,
                          
children: [
                            
Center(
                              
child: Text(
                                
tab.title,
                                
style: const TextStyle(
                                  
fontSize: 27.0,
                                  
fontWeight: FontWeight.bold,
                                  
color: Colors.white
                                
),
                                
textAlign: TextAlign.center,
                              ),
                            ),
                            
const SizedBox(height: 50),
                            
Text(
                              
tab.subtitle,
                              
style: const TextStyle(
                                
fontSize: 17.0,
                                
color: Colors.white70,
                              ),
                              
textAlign: TextAlign.center,
                            )
                          ],
                        );
                      },
                      
onPageChanged: (value) {
                        
_currentIndex = value;
                        setState(() {});
                      },
                    ),
                  ),
                  
Row(
                    
mainAxisSize: MainAxisSize.min,
                    
children: [
                      
for (int index = 0; index < tabs.length; index++)
                        
_DotIndicator(isSelected: index == _currentIndex),
                    ],
                  ),
                  
const SizedBox(height: 75)
                ],
              ),
            ),
          ),
        ],
      ),
      
floatingActionButton: FloatingActionButton(
        
onPressed: () {
          
if (_currentIndex == 2) {
            
// _pageController.animateToPage(
            //   0,
            //   duration: const Duration(milliseconds: 300),
            //   curve: Curves.linear,
            // );
            
Navigator.pushReplacement(
              
context,
              
MaterialPageRoute(builder: (context) => GidilmesiGerekenSayfa(key: GlobalKey(debugLabel: Uuid().v4() ),),),
            );
          }
else {
            
_pageController.nextPage(
              
duration: const Duration(milliseconds: 300),
              
curve: Curves.linear,
            );
          }
        },
        
child: const Icon(CupertinoIcons.chevron_right, color: Colors.white),
        
backgroundColor: Colors.transparent,
      ),
    );
  }
}

class ArcPainter extends CustomPainter {
  
@override
  
void paint(Canvas canvas, Size size) {
    
Path orangeArc = Path()
      ..moveTo(
0, 0)
      ..lineTo(
0, size.height - 170)
      ..quadraticBezierTo(
          
size.width / 2, size.height, size.width, size.height - 170)
      ..lineTo(
size.width, size.height)
      ..lineTo(
size.width, 0)
      ..close();

    
canvas.drawPath(orangeArc, Paint()..color = Colors.orange);

    
Path whiteArc = Path()
      ..moveTo(
0.0, 0.0)
      ..lineTo(
0.0, size.height - 185)
      ..quadraticBezierTo(
          
size.width / 2, size.height - 70, size.width, size.height - 185)
      ..lineTo(
size.width, size.height)
      ..lineTo(
size.width, 0)
      ..close();

    
canvas.drawPath(whiteArc, Paint()..color = Colors.white);
  }

  
@override
  
bool shouldRepaint(covariant CustomPainter oldDelegate) {
    
return false;
  }
}

class _DotIndicator extends StatelessWidget {
  
final bool isSelected;

  
const _DotIndicator({Key? key, required this.isSelected}) : super(key: key);

  
@override
  
Widget build(BuildContext context) {
    
return Padding(
      
padding: const EdgeInsets.only(right: 6.0),
      
child: AnimatedContainer(
        
duration: const Duration(milliseconds: 300),
        
height: 6.0,
        
width: 6.0,
        
decoration: BoxDecoration(
          
shape: BoxShape.circle,
          
color: isSelected ? Colors.white : Colors.white38,
        ),
      ),
    );
  }
}

class OnboardingModel {
  
final String lottieFile;
  
final String title;
  
final String subtitle;

  
OnboardingModel(this.lottieFile, this.title, this.subtitle);
}

List<OnboardingModel> tabs = [
  
OnboardingModel(
    
'assets/images/1.json',
    
'BAŞLIK',
    
'AÇIKLAMA',
  ),
  
OnboardingModel(
    
'assets/images/2.json',
    
'BAŞLIK',
    
'AÇIKLAMA',
  ),
  
OnboardingModel(
    
'assets/images/3.json',
   
'BAŞLIK',
    
'AÇIKLAMA',
  ),
];

 

 

 2024 Ekim 11 Cuma
 207