skip to Main Content

I have a list view with 9 items , and each item has a same dark blue picture in their left

ListView.builder(
              itemCount: 9,
              itemBuilder: (BuildContext context, int index) {
                return Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Image.asset(
                        "assets/logos/navy-circle.png",
                        width: 40,
                        height: 40,
                      ),
                      const SizedBox(width: 20),
                      Expanded(
                        child: Text(
                          'Paragraph ${index + 1}: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor.',
                          style: const TextStyle(color: Colors.white, fontSize: 13, fontWeight: FontWeight.bold),
                        ),
                      ),
                    ],
                  ),
                );
              },
            ),

it looks like this :

enter image description here

but i want to add an Arrow icon throw the images , something like this :

enter image description here

any idea? thanks

2

Answers


  1. You can try this:

    ListView.builder(
            itemCount: 9 + 2, // top and buttom of arrow
            itemBuilder: (BuildContext context, int index) {
              if (index == 0) {
                // end of arrow
                return Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 8.0),
                  child: Row(
                    children: [
                      SizedBox(
                        height: 40,
                        width: 40,
                        child: Container(// replace this with your svg arrow tail
                          color: Colors.white,
                        ),
                      ),
                    ],
                  ),
                );
              }
              if (index == 11 - 1) {
                // head of arrow
                return Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 8.0),
                  child: Row(
                    children: [
                      SizedBox(
                        height: 40,
                        width: 40,
                        child: Container( // replace this with your svg arrow head
                          color: Colors.white,
                        ),
                      ),
                    ],
                  ),
                );
              }
              return Padding(
                padding: const EdgeInsets.symmetric(
                  horizontal: 8.0,
                ),
                child: IntrinsicHeight(
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Stack(
                        alignment: Alignment.center,
                        children: [
                          Container(
                            width: 4,
                            color: Colors.white,
                          ),
                          Container(
                            width: 40,
                            height: 40,
                            decoration: const BoxDecoration(
                              shape: BoxShape.circle,
                              color: Colors.blueGrey,
                            ),
                          ),
                        ],
                      ),
                      const SizedBox(width: 20),
                      Expanded(
                        child: Padding(
                          padding: const EdgeInsets.symmetric(vertical: 8.0),
                          child: Text(
                            'Paragraph ${index + 1}: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor.',
                            style: const TextStyle(
                                color: Colors.white,
                                fontSize: 13,
                                fontWeight: FontWeight.bold),
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              );
            },
          )
    

    enter image description here

    NOTE: I don’t have svgs of the arrow’s head and tail so I used simple white container, you can replace those with your image.

    Login or Signup to reply.
  2. A suggestion for a dynamic screen is to use the Stepper Widget https://api.flutter.dev/flutter/material/Stepper-class.html

    /// Flutter code sample for [Stepper].
    
    void main() => runApp(const StepperExampleApp());
    
    class StepperExampleApp extends StatelessWidget {
      const StepperExampleApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: Scaffold(
            appBar: AppBar(title: const Text('Stepper Sample')),
            body: const Center(
              child: StepperExample(),
            ),
          ),
        );
      }
    }
    
    class StepperExample extends StatefulWidget {
      const StepperExample({super.key});
    
      @override
      State<StepperExample> createState() => _StepperExampleState();
    }
    
    class _StepperExampleState extends State<StepperExample> {
      int _index = 0;
    
      @override
      Widget build(BuildContext context) {
        return Stepper(
          currentStep: _index,
          onStepCancel: () {
            if (_index > 0) {
              setState(() {
                _index -= 1;
              });
            }
          },
          onStepContinue: () {
            if (_index <= 0) {
              setState(() {
                _index += 1;
              });
            }
          },
          onStepTapped: (int index) {
            setState(() {
              _index = index;
            });
          },
          steps: <Step>[
            Step(
              title: const Text('Step 1 title'),
              content: Container(
                alignment: Alignment.centerLeft,
                child: const Text('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.'),
              ),
            ),
            const Step(
              title: Text('Step 2 title'),
              content: Text('Content for Step 2'),
            ),
          ],
        );
      }
    }
    

    steper_example

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search