create dynamic widget in flutter

 Today in this post we will learn to make a dynamic list inside which there will be an icon and then a text and then we will learn to put the back icon of the iPhone. Follow all the steps told by us.


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


class AccountDetail extends StatefulWidget {
  @override
  _AccountDetailState createState() => _AccountDetailState();
}

class _AccountDetailState extends State{
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("App Bar"),
      ),
    
    body: Container(
      child: Column(
        children: [
          Expanded(child: Container(
            child: ListView(
              children: [
                Container(
                  color: Colors.blue,
                  child: Column(
                 children: [
                  buildMenuItem(Icons.home, "Dashboard", context,),
                ],
            ),

                ),
                buildMenuItem(Icons.home, "Dashboard", context,),
                buildMenuItem(Icons.home, "Dashboard", context,),
              ],
            ),
          ))
        ],
      ),
    ),
    
    );
  }

  Widget buildMenuItem(IconData icon, String title, BuildContext context, [Widget? screen, Color? iconColor]) {
    return ListTile(
      leading: Container(
        alignment: Alignment.center,
        child: Row(
          children: [
            Icon(icon, color: iconColor ?? Colors.black),
            SizedBox(width: 10,),
            Text(title, style: TextStyle(fontSize: 16)),
            Spacer(),
            Icon(Icons.arrow_forward_ios, size: 16),
          ],
        ),
      ),

      onTap: () {
        if (screen != null) {
          Navigator.push(
            context,
            MaterialPageRoute(builder: (context) => screen),
          );
        }
      },
    );
  }
}

  
 

 Output


 Buy Source Code

If you want to buy its complete source code, then click on the payment button given below and make the payment. After making the payment, you can download its complete source code. And after downloading, you can input this project in your Android studio and after inputting, you can use it very easily. Even after that if you face any problem, you can contact us.


Post a Comment

0 Comments