flutter boxdecoration border color code example

Example 1: flutter container border

Container(
  decoration: BoxDecoration(
    border: Border.all(
      color: Colors.red,  // red as border color
    ),
  ),
  child: Text("Your text...")
)

Example 2: add border color to acouintainer in flutter

Container(
  height: 100,
  width: 100,
  decoration: BoxDecoration(
    border: Border.all(
      color: Colors.blue,
    ),
    borderRadius: BorderRadius.circular(10.0),
  ),
  child: Center(
    child: Text('mrflutter.com'),
  ),
),

Example 3: border for container in flutter

new Container(
  margin: const EdgeInsets.all(15.0),
  padding: const EdgeInsets.all(3.0),
  decoration: BoxDecoration(
    border: Border.all(color: Colors.blueAccent)
  ),
  child: Text("My Awesome Border"),
)

Example 4: border side in flutter

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        child: Text(
          "This is a Boder with One Side",
          textDirection: TextDirection.ltr,
          style: TextStyle(color: Colors.black),
        ),
        padding: EdgeInsets.symmetric(vertical: 100.0, horizontal: 100.0),
        decoration: BoxDecoration(
          border: Border(
            top: BorderSide(width: 16.0, color: Colors.lightBlue.shade600),
            bottom: BorderSide(width: 16.0, color: Colors.lightBlue.shade900),
          ),
          color: Colors.white,
        ),
      ),
    );
  }
}

Example 5: container border flutter

BoxDecoration myBoxDecoration() {
  return BoxDecoration(
    border: Border.all(),
  );
}

Tags:

Misc Example