具有水平和垂直中心对齐分隔线的 GridView

use*_*570 5 dart flutter flutter-layout

我正在尝试绘制如下图所示的分隔线。

在此处输入图片说明

我正在考虑水平添加 5 列,并使用 1 dp 行缩小分隔列。但是,在 Flutter 中,所有列的宽度都相等,这似乎或可能是我错了。

如何绘制如下图所示的行和列分隔符?

这是我正在使用的代码

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
   @override
Widget build(BuildContext context) {
 
  Widget gridSection = Expanded(
    flex: 1,
    child: GridView.count(
      crossAxisCount: 3,
      childAspectRatio: 1.0,
      shrinkWrap:true,
      mainAxisSpacing: 2.0,      
      crossAxisSpacing: 2.0,
      padding: const EdgeInsets.all(4.0),
      children: <String>[
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
            'http://www.for-example.org/img/main/forexamplelogo.png',
          ].map((String url) {
            return GridTile(
                child: Image.network(url, fit: BoxFit.cover));
          }).toList()),
  );
 
  Widget body = Column(
    crossAxisAlignment: CrossAxisAlignment.stretch,
    mainAxisSize: MainAxisSize.min,
    children: <Widget>[
      gridSection,
    ],
  );
 
  return Scaffold(
    appBar: AppBar(
      title: Text("Example 2 Page"),
    ),
    body: Padding(
      padding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 0.0),
      child: body,
    ),
  );
}
}
Run Code Online (Sandbox Code Playgroud)

Abd*_*ber 0

我知道为时已晚,但我认为您可以使用 Stack 实现这一目标(或实现这一目标),并且线条可以是静态图像,而网格可以位于其上方