-3
import 'package:flutter/material.dart';
import 'package:local_food_vrhnika/sidebar.dart';
import 'package:local_food_vrhnika/style/style.dart';

class FirstPage extends StatelessWidget {
  const FirstPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: new AppBar(
        backgroundColor: rdecaDva,
        shadowColor: Colors.black,
        centerTitle: true,
        title: RichText(
            text: TextSpan(
                style: TextStyle(fontWeight: FontWeight.bold),
                children: [
              TextSpan(
                  text: 'Local',
                  style:
                      naslov(textStyle: TextStyle(color: tekst, fontSize: 25))),
              TextSpan(
                  text: 'food',
                  style: naslov(
                      textStyle: TextStyle(color: oranznaDva, fontSize: 20))),
              TextSpan(
                  text: 'Vrhnika',
                  style:
                      naslov(textStyle: TextStyle(color: tekst, fontSize: 25)))
            ])),
        /*leading: IconButton(
          icon: new Icon(Icons.food_bank),
          onPressed: () => Scaffold.of(context).openDrawer(),
        ),*/
      ),
      drawer: SideDrawer(),
      body: Center(
        child: Container(
          decoration: BoxDecoration(
              gradient: LinearGradient(
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                  colors: [oranzna!, oranznaDva!, rdecaDva!])),
        ),
      ),
    );
  }
}

I want to have a container below appbar that i already have and in this container text. But all of the answers that i got made my gradient background colors go from background to edges of container and now i have white background with container with those colors...

slovenian_boy
  • 35
  • 1
  • 6

4 Answers4

0

Try to below code like Container format because you close the one closing bracket before child Container remove it I give your answer on your image:

Center(
  child: Container(
   //1st Container
    child: Container(
      //2nd Container
    ),
  ),
),
Ravindra S. Patil
  • 11,757
  • 3
  • 13
  • 40
  • it works but at the same time it deletes background color (gradient) that i have done before and now the edgeinsets.all are the color of my before background (gradient) – slovenian_boy Aug 03 '21 at 09:39
0
You have to write it right after the color line , you are assigning a child outside of the container , thats why its giving an error 

body: Center(
child: Container(
decoration: BoxDecoration( 
gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [oranzna!, oranznaDva!, rdecaDva!])),
child:Container(
// your code here
),
 ), 
 )
 
Arsalan Khan
  • 146
  • 8
0

Container(child: Text('Write Some Text Here'))

0

The easiest way this problem use the Wrap widget. You can explore Column and Row widgets.

body: Center(
  child: Wrap(
    direction: Axis.vertical, //or horizontal
    children: <Widget>[
      Container(...),
      Container(...), // or Text('')
    ]
  )
)