Skip to content

Instantly share code, notes, and snippets.

@maks
Created July 1, 2020 05:39
Show Gist options
  • Save maks/20fdcf060ed4e16c882a9a975e487049 to your computer and use it in GitHub Desktop.
Save maks/20fdcf060ed4e16c882a9a975e487049 to your computer and use it in GitHub Desktop.
example for 9-slice in Flutter article
// Copyright 2019 the Dart project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file.
import 'package:flutter/material.dart';
final Color primaryColor = Colors.orange;
final TargetPlatform platform = TargetPlatform.android;
void main() {
runApp(NineSlice());
}
class NineSlice extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(title: Text("9 slice")),
body: Center(
// src of img: https://developer.mozilla.org/en-US/docs/Web/CSS/border-image
child: Image.network(
'https://mdn.mozillademos.org/files/4127/border.png',
height: 300,
fit: BoxFit.fill,
centerSlice: Rect.fromLTWH(27, 27, 27, 27),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment