Search code examples
flutter

Flutter make repeat image as pattern


in flutter how can i fill image with pattern? for example i want to fill screen by this square image

enter image description here

my code doesn't work:

  Widget build(BuildContext context) {
    return Consumer<ThemeManager>(builder: (context, theme, child) {
      return Directionality(
        textDirection: TextDirection.rtl,
        child: Container(
          width: double.infinity,
          height: double.infinity,
          child: Stack(
            children: <Widget>[
              Image.asset('assets/images/sBoeM.jpg',repeat: ImageRepeat.repeat,),
            ],
          ),
        ),
      );
    });
  }

Solution

  • you need to wrap your Image widget with Positioned.fill widget

        Positioned.fill(
          child: Image.asset(
            'images/sBoeM.jpg',
            repeat: ImageRepeat.repeat,
          ),
        ),