Skip to content

Instantly share code, notes, and snippets.

@AleksandarSavic95
Last active February 13, 2020 11:20
Show Gist options
  • Save AleksandarSavic95/e85a800a06a2bcb4ad28ea27054d19b7 to your computer and use it in GitHub Desktop.
Save AleksandarSavic95/e85a800a06a2bcb4ad28ea27054d19b7 to your computer and use it in GitHub Desktop.
Flutter's `RaisedButton` with text centered, and an image besides it. Like this: https://i.stack.imgur.com/9LT1K.png
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Created by: AleksandarSavic95
// Created as an answer to this question:
// https://stackoverflow.com/q/49442247/2101117
//
// Description: Flutter's `RaisedButton` with text centered,
// and an image besides it. Like this: https://i.stack.imgur.com/9LT1K.png
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
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> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
width: 500,
child: RaisedButton(
onPressed: () {},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(child: Text(
'Push it! '*10,
textAlign: TextAlign.center,
),),
Image.network(
'https://picsum.photos/250?image=9',
),
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment