admin管理员组

文章数量:1297078

Trying experiments with Flutter and found this article how to build a Responsive UI for multiple screen sizes. I want to make 'Header' area to be expandable. Found ExpansionPanel class but can't make this area to be correctly work with. Any suggestions? enter image description here

Trying experiments with Flutter and found this article how to build a Responsive UI for multiple screen sizes. I want to make 'Header' area to be expandable. Found ExpansionPanel class but can't make this area to be correctly work with. Any suggestions? enter image description here

Share Improve this question asked Feb 11 at 16:23 gothicagothica 13 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can use a SilverAppBar

Here is an example of UI that can explain the logic.

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: CustomScrollView(
          slivers: <Widget>[
            // SliverAppBar is the expandable header
            SliverAppBar(
              expandedHeight: 200.0, // Maximum header height
              floating: false, // Does not float when scrolling
              pinned: true, // Fix header when scrolling
              snap: false, // Does not "snap" when scrolling
              flexibleSpace: FlexibleSpaceBar(
                title: Text('Header Expansível'),
                background: Imagework(
                  'https://via.placeholder/400x200', // Background image
                  fit: BoxFit.cover,
                ),
              ),
            ),
            // Content below the header
            SliverList(
              delegate: SliverChildBuilderDelegate(
                (BuildContext context, int index) {
                  return ListTile(
                    title: Text('Item $index'),
                  );
                },
                childCount: 50, // Number of items in the list
              ),
            ),
          ],
        ),
      ),
    );
  }
}

本文标签: user interfaceMake responsive UI element to be expansible vertically in FlutterStack Overflow